From 23b1dc268aa1eab3cf43c44b9c7e4faf1f48d203 Mon Sep 17 00:00:00 2001 From: liudun Date: Fri, 19 Jan 2024 10:21:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5yangtze=E5=88=86=E6=94=AF?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bioauth-bin/i18n_ts/bo_CN.ts | 17 + bioauth-bin/i18n_ts/zh_CN.ts | 25 +- bioauth-bin/src/main.cpp | 91 ++++- bioauth/CMakeLists.txt | 1 + bioauth/i18n_ts/bo_CN.ts | 8 + bioauth/i18n_ts/zh_CN.ts | 14 +- bioauth/include/bioauth.h | 18 + bioauth/include/biodevices.h | 1 + bioauth/include/biotypes.h | 24 ++ bioauth/include/loginoptionswidget.h | 30 +- bioauth/src/bioauth.cpp | 79 +++- bioauth/src/biodevices.cpp | 72 ++++ bioauth/src/biotypes.cpp | 23 ++ bioauth/src/loginoptionswidget.cpp | 174 +++++++- debian/changelog | 42 +- debian/control | 8 +- debian/copyright | 95 ----- debian/libpam-biometric.install | 2 +- debian/libpam-biometric.manpages | 3 - debian/libpam-biometric.postinst | 2 +- debian/source/format | 2 +- debian/ukui-polkit.install | 1 + images/huawei/.DS_Store | Bin 0 -> 6148 bytes images/ukui-loginopt-face.svg | 2 +- images/ukui-loginopt-password.svg | 2 +- images/ukui-loginopt-ukey.svg | 31 ++ pam-biometric/CMakeLists.txt | 3 +- pam-biometric/logger.c | 10 +- pam-biometric/pam_biometric.c | 227 +++++++---- polkit-agent/CMakeLists.txt | 8 + ...kit-ukui-authentication-agent-1.desktop.in | 1 + polkit-agent/i18n_ts/bo_CN.ts | 12 +- polkit-agent/i18n_ts/zh_CN.ts | 14 +- polkit-agent/src/PolkitAgent.cpp | 8 +- polkit-agent/src/PolkitListener.cpp | 38 +- polkit-agent/src/kalabel.cpp | 17 - polkit-agent/src/kalabel.h | 17 - polkit-agent/src/mainwindow.cpp | 376 +++++++++++++++--- polkit-agent/src/mainwindow.h | 14 + polkit-agent/src/mainwindow.ui | 231 ++++++++--- polkit-agent/src/modeButton.cpp | 17 - polkit-agent/src/modeButton.h | 17 - uniauth-backend/CMakeLists.txt | 4 +- uniauth-backend/src/biodeviceinfo.h | 1 + uniauth-backend/src/main.cpp | 2 + uniauth-backend/src/serviceinterface.cpp | 33 ++ 46 files changed, 1364 insertions(+), 453 deletions(-) create mode 100644 images/huawei/.DS_Store create mode 100644 images/ukui-loginopt-ukey.svg diff --git a/bioauth-bin/i18n_ts/bo_CN.ts b/bioauth-bin/i18n_ts/bo_CN.ts index 4db662a..149ffa2 100644 --- a/bioauth-bin/i18n_ts/bo_CN.ts +++ b/bioauth-bin/i18n_ts/bo_CN.ts @@ -87,5 +87,22 @@ Unable to verify %1, please enter password. + + UKEY AUTHENTICATION + + + + BIOMETRIC AUTHENTICATION IS CLOSED + + + + AUTHENTICATION END + + + + Enter the ukey password + + + diff --git a/bioauth-bin/i18n_ts/zh_CN.ts b/bioauth-bin/i18n_ts/zh_CN.ts index d43bcb3..3361365 100644 --- a/bioauth-bin/i18n_ts/zh_CN.ts +++ b/bioauth-bin/i18n_ts/zh_CN.ts @@ -4,7 +4,16 @@ QObject - + Enter the ukey password + 输入ukey密码 + + + + Enter the ukey password + 输入ukey密码\n + + + Try it again 再试一次 @@ -81,7 +90,12 @@ - + + UKEY AUTHENTICATION + ukey认证 + + + BIOMETRIC AUTHENTICATION 生物识别认证 @@ -116,7 +130,12 @@ 无法验证%1,请输入密码. - + + AUTHENTICATION END + 认证结束 + + + BIOMETRIC AUTHENTICATION END 生物识别认证结束 diff --git a/bioauth-bin/src/main.cpp b/bioauth-bin/src/main.cpp index 2bd5322..ed29e03 100644 --- a/bioauth-bin/src/main.cpp +++ b/bioauth-bin/src/main.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -92,6 +93,39 @@ void showMessage(const QString &message, int type) fprintf(stdout, RESET_COLOR); } +QString inputPinCode() +{ + struct termios current; + struct termios save; + tcgetattr(0, &save); + + current = save; +// current.c_lflag &= ~ICANON; + current.c_lflag &= ~ECHO; + current.c_cc[VMIN] = 0; + current.c_cc[VTIME] = 0; + tcsetattr(0, TCSANOW, ¤t); + + QString password = ""; + showMessage(QObject::tr("Enter the ukey password"), QUESTION); + + char line[1024] = {0}; + fgets(line, sizeof(line), stdin); + //scanf("%s",&line); + + showMessage("\n", QUESTION); + + line[1023] = '\0'; + + if(line[strlen(line) - 1] == '\n') + line[strlen(line) - 1] = '\0'; + + QString str(line); + + tcsetattr(0, TCSANOW, &save); // 恢复原来的终端属性,以免干扰shall和之后的程序运行 + return line; +} + Option showOption(bool showSelectDevices) { QStringList optionList; @@ -247,13 +281,18 @@ int main(int argc, char *argv[]) if(bioDevices.getFeatureCount(uid)<1) exit(BIO_ERROR); - showMessage(QObject::tr("BIOMETRIC AUTHENTICATION"), START); - if(!isHiddenSwitchButton) - showMessage(QObject::tr("Press Q or Esc to cancel"), PROMPT); + if(deviceInfo->biotype == 6){ + showMessage(QObject::tr("UKEY AUTHENTICATION"), START); + }else{ + showMessage(QObject::tr("BIOMETRIC AUTHENTICATION"), START); + if(!isHiddenSwitchButton) + showMessage(QObject::tr("Press Q or Esc to cancel"), PROMPT); + } BioAuth bioAuth(uid, deviceInfo); KeyWatcher watcher; QMap m_failedTimes; + QObject::connect(&bioAuth, &BioAuth::notify, &a, [&](const QString &msg){ showMessage(msg, NOTIFY); }); @@ -261,7 +300,11 @@ int main(int argc, char *argv[]) Q_UNUSED(retErrNo); watcher.stop(); bool isBioEnable = bioDevices.GetBioAuthEnable(uid_); - if(!isBioEnable){ + bool isUkeyDevice = false; + if(deviceInfo && deviceInfo->biotype == 6){ + isUkeyDevice = true; + } + if(!isBioEnable && !isUkeyDevice){ showMessage(QObject::tr("BIOMETRIC AUTHENTICATION IS CLOSED"), RESULT); exit(BIO_IGNORE); } @@ -271,31 +314,43 @@ int main(int argc, char *argv[]) } else { showMessage(QObject::tr("AUTHENTICATION FAILED"), RESULT); - + DeviceInfoPtr curDeviceInfo = bioAuth.getDevice(); if (m_failedTimes.contains(deviceInfo->device_id)) { - m_failedTimes[deviceInfo->device_id] = m_failedTimes[deviceInfo->device_id] + 1; + m_failedTimes[curDeviceInfo->device_id] = m_failedTimes[curDeviceInfo->device_id] + 1; } else { - m_failedTimes[deviceInfo->device_id] = 1; + m_failedTimes[curDeviceInfo->device_id] = 1; } - if(m_failedTimes[deviceInfo->device_id]device_id]biotype)).arg(maxFailedTimes-m_failedTimes[deviceInfo->device_id]),RESULT); + showMessage(QObject::tr("Failed to verify %1, you still have %2 verification opportunities").arg(bioDevices.bioTypeToString_tr(curDeviceInfo->biotype)).arg(maxFailedTimes-m_failedTimes[deviceInfo->device_id]),RESULT); }else{ - showMessage(QObject::tr("Unable to verify %1, please enter password.").arg(bioDevices.bioTypeToString_tr(deviceInfo->biotype)),RESULT); + showMessage(QObject::tr("Unable to verify %1, please enter password.").arg(bioDevices.bioTypeToString_tr(curDeviceInfo->biotype)),RESULT); exit(BIO_IGNORE); } Option option = showOption(bioDevices.count() > 1); switch(option) { case OPTION_TRY_AGAIN: + + if(deviceInfo->biotype == 6){ + QString code = inputPinCode(); + bioAuth.SetExtraInfo("pincode",code); + } + bioAuth.startAuth(); watcher.start(); break; case OPTION_SELECT_DEVICE: { - DeviceInfoPtr deviceInfo = std::make_shared(); + deviceInfo = std::make_shared(); *deviceInfo = showDevices(bioDevices.getAllDevices()); bioAuth.setDevice(deviceInfo); + + if(deviceInfo->biotype == 6){ + QString code = inputPinCode(); + bioAuth.SetExtraInfo("pincode",code); + } + bioAuth.startAuth(); watcher.start(); break; @@ -305,8 +360,12 @@ int main(int argc, char *argv[]) { exit(BIO_ERROR); }else{ - showMessage(QObject::tr("BIOMETRIC AUTHENTICATION END"), START); - exit(BIO_IGNORE); + if(deviceInfo->biotype == 6){ + showMessage(QObject::tr("AUTHENTICATION END"), START); + }else{ + showMessage(QObject::tr("BIOMETRIC AUTHENTICATION END"), START); + } + exit(BIO_IGNORE); break; } default: @@ -314,6 +373,12 @@ int main(int argc, char *argv[]) } } }); + + if(deviceInfo->biotype == 6){ + QString code = inputPinCode(); + bioAuth.SetExtraInfo("pincode",code); + } + bioAuth.startAuth(); if(!isHiddenSwitchButton){ diff --git a/bioauth/CMakeLists.txt b/bioauth/CMakeLists.txt index 076db39..97f287c 100644 --- a/bioauth/CMakeLists.txt +++ b/bioauth/CMakeLists.txt @@ -35,6 +35,7 @@ include_directories( ${Qt5Widgets_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} + ${GIOUNIX2_INCLUDE_DIRS} include ../common ) diff --git a/bioauth/i18n_ts/bo_CN.ts b/bioauth/i18n_ts/bo_CN.ts index 42b8bca..4afb7e6 100644 --- a/bioauth/i18n_ts/bo_CN.ts +++ b/bioauth/i18n_ts/bo_CN.ts @@ -82,6 +82,10 @@ QRCode ཨང་ཀི་ཕྱག་པ། + + ukey + + BioDevicesWidget @@ -108,5 +112,9 @@ Login Options ཐོ་འགོད་ཀྱི་བསལ་འདེམས་ཀྱི་དབང་ཆ། + + Password + གསང་ཨང་། + diff --git a/bioauth/i18n_ts/zh_CN.ts b/bioauth/i18n_ts/zh_CN.ts index 6777054..d009954 100644 --- a/bioauth/i18n_ts/zh_CN.ts +++ b/bioauth/i18n_ts/zh_CN.ts @@ -28,7 +28,7 @@ Password - 密码 + 密码 Current Device: @@ -99,7 +99,12 @@ 声纹 - + + ukey + + + + QRCode 二维码 @@ -139,6 +144,11 @@ Login Options 登录选项 + + + Password + 密码 + Wechat 微信 diff --git a/bioauth/include/bioauth.h b/bioauth/include/bioauth.h index c3f4146..ee9d55b 100644 --- a/bioauth/include/bioauth.h +++ b/bioauth/include/bioauth.h @@ -36,11 +36,29 @@ public: explicit BioAuth(QObject *parent = nullptr); ~BioAuth(); void setDevice(const DeviceInfoPtr deviceInfo); + DeviceInfoPtr getDevice(); void startAuth(); + void startUkeyAuth(); void startAuth(qint32 uid, const DeviceInfoPtr deviceInfo); void stopAuth(); bool isAuthenticating(); void init(); + /** + * @brief 设置一些认证时所需的额外的信息 + * @param info_type 额外的信息类型,ukey pincode认证时传 "pincode" + * @param extra_info 额外的信息内容,ukey pincode认证时传PIN码内容 + * @return 结果: (设置额外信息的结果) + */ + int SetExtraInfo(QString info_type, QString extra_info); + /** + * @brief 获取当前用户已连接设备对应特征数目 + * @param uid 用户id + * @param indexStart 用于认证的特征索引范围 + * @param indexEnd + * @return 返回是否存在ukey特征 + */ + bool GetHasUkeyFeature(int uid, int indexStart = 0, int indexEnd = -1); + signals: void authComplete(int uid, bool result, int retErrNo); diff --git a/bioauth/include/biodevices.h b/bioauth/include/biodevices.h index 2aa8098..2308138 100644 --- a/bioauth/include/biodevices.h +++ b/bioauth/include/biodevices.h @@ -45,6 +45,7 @@ public: QMap> getUserDevices(int uid); QList getDevices(int type); DeviceInfoPtr getDefaultDevice(uid_t uid); + DeviceInfoPtr getDefaultDevice(uid_t uid,int bioType); int GetLastDevice(const QString &userName); void SetLastDevice(const QString &userName, int drvid); DeviceInfoPtr findDevice(const QString &deviceName); diff --git a/bioauth/include/biotypes.h b/bioauth/include/biotypes.h index 862d0ee..07a940f 100644 --- a/bioauth/include/biotypes.h +++ b/bioauth/include/biotypes.h @@ -34,6 +34,20 @@ #endif #define LOG() qDebug() << "[BIOMETRIC]" +enum LOGINOPT_TYPE { + LOGINOPT_TYPE_PASSWORD = 0, // 密码 + LOGINOPT_TYPE_FACE, // 人脸 + LOGINOPT_TYPE_FINGERPRINT, // 指纹 + LOGINOPT_TYPE_IRIS, // 虹膜 + LOGINOPT_TYPE_VOICEPRINT, // 声纹 + LOGINOPT_TYPE_FINGERVEIN, // 指静脉 + LOGINOPT_TYPE_GENERAL_UKEY, // 普通的ukey + LOGINOPT_TYPE_ADVANCED_UKEY, // 高阶的ukey + LOGINOPT_TYPE_QRCODE, // 二维码 + LOGINOPT_TYPE_OTHERS, // 其他 + LOGINOPT_TYPE_COUNT +}; + /* the type of device */ enum BioType { BIOTYPE_FINGERPRINT, @@ -173,6 +187,14 @@ struct StatusReslut int notifyMessageId; }; +struct FeatureInfo { + int uid; + int biotype; + QString device_shortname; + int index; + QString index_name; +}; + /* the info of device */ struct DeviceInfo { int device_id; @@ -207,6 +229,8 @@ typedef QMap DeviceMap; QDBusArgument &operator<<(QDBusArgument &argument, const DeviceInfo &deviceInfo); const QDBusArgument &operator>>(const QDBusArgument &argument, DeviceInfo &deviceInfo); QDebug operator <<(QDebug stream, const DeviceInfo &deviceInfo); +QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo); +const QDBusArgument &operator>>(const QDBusArgument &argument, FeatureInfo &featureInfo); QString bioTypeToString(int type); diff --git a/bioauth/include/loginoptionswidget.h b/bioauth/include/loginoptionswidget.h index 14d1fd0..31c69e2 100644 --- a/bioauth/include/loginoptionswidget.h +++ b/bioauth/include/loginoptionswidget.h @@ -30,17 +30,18 @@ class QVBoxLayout; class QToolButton; class QTimer; -enum LOGINOPT_TYPE { - LOGINOPT_TYPE_PASSWORD = 0, // 密码 - LOGINOPT_TYPE_FACE, // 人脸 - LOGINOPT_TYPE_FINGERPRINT, // 指纹 - LOGINOPT_TYPE_IRIS, // 虹膜 - LOGINOPT_TYPE_VOICEPRINT, // 声纹 - LOGINOPT_TYPE_FINGERVEIN, // 指静脉 - LOGINOPT_TYPE_QRCODE, // 二维码 - LOGINOPT_TYPE_OTHERS, // 其他 - LOGINOPT_TYPE_COUNT -}; +typedef enum { + BioT_FingerPrint, /** 指纹 **/ + BioT_FingerVein, /** 指静脉 **/ + BioT_Iris, /** 虹膜 **/ + BioT_Face, /** 人脸 **/ + BioT_VoicePrint, /** 声纹 **/ + + UniT_KCM, /** 安全管控 **/ + UniT_General_Ukey, /** 普通的Ukey **/ + UniT_Advanced_Ukey, /** 高阶的Ukey **/ + UniT_Remote, /** 远程账户 **/ +}Bio_Type; class LoginOptionsWidget : public QWidget { @@ -54,6 +55,7 @@ public: DeviceInfoPtr getFirstDevInfo(); int convertDeviceType(int nDevType); void updateUIStatus(bool update); + void updateUkeyUIStatus(int type); void setUser(int uid); void setCurrentDevice(int drvid); void setCurrentDevice(const QString &deviceName); @@ -69,6 +71,7 @@ public: * @return */ QString GetDefaultDevice(uid_t uid); + QString GetDefaultDevice(uid_t uid,int bioType); /** * @brief 进行生物识别认证 @@ -91,6 +94,9 @@ public: } QPixmap loadSvg(QString path, QString color, int size); + void SetExtraInfo(QString extra_info,QString info_type); + bool getHasUkeyOptions(); + void setSelectedPassword(); public slots: void readDevicesInfo(); void onIdentifyComplete(int uid, bool ret, int retErrNo); @@ -155,6 +161,8 @@ private: bool is_Lock = false; QPixmap m_waitingPixmap; QTimer *w_timer; + + bool isShowUkey = false; }; #endif // LOGINOPTIONSWIDGET_H diff --git a/bioauth/src/bioauth.cpp b/bioauth/src/bioauth.cpp index 318f3d3..df66f19 100644 --- a/bioauth/src/bioauth.cpp +++ b/bioauth/src/bioauth.cpp @@ -60,6 +60,30 @@ void BioAuth::setDevice(const DeviceInfoPtr deviceInfo) this->deviceInfo = deviceInfo; } +void BioAuth::startUkeyAuth() +{ + // stopAuth(); + if (!deviceInfo) { + qDebug()<<"DeviceInfo not valid!!"; + return; + } + + /* 开始认证识别 */ + LOG() << "start biometric verification"; + QList args; + args << QVariant(deviceInfo->device_id) << QVariant(2) + << QVariant(uid); + isInAuthentication = true; + + QDBusPendingCall call = serviceInterface->asyncCallWithArgumentList("UkeyIdentify", args); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, &BioAuth::onIdentityComplete); +} +DeviceInfoPtr BioAuth::getDevice() +{ + return this->deviceInfo; +} + void BioAuth::startAuth() { // stopAuth(); @@ -75,9 +99,58 @@ void BioAuth::startAuth() << QVariant(0) << QVariant(-1); isInAuthentication = true; - QDBusPendingCall call = serviceInterface->asyncCallWithArgumentList("Identify", args); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); - connect(watcher, &QDBusPendingCallWatcher::finished, this, &BioAuth::onIdentityComplete); + qDebug()<biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + QList args1; + args1 << QVariant(deviceInfo->device_id) << QVariant(2) + << QVariant(uid); + + QDBusPendingCall call = serviceInterface->asyncCallWithArgumentList("UkeyIdentify", args1); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, &BioAuth::onIdentityComplete); + }else{ + QDBusPendingCall call = serviceInterface->asyncCallWithArgumentList("Identify", args); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, &BioAuth::onIdentityComplete); + } +} + +bool BioAuth::GetHasUkeyFeature(int uid, int indexStart, int indexEnd) +{ + QList qlist; + FeatureInfo *featureInfo; + int listsize; + QDBusMessage result = serviceInterface->call(QStringLiteral("GetAllFeatureList"),uid,indexStart,indexEnd); + if(result.type() == QDBusMessage::ErrorMessage) + { + qWarning() << "GetDevList error:" << result.errorMessage(); + return false; + } + QList variantList = result.arguments(); + listsize = variantList[0].value(); + variantList[1].value() >> qlist; + for (int i = 0; i < listsize; i++) { + featureInfo = new FeatureInfo; + qlist[i].variant().value() >> *featureInfo; + if(featureInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + delete featureInfo; + return true; + } + delete featureInfo; + } + return false; +} + +int BioAuth::SetExtraInfo(QString info_type,QString extra_info) +{ + QDBusReply reply = serviceInterface->call(QStringLiteral("SetExtraInfo"), info_type, extra_info); + if(!reply.isValid()) + { + qWarning() << "SetExtraInfo error:" << reply.error(); + return -1; + } + return reply.value(); } void BioAuth::startAuth(qint32 uid, const DeviceInfoPtr deviceInfo) diff --git a/bioauth/src/biodevices.cpp b/bioauth/src/biodevices.cpp index 92fb32e..556ed1c 100644 --- a/bioauth/src/biodevices.cpp +++ b/bioauth/src/biodevices.cpp @@ -43,6 +43,7 @@ BioDevices::BioDevices(bool isIgnoreQrCode, QObject *parent) m_listPriority.push_back(BIOTYPE_VOICEPRINT); m_listPriority.push_back(BIOTYPE_FINGERVEIN); m_listPriority.push_back(REMOTE_QRCODE_TYPE); + m_listPriority.push_back(LOGINOPT_TYPE_GENERAL_UKEY); } void BioDevices::setUId(int nUId) @@ -70,6 +71,7 @@ void BioDevices::onUSBDeviceHotPlug(int deviceId, int action, int devNumNow) { qDebug() << deviceId << action << devNumNow; QString text = ""; + if(action == -1){ DeviceInfoPtr device = findDevice(deviceId); if(device) @@ -102,6 +104,7 @@ void BioDevices::onUSBDeviceHotPlug(int deviceId, int action, int devNumNow) <<(int)-1; iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args); } + } bool BioDevices::GetBioAuthEnable(uid_t uid) @@ -398,6 +401,72 @@ bool BioDevices::GetBioAuthEnable() } } +DeviceInfoPtr BioDevices::getDefaultDevice(uid_t uid,int bioType) +{ + if(deviceInfos.size() <= 0) + return nullptr; + + if (m_uniAuthService && m_uniAuthService->isActivatable()) { + QString defaultDeviceName = ""; + struct passwd *pwdInfo = getpwuid(uid); + DeviceInfoPtr ptrDevInfo = nullptr; + if (pwdInfo) { + QString strDeviceName = m_uniAuthService->getDefaultDevice(pwdInfo->pw_name, bioType); + qDebug()<device_id) > 0) { + defaultDeviceName = strDeviceName; + } + } + } + } + if(defaultDeviceName.isEmpty()){ + return nullptr; + } + return ptrDevInfo; + } else { + QString defaultDeviceName; + + struct passwd *pwd = getpwuid(uid); + QString userConfigFile = QString(pwd->pw_dir) + "/.biometric_auth/ukui_biometric.conf"; + QSettings userConfig(userConfigFile, QSettings::IniFormat); + qDebug() << userConfig.fileName(); + defaultDeviceName = userConfig.value(DEFAULT_DEVICE).toString(); + qDebug() << defaultDeviceName; + + if(defaultDeviceName.isEmpty() || !findDevice(defaultDeviceName)) { + QSettings sysConfig(GET_STR(CONFIG_FILE), QSettings::IniFormat); + defaultDeviceName = sysConfig.value(DEFAULT_DEVICE).toString(); + } + + if(defaultDeviceName.isEmpty() || !findDevice(defaultDeviceName)){ + QString userConfigFile = QString(pwd->pw_dir) + "/.biometric_auth/ukui_biometric.conf"; + QSettings userConfig(userConfigFile, QSettings::IniFormat); + defaultDeviceName = userConfig.value(DEFAULT_DEVICE).toString(); + } + qDebug() << "default device: " << defaultDeviceName; + // 终端不默认使用第一个设备 + if(defaultDeviceName.isEmpty()){ + return nullptr; + } + bool defValid = false; + DeviceInfoPtr ptrDevInfo = findDevice(defaultDeviceName); + if (ptrDevInfo) { + if (GetUserDevFeatureCount(uid,ptrDevInfo->device_id) > 0) { + defValid = true; + } + } + + if (!defValid) { + ptrDevInfo = nullptr; + } + + return ptrDevInfo; + } +} + DeviceInfoPtr BioDevices::getDefaultDevice(uid_t uid) { if(deviceInfos.size() <= 0) @@ -410,6 +479,7 @@ DeviceInfoPtr BioDevices::getDefaultDevice(uid_t uid) if (pwdInfo) { for (auto bioType : m_listPriority) { QString strDeviceName = m_uniAuthService->getDefaultDevice(pwdInfo->pw_name, bioType); + qDebug()<>(const QDBusArgument &argument, FeatureInfo &featureInfo) +{ + argument.beginStructure(); + argument >> featureInfo.uid >> featureInfo.biotype + >> featureInfo.device_shortname >> featureInfo.index + >> featureInfo.index_name; + argument.endStructure(); + return argument; +} + QString bioTypeToString(int type) { switch(type) { @@ -86,6 +107,8 @@ QString bioTypeToString(int type) return ("Iris"); case BIOTYPE_FACE: return ("Face"); + case LOGINOPT_TYPE_GENERAL_UKEY: + return ("ukey"); case BIOTYPE_VOICEPRINT: return ("VoicePrint"); } diff --git a/bioauth/src/loginoptionswidget.cpp b/bioauth/src/loginoptionswidget.cpp index a207c33..955270c 100644 --- a/bioauth/src/loginoptionswidget.cpp +++ b/bioauth/src/loginoptionswidget.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include + LoginOptionsWidget::LoginOptionsWidget(QWidget *parent) : QWidget(parent) , m_biomericProxy(new BioAuth(this)) @@ -72,19 +74,21 @@ void LoginOptionsWidget::initUI() m_layoutImage->setAlignment(Qt::AlignCenter); m_labelOptTitle = new QLabel(); - m_labelOptTitle->setAlignment(Qt::AlignCenter); + m_labelOptTitle->setAlignment(Qt::AlignLeft); m_labelOptTitle->setText(tr("Login Options")); m_layoutMain->addWidget(m_labelOptTitle); m_btnGroup = new QButtonGroup(this); m_btnGroup->setExclusive(true); - m_layoutOptBtns->setAlignment(Qt::AlignCenter); + m_layoutOptBtns->setAlignment(Qt::AlignLeft); m_layoutMain->addLayout(m_layoutOptBtns); m_widgetImage = new QWidget(); m_widgetImage->setFixedSize(154,154); + m_layoutImage->addSpacerItem(new QSpacerItem(109, 0, QSizePolicy::Expanding)); m_layoutImage->addWidget(m_widgetImage); + m_layoutImage->addSpacerItem(new QSpacerItem(109, 0, QSizePolicy::Expanding)); m_widgetImage->hide(); // 人脸识别 m_labelFace = new QLabel(m_widgetImage); @@ -100,6 +104,8 @@ void LoginOptionsWidget::initUI() m_labelFaceLoad->setFixedSize(142, 142); m_labelFaceLoad->setStyleSheet(QString("QLabel{background-color: rgba(230,230,230,0.39); border-radius: %1px; border: 8px solid white;}").arg(71)); layoutFace->addWidget(m_labelFaceLoad, 0, Qt::AlignVCenter); + + // QImage img; // setFaceImg(img); m_labelFace->hide(); @@ -127,6 +133,21 @@ void LoginOptionsWidget::initUI() layoutQRCode->addWidget(m_labelQRCodeMsg, 0, Qt::AlignHCenter); this->setLayout(m_layoutMain); + + //设置水平扩展 + QSizePolicy sizePolicy = this->sizePolicy(); + sizePolicy.setHorizontalPolicy(QSizePolicy::Expanding); + this->setSizePolicy(sizePolicy); +} + +void LoginOptionsWidget::SetExtraInfo(QString extra_info, QString info_type) +{ + if(!m_biomericProxy) + { + qWarning() << "BiometricProxy doesn't exist."; + return; + } + m_biomericProxy->SetExtraInfo(info_type,extra_info); } void LoginOptionsWidget::initConnections() @@ -167,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:"<setStyleSheet(QString("QToolButton{text-align:center;border: none;border-radius: 6px;outline: none;background-color: rgba(230, 230, 230, 100%);} \ // QToolButton::hover{background-color: rgba(55, 144, 250, 40%);} \ @@ -217,19 +247,22 @@ void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QSt newButton->setChecked(false); newButton->setFocusPolicy(Qt::NoFocus); newButton->setContentsMargins(16,16,16,16); - if (nDrvId == -1) { - newButton->setEnabled(false); - newButton->setChecked(true); - } else { +// if (nDrvId == -1) { +// newButton->setEnabled(false); +// newButton->setChecked(true); +// } else { int nLength = m_btnGroup->buttons().length(); m_btnGroup->addButton(newButton, nLength); m_listDriveId.append(nDrvId); - } +// } QIcon icon; switch (uLoginOptType) { case LOGINOPT_TYPE_PASSWORD: icon = QIcon(QString("%1/images/ukui-loginopt-password.svg").arg(GET_STR(UKUI_BIOMETRIC))); break; + case LOGINOPT_TYPE_GENERAL_UKEY: + icon = QIcon(QString("%1/images/ukui-loginopt-ukey.svg").arg(GET_STR(UKUI_BIOMETRIC))); + break; case LOGINOPT_TYPE_FACE: icon = QIcon(QString("%1/images/ukui-loginopt-face.svg").arg(GET_STR(UKUI_BIOMETRIC))); break; @@ -278,17 +311,43 @@ void LoginOptionsWidget::clearOptionButtons() void LoginOptionsWidget::updateOptionButtons() { + isShowUkey = false; clearOptionButtons(); - //addOptionButton(LOGINOPT_TYPE_PASSWORD, -1, tr("Password")); + addOptionButton(LOGINOPT_TYPE_PASSWORD, -1, tr("Password")); DeviceMap::iterator itMapDev = m_mapDevices.begin(); for ( ; itMapDev != m_mapDevices.end(); itMapDev++) { for (DeviceInfoPtr devPtr : itMapDev.value()) { if (devPtr) { - addOptionButton(itMapDev.key(), devPtr->device_id, BioDevices::bioTypeToString_tr(devPtr->biotype)); + if(devPtr->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + //ukey 设备类型排在二维码前,但实际上应该显示在二维码之后,因此暂时不添加 + isShowUkey = true; + continue; + } + addOptionButton(itMapDev.key(), devPtr->device_id, BioDevices::bioTypeToString_tr(devPtr->biotype)); + } + } + } + + itMapDev = m_mapDevices.begin(); + if(isShowUkey){ + for ( ; itMapDev != m_mapDevices.end(); itMapDev++) { + for (DeviceInfoPtr devPtr : itMapDev.value()) { + if(devPtr && devPtr->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + //此处才添加ukey + addOptionButton(itMapDev.key(), devPtr->device_id, BioDevices::bioTypeToString_tr(devPtr->biotype)); + } } } } - if (m_mapOptBtns.size() <= 1) { + + //存在特征但没有插入ukey + if( !isShowUkey && m_biomericProxy->GetHasUkeyFeature(m_uid)){ + addOptionButton(LOGINOPT_TYPE_GENERAL_UKEY,-2,BioDevices::bioTypeToString_tr(LOGINOPT_TYPE_GENERAL_UKEY)); + isShowUkey = true; + } + + if (m_mapOptBtns.size() <= 2 && !isShowUkey) { + //因为默认添加一个密码选项,因此当ukey没有显示出来时,按钮数小于等于2时就隐藏选项界面 m_labelOptTitle->hide(); QMap::iterator itMapBtn = m_mapOptBtns.begin(); for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) { @@ -309,6 +368,12 @@ void LoginOptionsWidget::updateOptionButtons() } } } + + m_mapOptBtns[-1]->hide(); + if(m_mapOptBtns.size() == 2 && isShowUkey) { + m_mapOptBtns[-1]->show(); + } + adjustSize(); } @@ -381,14 +446,30 @@ void LoginOptionsWidget::startAuth(DeviceInfoPtr device, int uid) qDebug()<<"deviceInfo:"<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_(); } +void LoginOptionsWidget::setSelectedPassword() +{ + if (m_mapOptBtns.contains(-1)) { + QToolButton* btn = m_mapOptBtns[-1]; + if (btn && btn->isVisible()) { + btn->setChecked(true); + } + m_curDevInfo = nullptr; + } +} + void LoginOptionsWidget::startAuth_() { if (!m_curDevInfo) @@ -551,9 +632,13 @@ QPixmap LoginOptionsWidget::scaledPixmap(int width, int height, QString url) void LoginOptionsWidget::onFrameWritten(int drvid) { - if (m_curDevInfo->device_id != drvid || !m_isInAuth) { + if(!m_curDevInfo) + return; + + if (m_curDevInfo && m_curDevInfo->device_id != drvid || !m_isInAuth) { return ; } + if(m_dupFD == -1){ m_dupFD = get_server_gvariant_stdout(drvid); } @@ -729,6 +814,18 @@ DeviceInfoPtr LoginOptionsWidget::findDeviceByName(const QString &name) return DeviceInfoPtr(); } +QString LoginOptionsWidget::GetDefaultDevice(uid_t uid,int bioType) +{ + QString defaultDeviceName = ""; + DeviceInfoPtr pDeviceInfo = m_bioDevices->getDefaultDevice(uid,bioType); + if (pDeviceInfo) { + defaultDeviceName = pDeviceInfo->device_shortname; + } + qDebug() << "default device: " << defaultDeviceName; + + return defaultDeviceName; +} + QString LoginOptionsWidget::GetDefaultDevice(uid_t uid) { QString defaultDeviceName = ""; @@ -753,7 +850,7 @@ void LoginOptionsWidget::onUSBDeviceCountChange(int newNum) int count = 0; for(int type : m_mapDevices.keys()) count += m_mapDevices.value(type).count(); - + //设备数量发生了变化 if(count != savedCount) { updateOptionButtons(); @@ -762,11 +859,36 @@ void LoginOptionsWidget::onUSBDeviceCountChange(int newNum) updateUIStatus(false); } +void LoginOptionsWidget::updateUkeyUIStatus(int type) +{ + if (type == LOGINOPT_TYPE_FACE) { + m_labelFace->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,10%);").arg(77)); + m_labelFace->show(); + m_labelQRCode->hide(); + m_widgetImage->show(); + } else if (type == LOGINOPT_TYPE_QRCODE) { + m_labelQRCode->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,100%);").arg(6)); + QImage img; + setQRCode(img); + m_labelQRCode->show(); + m_labelFace->hide(); + m_widgetImage->show(); + } else { + m_labelFace->hide(); + m_labelQRCode->hide(); + m_widgetImage->hide(); + } + + QTimer::singleShot(0,this,[&,this](){ + Q_EMIT this->updateWndSize(this->m_curLoginOptType, this->m_mapOptBtns.size()); + }); +} + void LoginOptionsWidget::updateUIStatus(bool update) { if (m_mapOptBtns.contains(-1)) { QToolButton* btn = m_mapOptBtns[-1]; - if (btn) { + if (btn && btn->isVisible()) { btn->setChecked(true); } } @@ -778,6 +900,7 @@ void LoginOptionsWidget::updateUIStatus(bool update) } } } + if (update) { if (m_curLoginOptType == LOGINOPT_TYPE_FACE) { m_labelFace->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,10%);").arg(77)); @@ -810,6 +933,19 @@ void LoginOptionsWidget::onOptionSelected(int nIndex) DeviceInfoPtr info = findDeviceById(m_listDriveId[nIndex]); if (info && !isDeviceDisable(info->device_id)) { Q_EMIT optionSelected(convertDeviceType(info->biotype), info); + this->m_curLoginOptType = convertDeviceType(info->biotype); + }else if(nIndex == 0 && m_listDriveId[nIndex] == -1){ + stopAuth(); + m_curDevInfo = nullptr; + Q_EMIT optionSelected(LOGINOPT_TYPE_PASSWORD,nullptr); + this->m_curLoginOptType = LOGINOPT_TYPE_PASSWORD; + + }else if(m_listDriveId[nIndex] == -2){ + //存在ukey特征,但未插入ukey + stopAuth(); + m_curDevInfo = nullptr; + Q_EMIT optionSelected(LOGINOPT_TYPE_GENERAL_UKEY,nullptr); + this->m_curLoginOptType = LOGINOPT_TYPE_GENERAL_UKEY; } } } @@ -833,6 +969,12 @@ int LoginOptionsWidget::convertDeviceType(int nDevType) case BIOTYPE_VOICEPRINT: nLoginOptType = LOGINOPT_TYPE_VOICEPRINT; break; + case UniT_General_Ukey: + nLoginOptType = LOGINOPT_TYPE_GENERAL_UKEY; + break; + case UniT_Advanced_Ukey: + nLoginOptType = LOGINOPT_TYPE_ADVANCED_UKEY; + break; case REMOTE_QRCODE_TYPE: nLoginOptType = LOGINOPT_TYPE_QRCODE; break; diff --git a/debian/changelog b/debian/changelog index 5c3b3bf..1703ffa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,44 @@ -ukui-biometric-auth (3.22.0.0-ok3~1101) unstable; urgency=medium +ukui-biometric-auth (4.0.0.0-ok1~0426) yangtze; urgency=medium + + * BUG号:无 + * 需求号:无 + * 其他修改说明:合并V101、V101-tablet代码 + + -- Yang Min Wed, 26 Apr 2023 21:58:51 +0800 + +ukui-biometric-auth (3.22.0.0-ok7~0420) yangtze; urgency=medium + + * BUG号:无 + * 需求号:无 + * 其他修改说明:修复glib2.0头文件引用不规范导致的编译问题 + + -- Yang Min Thu, 20 Apr 2023 16:16:16 +0800 + +ukui-biometric-auth (3.22.0.0-ok6~0420) yangtze; urgency=medium + + * BUG号:无 + * 需求号:无 + * 其他修改说明:解决libpam-biometric与libkysdk-log库同时加载时程序崩溃问题 + + -- Yang Min Thu, 20 Apr 2023 11:09:41 +0800 + +ukui-biometric-auth (3.22.0.0-ok5~0417) yangtze; urgency=medium + + * BUG号:167371 【提权】A用户添加生物识别特征,B用户登录使用A用户进行提权时没有生物识别选项 + * 需求号:无 + * 其他修改说明:无 + + -- Yang Min Mon, 17 Apr 2023 14:09:28 +0800 + +ukui-biometric-auth (3.22.0.0-ok4~0413) yangtze; urgency=medium + + * BUG号:I643GT 【提权】授权窗口无图标 + * 需求号:无 + * 其他修改说明:无 + + -- Yang Min Thu, 13 Apr 2023 17:59:37 +0800 + +ukui-biometric-auth (3.22.0.0-ok3~1101) yangtze; urgency=medium * 其他修改说明:修复编包问题,重新编包 diff --git a/debian/control b/debian/control index 81c44d4..ef1f89e 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: Kylin Team Uploaders: handsome_feng Build-Depends: cmake (>= 2.6), - debhelper-compat (= 13), + debhelper-compat (= 12), libglib2.0-dev, libgsettings-qt-dev, libopencv-dev, @@ -15,7 +15,9 @@ Build-Depends: cmake (>= 2.6), qtbase5-dev, qttools5-dev, qttools5-dev-tools, -Standards-Version: 4.6.1.0 + libkysdk-sysinfo-dev, + libukui-log4qt-dev +Standards-Version: 4.5.0 Rules-Requires-Root: no Homepage: https://github.com/ukui/ukui-biometric-auth Vcs-Git: https://github.com/ukui/ukui-biometric.git @@ -34,7 +36,7 @@ Description: Insertable authentication module for PAM Package: ukui-polkit Architecture: any -Depends: polkitd, ${misc:Depends}, ${shlibs:Depends} +Depends: policykit-1, ${misc:Depends}, ${shlibs:Depends} Suggests: biometric-auth Provides: polkit-1-auth-agent Description: UKUI authentication agent for PolicyKit-1 diff --git a/debian/copyright b/debian/copyright index 67b122d..c833905 100644 --- a/debian/copyright +++ b/debian/copyright @@ -4,101 +4,6 @@ Upstream-Contact: yanghao@kylinos.cn Source: https://github.com/ukui/ukui-biometric-auth Files: * -Copyright: 2018, 2022, 2023, Tianjin KYLIN Information Technology Co., Ltd. -License: GPL-3+ - This package is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Genaral Public License for more details. - . - You should have received a copy og the GNU General Public License - along with this program. If not, see - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". - -Files: debian/* -Copyright: 2022, yanghao -License: GPL-3+ - This package is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Genaral Public License for more details. - . - You should have received a copy og the GNU General Public License - along with this program. If not, see - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". - -Files: man/* -Copyright: 2018, yanghao -License: GPL-3+ - This package is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Genaral Public License for more details. - . - You should have received a copy og the GNU General Public License - along with this program. If not, see - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". - -Files: pam-biometric/data/* -Copyright: 2018, yanghao -License: GPL-3+ - This package is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Genaral Public License for more details. - . - You should have received a copy og the GNU General Public License - along with this program. If not, see - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". - -Files: pam-biometric/utils/* -Copyright: 2018, yanghao -License: GPL-3+ - This package is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Genaral Public License for more details. - . - You should have received a copy og the GNU General Public License - along with this program. If not, see - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". - -Files: polkit-agent/data/* Copyright: 2018, yanghao License: GPL-3+ This package is free software; you can redistribute it and/or modify diff --git a/debian/libpam-biometric.install b/debian/libpam-biometric.install index d67b8b3..6ce65fb 100644 --- a/debian/libpam-biometric.install +++ b/debian/libpam-biometric.install @@ -1,6 +1,6 @@ /usr/share/ukui-biometric/ukui-biometric.conf /usr/share/dbus-1/system-services/org.ukui.UniauthBackend.service -/usr/share/dbus-1/system.d/org.ukui.UniauthBackend.conf +/etc/dbus-1/system.d/org.ukui.UniauthBackend.conf /lib/security/* /usr/bin/* /usr/share/pam-configs/* diff --git a/debian/libpam-biometric.manpages b/debian/libpam-biometric.manpages index 0eaf7d0..ce85cd2 100644 --- a/debian/libpam-biometric.manpages +++ b/debian/libpam-biometric.manpages @@ -1,6 +1,3 @@ man/bioauth.1 man/bioctl.1 man/biodrvctl.1 -man/bioctl-helper.1 -man/biorestart.1 -man/uniauth-backend.1 diff --git a/debian/libpam-biometric.postinst b/debian/libpam-biometric.postinst index 1add37b..46f1a0d 100644 --- a/debian/libpam-biometric.postinst +++ b/debian/libpam-biometric.postinst @@ -39,7 +39,7 @@ set_opt(){ sed -i "s/\[${section}\]/\[${section}\]\n${key}\=${val}/g" ${file} fi else - sed -i "\n[${section}]\n${key}=${val}" ${file} + echo -e "\n[${section}]\n${key}=${val}" >> ${file} sed -i "s/\-e//g" ${file} fi } diff --git a/debian/source/format b/debian/source/format index 163aaf8..89ae9db 100644 --- a/debian/source/format +++ b/debian/source/format @@ -1 +1 @@ -3.0 (quilt) +3.0 (native) diff --git a/debian/ukui-polkit.install b/debian/ukui-polkit.install index 0f930a8..e6f5054 100644 --- a/debian/ukui-polkit.install +++ b/debian/ukui-polkit.install @@ -1,3 +1,4 @@ /etc/xdg/* +/usr/share/applications/* /usr/lib/* /usr/share/ukui-biometric/i18n_qm/polkit/*.qm diff --git a/images/huawei/.DS_Store b/images/huawei/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0ed9a3d4040b26b46119e99fb633973bac04e956 GIT binary patch literal 6148 zcmeHK!Ab)$5PegNR6JOrpm^Gwo&?WcmQsaY6}(nk>slyXX{+FEFMf>Q=LhJUNvQ3% z1qBh28JN6HcHU(2QZ@|$X+GYb0CfO0x?*LE%?i`^>PuFMBb!9A9DVd~j}dYVm!f^( zFDjsWw~HnQ+_Nd>_b*3=XB=aKCuHqm-s=wYE~EKVsZ5B6?`F2BI$F$-(WkiK-gn69 zvo~7J$0=DybNmL*$?K8R!Pu(M*+-U7D_fW6wUlQEcQ$Lr9AiAtwT9{HDrB$3ZlG<9 z39GpHdKL0g%5#7#);zHFeAe)-mC0KvC%bO0fGgk%{Fnkfv(;+b0ljqvTme^LrhtAQ z61rj1rBR1e{U$U`H`y^(fw_n{hnR2Vxqr2*?qd{}C`5ym1A7Re=waWOfb! literal 0 HcmV?d00001 diff --git a/images/ukui-loginopt-face.svg b/images/ukui-loginopt-face.svg index 6eacd5e..9da90ad 100644 --- a/images/ukui-loginopt-face.svg +++ b/images/ukui-loginopt-face.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/images/ukui-loginopt-password.svg b/images/ukui-loginopt-password.svg index d626f56..91273cf 100644 --- a/images/ukui-loginopt-password.svg +++ b/images/ukui-loginopt-password.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/images/ukui-loginopt-ukey.svg b/images/ukui-loginopt-ukey.svg new file mode 100644 index 0000000..0239a86 --- /dev/null +++ b/images/ukui-loginopt-ukey.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/pam-biometric/CMakeLists.txt b/pam-biometric/CMakeLists.txt index 2c82306..7711237 100644 --- a/pam-biometric/CMakeLists.txt +++ b/pam-biometric/CMakeLists.txt @@ -29,11 +29,12 @@ set(pam_SRCS include_directories( ../common ${PAM_INCLUDE_DIR} + ${GLIB2_INCLUDE_DIRS} ) add_library(pam_biometric SHARED ${pam_SRCS}) -target_link_libraries(pam_biometric ${PAM_LIB}) +target_link_libraries(pam_biometric ${PAM_LIB} ${GLIB2_LIBRARIES}) #去除lib前缀 set_target_properties(pam_biometric PROPERTIES PREFIX "") diff --git a/pam-biometric/logger.c b/pam-biometric/logger.c index 78abd2a..47f70ce 100644 --- a/pam-biometric/logger.c +++ b/pam-biometric/logger.c @@ -24,12 +24,12 @@ #include #include -int enable_debug; -char *log_prefix; +int pam_enable_debug; +char *pam_log_prefix; -void logger(char *format, ...) +void pam_logger(char *format, ...) { - if(!enable_debug){ + if(!pam_enable_debug){ return; } @@ -39,7 +39,7 @@ void logger(char *format, ...) char timestr[32] = {0}; strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", localtime(&t)); //产生"YYYYMMDD hh:mm:ss"格式的字符串。 - fprintf(stderr, "[%s] %s - ", log_prefix, timestr); + fprintf(stderr, "[%s] %s - ", pam_log_prefix, timestr); va_start(args, format); /* 初始化 args */ vfprintf(stderr, format, args); } diff --git a/pam-biometric/pam_biometric.c b/pam-biometric/pam_biometric.c index 066d2ff..68f6aab 100644 --- a/pam-biometric/pam_biometric.c +++ b/pam-biometric/pam_biometric.c @@ -31,13 +31,15 @@ #include #include #include +#include +#include #define USER_CONFIG_FILE "/home/%s/.biometric_auth/ukui_biometric.conf" /* Declare log function */ -extern int enable_debug; -extern char *log_prefix; -extern int logger(char *format, ...); +extern int pam_enable_debug; +extern char *pam_log_prefix; +extern int pam_logger(char *format, ...); static int ukui_biometric_lock = 0; int enable_biometric_authentication(pam_handle_t *pamh); @@ -50,7 +52,7 @@ static void signal_handler(int signo) { if (signo == SIGUSR1) child_alive = 0; /* GUI child process has terminated */ - logger("signal_handler is triggered\n"); + pam_logger("signal_handler is triggered\n"); } int enable_biometric_authentication_app() @@ -62,14 +64,14 @@ int enable_biometric_authentication_app() int is_enable = 0; if((file = fopen(conf_file, "r")) == NULL){ - logger("open configure file failed: %s\n", strerror(errno)); + pam_logger("open configure file failed: %s\n", strerror(errno)); return 1; } while(fgets(line, sizeof(line), file)) { i = sscanf(line, "EnableAuthApp=%d\n", &is_enable); if(i > 0) { - logger("EnableAuthApp=%d\n", is_enable); + pam_logger("EnableAuthApp=%d\n", is_enable); break; } } @@ -86,11 +88,9 @@ int service_filter(char *service) //syslog(LOG_INFO,"is_enable = %d service = %s\n",is_enable,service); if (strcmp(service, "lightdm") == 0) { - int ret = system("/bin/chmod -f a+wr /tmp/bio.log"); - (void)ret; /* Suppress gcc ignoring return value warning */ //if(is_enable & 1 == 0) - // return 0; - return 1; + // return 0; + return 1; } if (strcmp(service, "ukui-screensaver-qt") == 0){ //if((is_enable & (1<<1)) == 0) @@ -145,9 +145,9 @@ int call_conversation(pam_handle_t *pamh, int msg_style, char *msg, char *resp) message_tmp->msg_style = msg_style; message_tmp->msg = msg; message[0] = message_tmp; - logger("Call conv callback function\n"); + pam_logger("Call conv callback function\n"); status = conv_struct->conv(1, message, &response, conv_struct->appdata_ptr); - logger("Finish conv callback function\n"); + pam_logger("Finish conv callback function\n"); if (resp && response->resp) strcpy(resp, response->resp); @@ -163,16 +163,15 @@ int call_conversation(pam_handle_t *pamh, int msg_style, char *msg, char *resp) /* GUI child process */ void child(char *service, char *username, char *xdisp) { - char *gui = "/usr/bin/bioauth"; - logger("Child process will be replaced.\n"); + pam_logger("Child process will be replaced.\n"); int fd = open("/dev/null", O_WRONLY); dup2(fd, 2); - execl(gui, "bioauth", + execl("/usr/bin/bioauth", "bioauth", "--service", service, "--user", username, // "--display", xdisp, - enable_debug ? "--debug" : "", + pam_enable_debug ? "--debug" : "", (char *)0); /* * execl almost always succeed as long as the GUI executable file exists. @@ -180,11 +179,11 @@ void child(char *service, char *username, char *xdisp) * process won't reach here. Therefore, the following code won't be * executed in general. */ - logger("Fatal error: execl(gui) failed in child process. " + pam_logger("Fatal error: execl(gui) failed in child process. " "This is an extremely rare condition. Please ensure that the " "biometric-authentication executable file exists.\n"); - logger("Use password as a fallback\n"); - logger("Child _exit with BIO_IGNORE\n"); + pam_logger("Use password as a fallback\n"); + pam_logger("Child _exit with BIO_IGNORE\n"); /* Child process exits */ _exit(BIO_IGNORE); } @@ -196,7 +195,7 @@ void handler() /* PAM parent process */ int parent(int pid, pam_handle_t *pamh, int need_call_conv) { - logger("Parent process continue running.\n"); + pam_logger("Parent process continue running.\n"); int child_status = -1; /* * 1. If calling conversation function is not needed, wait the child @@ -224,7 +223,7 @@ int parent(int pid, pam_handle_t *pamh, int need_call_conv) #endif if (signal(SIGUSR1, signal_handler) == SIG_ERR) - logger("Fatal Error. Can't catch SIGUSR1\n"); + pam_logger("Fatal Error. Can't catch SIGUSR1\n"); reinvoke: call_conversation(pamh, PAM_TEXT_INFO, msg1, NULL); call_conversation(pamh, PAM_PROMPT_ECHO_OFF, msg2, NULL); @@ -234,7 +233,7 @@ int parent(int pid, pam_handle_t *pamh, int need_call_conv) signal(SIGUSR1, SIG_DFL); waitpid(pid, &child_status, 0); } else { - logger("Waiting for the GUI child process to exit...\n"); + pam_logger("Waiting for the GUI child process to exit...\n"); //由于sudo命令在进入pam认证时,会阻塞来自终端的SIGINT以及SIGQUIT信号,导致使用 //pam认证时,按下Ctrl+C无反应,认证完成后,sudo会退出,这里为了简单,取消了阻塞 //信号,捕获信号但不做处理,在认证完成后,恢复原本阻塞状态 @@ -245,7 +244,7 @@ int parent(int pid, pam_handle_t *pamh, int need_call_conv) signal(SIGINT,handler); waitpid(pid, &child_status, 0); - logger("GUI child process has exited.\n"); + pam_logger("GUI child process has exited.\n"); sigprocmask(SIG_SETMASK,&mask,NULL); } @@ -257,23 +256,23 @@ int parent(int pid, pam_handle_t *pamh, int need_call_conv) if (WIFEXITED(child_status)) bio_result = WEXITSTATUS(child_status); else /* This may be because the GUI child process is invoked under console. */ - logger("The GUI-Child process terminate abnormally.\n"); + pam_logger("The GUI-Child process terminate abnormally.\n"); if (bio_result == BIO_SUCCESS) { if(!enable_biometric_authentication(pamh) && !enable_qrcode_authentication(pamh)) { - logger("disable biometric authentication.\n"); + pam_logger("disable biometric authentication.\n"); return PAM_SYSTEM_ERR; } - logger("pam_biometric.so return PAM_SUCCESS\n"); + pam_logger("pam_biometric.so return PAM_SUCCESS\n"); return PAM_SUCCESS; } else if (bio_result == BIO_IGNORE) { /* Override msg1 to empty the label. We are ready to enter the password module. */ call_conversation(pamh, PAM_TEXT_INFO, "", NULL); ukui_biometric_lock = 1; - logger("pam_biometric.so return PAM_IGNORE\n"); + pam_logger("pam_biometric.so return PAM_IGNORE\n"); return PAM_IGNORE; } else { - logger("pam_biometric.so return PAM_SYSTEM_ERR\n"); + pam_logger("pam_biometric.so return PAM_SYSTEM_ERR\n"); ukui_biometric_lock = 1; return PAM_SYSTEM_ERR; } @@ -296,10 +295,10 @@ void check_and_set_env(pam_handle_t *pamh, char **xdisp, char **xauth) *xdisp=getenv("DISPLAY"); *xauth=getenv("XAUTHORITY"); if (*xdisp == 0) - logger("Warning: DISPLAY env is still empty, " + pam_logger("Warning: DISPLAY env is still empty, " "this is not an error if you are using terminal\n"); if (*xauth == 0) - logger("Warning: XAUTHORITY env is still empty, " + pam_logger("Warning: XAUTHORITY env is still empty, " "this is not an error if you are using terminal\n"); } @@ -318,49 +317,49 @@ int biometric_auth_independent(pam_handle_t *pamh , char *service, int need_call /* Detach child process */ unsigned int pid; pid = fork(); - if (pid == 0 ) { - child(service, username, xdisp); - logger("Should never reach here.\n"); - return PAM_SYSTEM_ERR; - } else if (pid > 0) { - return parent(pid, pamh, need_call_conv); + if (pid < 0) { + pam_logger("Fork Error!\n"); + return PAM_SYSTEM_ERR; + } else if (pid != 0) { + return parent(pid, pamh, need_call_conv); } else { - logger("Fork Error!\n"); - return PAM_SYSTEM_ERR; + child(service, username, xdisp); + pam_logger("Should never reach here.\n"); + return PAM_SYSTEM_ERR; } } /* Biometric processing function fot polkit-1 */ int biometric_auth_polkit() { - logger("Current service is polkit-1\n"); + pam_logger("Current service is polkit-1\n"); const char *fifo_name = "/tmp/bio.fifo"; if(access(fifo_name, F_OK) == -1) { int res = mkfifo(fifo_name, 0777); if(res != 0) { - logger("Can't create FIFO file\n"); + pam_logger("Can't create FIFO file\n"); return PAM_SYSTEM_ERR; } } int fifo_rd = open(fifo_name, O_RDONLY); if (fifo_rd == -1) return PAM_SYSTEM_ERR; - logger("Before reading FIFO\n"); + pam_logger("Before reading FIFO\n"); char buffer[8] = {0}; if(read(fifo_rd, buffer, 8) == -1) return PAM_SYSTEM_ERR; - logger("After reading FIFO\n"); + pam_logger("After reading FIFO\n"); int result_code; sscanf(buffer, "%d", &result_code); remove(fifo_name); if (result_code == BIO_SUCCESS) { - logger("pam_biometric.so return PAM_SUCCESS\n"); + pam_logger("pam_biometric.so return PAM_SUCCESS\n"); return PAM_SUCCESS; } else if (result_code == BIO_IGNORE) { - logger("pam_biometric.so return PAM_IGNORE\n"); + pam_logger("pam_biometric.so return PAM_IGNORE\n"); return PAM_IGNORE; } else { - logger("pam_biometric.so return PAM_SYSTEM_ERR\n"); + pam_logger("pam_biometric.so return PAM_SYSTEM_ERR\n"); return PAM_SYSTEM_ERR; } } @@ -385,7 +384,7 @@ int biometric_auth_embeded(pam_handle_t *pamh) return PAM_IGNORE; else if (strcmp(resp, BIOMETRIC_SUCCESS) == 0){ if(!enable_biometric_authentication(pamh) && !enable_qrcode_authentication(pamh)) { - logger("disable biometric authentication.\n"); + pam_logger("disable biometric authentication.\n"); return PAM_SYSTEM_ERR; } return PAM_SUCCESS; @@ -398,24 +397,82 @@ int biometric_auth_embeded(pam_handle_t *pamh) void get_greeter_session(char buf[], int len) { - FILE *stream; - char cmd[] = "ps -aux | grep greeter-session | grep -v grep | awk '{print $13}' | awk -F '/' '{print $4}'"; - memset(buf, 0, len); - stream = popen(cmd, "r"); - if(fgets(buf, len, stream) == NULL) - logger("get greeter session error: %d\n", errno); - buf[strlen(buf)-1] = '\0'; - if(strlen(buf) == 0) { - char cmd1[] = "ps aux | grep ukui-greeter | grep -v grep | wc -l"; - pclose(stream); - stream = popen(cmd1, "r"); - if(fgets(buf, len, stream) == NULL) - logger("get greeter session error: %d\n", errno); - int i = atoi(buf); - if(i > 0) - strcpy(buf, "ukui-greeter"); + GPtrArray *args_ps = NULL; + gchar *stdout_ps = NULL; + gchar *greeter_name = NULL; + + args_ps = g_ptr_array_new (); + g_ptr_array_add(args_ps, (gpointer)"/usr/bin/ps"); + g_ptr_array_add(args_ps, (gpointer)"-aux"); + g_ptr_array_add(args_ps, (gpointer)"--columns"); + g_ptr_array_add(args_ps, (gpointer)"256"); + g_ptr_array_add(args_ps, NULL); + + if (!g_spawn_sync(NULL, (char**)args_ps->pdata, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &stdout_ps, NULL, NULL, NULL)) { + if (stdout_ps) + g_free(stdout_ps); + g_ptr_array_free (args_ps, TRUE); + return ; + } + if (stdout_ps) { + gchar **lines = NULL; + lines = g_strsplit(stdout_ps, "\n", 0); + for (int n = 0; lines[n] != NULL; n++) { + if (lines[n][0] == '\0') + continue; + gchar *res = g_strstr_len(lines[n], 1024, "greeter-session"); + if (res) { + gchar **greeter_args = g_strsplit(res, " ", 0); + int arg_index = 0; + for (int m = 0; greeter_args[m] != NULL; m++) { + if (greeter_args[m][0] == '\0') + continue; + // greeter-session arg1 + if (arg_index == 1) { + gchar *greeter = g_strrstr_len(greeter_args[m], 256, "/"); + if (greeter && strlen(greeter) > 1) { + greeter_name = g_strdup(greeter + 1); + break; + } + } + arg_index ++; + } + g_strfreev(greeter_args); + if (greeter_name) { + break; + } + } + } + g_strfreev(lines); + g_free(stdout_ps); + } + g_ptr_array_free (args_ps, TRUE); + if (greeter_name) { + g_strlcpy(buf, greeter_name, len); + g_free(greeter_name); + } else { + GPtrArray *args_pidof = NULL; + gchar *stdout_pidof = NULL; + + args_pidof = g_ptr_array_new (); + g_ptr_array_add(args_pidof, (gpointer)"/usr/bin/pidof"); + g_ptr_array_add(args_pidof, (gpointer)"ukui-greeter"); + g_ptr_array_add(args_pidof, NULL); + + if (!g_spawn_sync(NULL, (char**)args_pidof->pdata, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &stdout_pidof, NULL, NULL, NULL)) { + if (stdout_pidof) + g_free(stdout_pidof); + g_ptr_array_free (args_pidof, TRUE); + return ; + } + if (stdout_pidof) { + if (strlen(stdout_pidof) > 0 && atoi(stdout_pidof) > 0) { + g_strlcpy(buf, "ukui-greeter", len); + } + g_free(stdout_pidof); + } + g_ptr_array_free (args_pidof, TRUE); } - pclose(stream); } int enable_by_polkit() @@ -424,15 +481,15 @@ int enable_by_polkit() char buf[1024]; if( (file = fopen(BIO_COM_FILE, "r")) == NULL) { - logger("open communication file failed: %s\n", strerror(errno)); + pam_logger("open communication file failed: %s\n", strerror(errno)); return 0; } memset(buf, 0, sizeof(buf)); fgets(buf, sizeof(buf), file); fclose(file); if(remove(BIO_COM_FILE) < 0) - logger("remove communication file failed: %s\n", strerror(errno)); - logger("%s\n", buf); + pam_logger("remove communication file failed: %s\n", strerror(errno)); + pam_logger("%s\n", buf); if(strcmp(buf, "polkit-ukui-authentication-agent-1") == 0) return 1; return 0; @@ -451,12 +508,12 @@ int enable_biometric_authentication(pam_handle_t *pamh) char line[1024], is_enable[16]; int i; if((file = fopen(conf_file_user, "r")) == NULL){ - logger("open configure file failed: %s\n", strerror(errno)); + pam_logger("open configure file failed: %s\n", strerror(errno)); } else { while(fgets(line, sizeof(line), file)) { i = sscanf(line, "EnableAuth=%15s\n", is_enable); if(i > 0) { - logger("EnableAuth=%s\n", is_enable); + pam_logger("EnableAuth=%s\n", is_enable); is_found = 1; break; } @@ -476,13 +533,13 @@ int enable_biometric_authentication(pam_handle_t *pamh) int i; if((file = fopen(conf_file, "r")) == NULL){ - logger("open configure file failed: %s\n", strerror(errno)); + pam_logger("open configure file failed: %s\n", strerror(errno)); return 0; } while(fgets(line, sizeof(line), file)) { i = sscanf(line, "EnableAuth=%15s\n", is_enable); if(i > 0) { - logger("EnableAuth=%s\n", is_enable); + pam_logger("EnableAuth=%s\n", is_enable); break; } } @@ -506,12 +563,12 @@ int enable_qrcode_authentication(pam_handle_t *pamh) char line[1024], is_enable[16]; int i; if((file = fopen(conf_file_user, "r")) == NULL){ - logger("open configure file failed: %s\n", strerror(errno)); + pam_logger("open configure file failed: %s\n", strerror(errno)); } else { while(fgets(line, sizeof(line), file)) { i = sscanf(line, "EnableQRCode=%15s\n", is_enable); if(i > 0) { - logger("EnableQRCode=%s\n", is_enable); + pam_logger("EnableQRCode=%s\n", is_enable); is_found = 1; break; } @@ -531,13 +588,13 @@ int enable_qrcode_authentication(pam_handle_t *pamh) int i; if((file = fopen(conf_file, "r")) == NULL){ - logger("open configure file failed: %s\n", strerror(errno)); + pam_logger("open configure file failed: %s\n", strerror(errno)); return 0; } while(fgets(line, sizeof(line), file)) { i = sscanf(line, "EnableQRCode=%15s\n", is_enable); if(i > 0) { - logger("EnableQRCode=%s\n", is_enable); + pam_logger("EnableQRCode=%s\n", is_enable); break; } } @@ -557,13 +614,13 @@ int enable_biometric_auth_double() if((file = fopen(conf_file, "r")) == NULL){ - logger("open configure file failed: %s\n", strerror(errno)); + pam_logger("open configure file failed: %s\n", strerror(errno)); return 0; } while(fgets(line, sizeof(line), file)) { i = sscanf(line, "DoubleAuth=%s\n", is_enable); if(i > 0) { - logger("DoubleAuth=%s\n", is_enable); + pam_logger("DoubleAuth=%s\n", is_enable); break; } } @@ -582,26 +639,26 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, { for(int i = 0; i < argc; i++) { if(strcmp(argv[i], "debug") == 0) { - enable_debug = 1; - log_prefix = "PAM_BIO"; + pam_enable_debug = 1; + pam_log_prefix = "PAM_BIO"; } } - logger("Invoke libpam_biometric.so module\n"); + pam_logger("Invoke libpam_biometric.so module\n"); char *service = 0; if((!enable_biometric_authentication(pamh) && !enable_qrcode_authentication(pamh)) || ukui_biometric_lock) { - logger("disable biometric authentication.\n"); + pam_logger("disable biometric authentication.\n"); return PAM_IGNORE; } - logger("enable biometric authentication.\n"); + pam_logger("enable biometric authentication.\n"); pam_get_item(pamh, PAM_SERVICE, (const void **)&service); /* Service filter */ if (!service_filter(service)){ - logger("Service <%s> should not use biometric-authentication\n", service); + pam_logger("Service <%s> should not use biometric-authentication\n", service); return PAM_IGNORE; } @@ -609,7 +666,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, if (strcmp(service, "lightdm") == 0) { char buf[128]; get_greeter_session(buf, sizeof(buf)); - logger("current greeter: %s\n", buf); + pam_logger("current greeter: %s\n", buf); if(strcmp(buf, "ukui-greeter") == 0 || strcmp(buf, "ukui-greeter-wayland") == 0) return biometric_auth_embeded(pamh); @@ -622,7 +679,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, if(enable_by_polkit()) return biometric_auth_embeded(pamh); else - logger("[PAM_BIOMETRIC]: It's not polkit-ukui-authentication-agent-1.\n"); + pam_logger("[PAM_BIOMETRIC]: It's not polkit-ukui-authentication-agent-1.\n"); } else if (strcmp(service, "sudo") == 0) return biometric_auth_independent(pamh, "sudo", 0); @@ -637,7 +694,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, return biometric_auth_independent(pamh, "biotest", 1); #endif else - logger("Service <%s> slip through the service filter\n", service); + pam_logger("Service <%s> slip through the service filter\n", service); return PAM_IGNORE; } diff --git a/polkit-agent/CMakeLists.txt b/polkit-agent/CMakeLists.txt index 75bafe4..fa7768e 100644 --- a/polkit-agent/CMakeLists.txt +++ b/polkit-agent/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.6) project(ukui-polkit-agent) pkg_check_modules(QGS REQUIRED gsettings-qt) +pkg_check_modules(KDKINFO REQUIRED kysdk-sysinfo) find_package(PolkitQt5-1 REQUIRED 0.103.0) find_package(Qt5 COMPONENTS Core Widgets DBus X11Extras Xml Network Svg) @@ -39,6 +40,10 @@ include_directories( qt5_add_resources(polkit_SRCS assets.qrc) +qt5_wrap_ui(polkit_SRCS + src/mainwindow.ui + ) + set(polkit_SRCS ${polkit_SRCS} src/PolkitAgent.cpp @@ -58,6 +63,7 @@ target_link_libraries(polkit-ukui-authentication-agent-1 ${POLKITQT-1_LIBRARIES} BioAuthWidgets -lrt + -lukui-log4qt ) install(TARGETS polkit-ukui-authentication-agent-1 DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-polkit) @@ -71,3 +77,5 @@ add_dependencies(polkit-ukui-authentication-agent-1 polkit_i18n) install(FILES ${qm_files} DESTINATION ${UKUI_BIOMETRIC_DIR}/i18n_qm/polkit) install(FILES ${PROJECT_BINARY_DIR}/data/polkit-ukui-authentication-agent-1.desktop DESTINATION /etc/xdg/autostart) +install(FILES ${PROJECT_BINARY_DIR}/data/polkit-ukui-authentication-agent-1.desktop + DESTINATION /usr/share/applications) diff --git a/polkit-agent/data/polkit-ukui-authentication-agent-1.desktop.in b/polkit-agent/data/polkit-ukui-authentication-agent-1.desktop.in index c48db74..9c6af37 100644 --- a/polkit-agent/data/polkit-ukui-authentication-agent-1.desktop.in +++ b/polkit-agent/data/polkit-ukui-authentication-agent-1.desktop.in @@ -87,3 +87,4 @@ X-DBUS-StartupType=Unique X-MATE-Autostart-Phase=Initialization X-MATE-StartupNotify=false X-MATE-AutoRestart=true +X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,org_kde_kwin_keystate diff --git a/polkit-agent/i18n_ts/bo_CN.ts b/polkit-agent/i18n_ts/bo_CN.ts index 59dbbc7..75bd971 100644 --- a/polkit-agent/i18n_ts/bo_CN.ts +++ b/polkit-agent/i18n_ts/bo_CN.ts @@ -304,7 +304,17 @@ ནང་འཇུག་གི་གསང་གྲངས། - + + Insert the ukey into the USB port + བདེ་འཇགས་ཀྱི་གསང་བའི་ལྡེ་མིག་དེ་USBཡི་སྣེ་འདྲེན་དུ་འཇུག་རོགས། + + + + Enter the ukey password + གསང་བའི་ཨང་གྲངས་ནང་འཇུག་བྱེད་པ། + + + hours left དུས་ཚོད་འགའ་ལས་ལྷག་མེད diff --git a/polkit-agent/i18n_ts/zh_CN.ts b/polkit-agent/i18n_ts/zh_CN.ts index 7f79e26..34b82ac 100644 --- a/polkit-agent/i18n_ts/zh_CN.ts +++ b/polkit-agent/i18n_ts/zh_CN.ts @@ -88,7 +88,7 @@ Password - 密码 + 密码 @@ -304,7 +304,17 @@ 输入密码 - + + Insert the ukey into the USB port + 请将安全密钥插入USB端口 + + + + Enter the ukey password + 输入安全密钥密码 + + + hours left 小时后解锁 diff --git a/polkit-agent/src/PolkitAgent.cpp b/polkit-agent/src/PolkitAgent.cpp index ef68e02..aa9d5c7 100644 --- a/polkit-agent/src/PolkitAgent.cpp +++ b/polkit-agent/src/PolkitAgent.cpp @@ -24,19 +24,19 @@ #include "generic.h" #include "sessionmanager.h" #include "biodevices.h" +#include bool enableDebug; QString logPrefix; - - - int main(int argc, char *argv[]) { enableDebug = true; logPrefix = "[ukui-polkit]:"; - qInstallMessageHandler(outputMessage); + //qInstallMessageHandler(outputMessage); + initUkuiLog4qt("ukui-polkit"); qDebug() << "Polkit Agent Started"; + #if(QT_VERSION>=QT_VERSION_CHECK(5,6,0)) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); diff --git a/polkit-agent/src/PolkitListener.cpp b/polkit-agent/src/PolkitListener.cpp index 6a29100..88d9cdb 100644 --- a/polkit-agent/src/PolkitListener.cpp +++ b/polkit-agent/src/PolkitListener.cpp @@ -35,7 +35,7 @@ #include "PolkitListener.h" #include "mainwindow.h" #include "generic.h" -//#include +#include PolkitListener::PolkitListener(QObject *parent) : Listener(parent), @@ -54,28 +54,26 @@ PolkitListener::~PolkitListener() bool PolkitListener::isMavis() { - /*char *prjName = kdk_system_get_projectName(); - *if (prjName) { - * QString strFeature = QString(prjName); - * free(prjName); - * if (!strFeature.isEmpty()) { - * if(strFeature == "V10SP1-edu"){ - * m_isSupportTableMode = true; - * return true; - * } - * } - *} - */ + char *prjName = kdk_system_get_projectName(); + if (prjName) { + QString strFeature = QString(prjName); + free(prjName); + if (!strFeature.isEmpty()) { + if(strFeature == "V10SP1-edu"){ + m_isSupportTableMode = true; + return true; + } + } + } return false; } bool PolkitListener::isSupportTableMode() { - /*unsigned int nFeature = kdk_system_get_productFeatures(); - *if (nFeature&0x02) { // 支持平板模式 - * return true; - *} - */ + unsigned int nFeature = kdk_system_get_productFeatures(); + if (nFeature&0x02) { // 支持平板模式 + return true; + } return false; } @@ -186,6 +184,10 @@ void PolkitListener::initiateAuthentication( startAuthentication(); }); + connect(mainWindow, &MainWindow::restartAuth, this, [&]{ + startAuthentication(); + }); + connect(mainWindow, &MainWindow::userChanged, this, [&](const QString &userName){ for(int i = 0; i < this->identities.size(); i++) { auto identity = this->identities.at(i); diff --git a/polkit-agent/src/kalabel.cpp b/polkit-agent/src/kalabel.cpp index dd529ab..2666f0b 100644 --- a/polkit-agent/src/kalabel.cpp +++ b/polkit-agent/src/kalabel.cpp @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - **/ #include "kalabel.h" diff --git a/polkit-agent/src/kalabel.h b/polkit-agent/src/kalabel.h index a78d4c9..f2678ac 100644 --- a/polkit-agent/src/kalabel.h +++ b/polkit-agent/src/kalabel.h @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - **/ #ifndef KALABEL_H #define KALABEL_H diff --git a/polkit-agent/src/mainwindow.cpp b/polkit-agent/src/mainwindow.cpp index e722936..e8b66c1 100644 --- a/polkit-agent/src/mainwindow.cpp +++ b/polkit-agent/src/mainwindow.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -94,25 +95,74 @@ MainWindow::MainWindow(QWidget *parent) : m_loginOptsWidget = new LoginOptionsWidget(); m_loginOptsWidget->hide(); ui->titleTipLayout->addWidget(m_labelTip); - ui->loginOptionsLayout->setAlignment(Qt::AlignTop|Qt::AlignHCenter); + ui->loginOptionsLayout->setAlignment(Qt::AlignTop|Qt::AlignCenter); ui->loginOptionsLayout->addWidget(m_loginOptsWidget); - + ui->loadingUkeyWidget->hide(); + ui->widgetUkeyAuth->hide(); + ui->loadingUkeyBtn->setAttribute(Qt::WA_TransparentForMouseEvents, true); + ui->ukeyPassword->setEchoMode(QLineEdit::Password); + ui->loadingUkeyLbl->setText(tr("Insert the ukey into the USB port")); + ui->loadingUkeyLbl->setAlignment(Qt::AlignTop|Qt::AlignHCenter); + ui->ukeyTipLbl->setText(tr("Enter the ukey password")); + ui->ukeyPassword->setPlaceholderText(tr("Input Password")); + ui->loadingUkeyWidget->adjustSize(); maxFailedTimes = bioDevices.getFailedTimes(); isHiddenSwitchButton = bioDevices.GetHiddenSwitchButton(); connect(m_loginOptsWidget, &LoginOptionsWidget::optionSelected, this, [&](unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo){ - qDebug() << "device changed: " << deviceInfo->biotype; - if(m_failMap[getUid(userName)][deviceInfo->device_id] >= maxFailedTimes){ + + isLoadingUkey = false; + + if(uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY){ + stopLoadingUkey(); + } + + if(uCurLoginOptType == LOGINOPT_TYPE_PASSWORD){ + switchLoginOptType(uCurLoginOptType); + if(m_loginOptsWidget){ + m_loginOptsWidget->stopAuth(); + } + m_deviceInfo = nullptr; + authMode = PASSWORD; + emit restartAuth(); + return; + } + + if (uCurLoginOptType != LOGINOPT_TYPE_GENERAL_UKEY && !deviceInfo) + return; + + if(deviceInfo) + qDebug() << "device changed: " << deviceInfo->biotype; + + if(deviceInfo && m_failMap[getUid(userName)][deviceInfo->device_id] >= maxFailedTimes){ qDebug() << "Failed MAX!!"; return ; } + + if (uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY && !deviceInfo){ + isLoadingUkey = true; + startLoadingUkey(); + m_loginOptsWidget->updateUkeyUIStatus(LOGINOPT_TYPE_GENERAL_UKEY); + }else if(uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY && deviceInfo){ + stopLoadingUkey(); + m_loginOptsWidget->updateUkeyUIStatus(LOGINOPT_TYPE_GENERAL_UKEY); + } + if (deviceInfo == m_deviceInfo) { return; } + + if (uCurLoginOptType != LOGINOPT_TYPE_GENERAL_UKEY && deviceInfo == m_deviceInfo) { + return ; + } + + if(m_bioTimer) + m_bioTimer->stop(); + m_deviceInfo = deviceInfo; switchLoginOptType(uCurLoginOptType); - if(!isbioSuccess) { + if(!isbioSuccess && m_deviceInfo) { startBioAuth(); } }); @@ -122,10 +172,15 @@ MainWindow::MainWindow(QWidget *parent) : if (uOptionsCount > 0) { m_loginOptsWidget->show(); } else { - m_loginOptsWidget->hide(); + //m_loginOptsWidget->hide(); } + + if (m_deviceInfo && m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + stopLoadingUkey(); + } + if (!m_deviceInfo || !m_loginOptsWidget->findDeviceById(m_deviceInfo->device_id) - || m_loginOptsWidget->isDeviceDisable(m_deviceInfo->device_id)) { + || m_loginOptsWidget->isDeviceDisable(m_deviceInfo->device_id)) { m_loginOptsWidget->stopAuth(); if (authMode != UNDEFINED) { authMode = UNDEFINED; @@ -138,6 +193,10 @@ MainWindow::MainWindow(QWidget *parent) : this, [&](uid_t uid, bool ret, int nStatus){ qDebug() << "biometric authentication complete: " << uid << ret << nStatus; + if(m_deviceInfo && m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY && ui->widgetUkeyAuth->isVisible()){ + ui->ukeyPassword->setText(""); + } + if(uid == getUid(userName) && ret) { isbioSuccess = true; emit switchToBiometric(); @@ -168,17 +227,27 @@ MainWindow::MainWindow(QWidget *parent) : setLoginTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype))); QImage nullImage; m_loginOptsWidget->setQRCode(nullImage); - } else { + } else if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + ui->ukeyPassword->setReadOnly(true); + setUkeyTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype))); + }else { setLoginTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype))); } + m_loginOptsWidget->setDeviceDisable(m_deviceInfo->device_id, true); useDoubleAuth = false; return ; } no_changes = false; - setLoginTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities") - .arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype)) - .arg(maxFailedTimes-m_failMap[curUid][m_deviceInfo->device_id])); + if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + setUkeyTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities") + .arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype)) + .arg(maxFailedTimes-m_failMap[curUid][m_deviceInfo->device_id])); + }else{ + setLoginTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities") + .arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype)) + .arg(maxFailedTimes-m_failMap[curUid][m_deviceInfo->device_id])); + } } } if(!isbioSuccess) { @@ -222,6 +291,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->lblContent->height(); ui->lblMessage->adjustSize(); ui->widgetPasswdAuth->adjustSize(); + ui->widgetUkeyAuth->adjustSize(); ui->lblMessage->height(); ui->cmbUsers->view()->setTextElideMode(Qt::ElideRight); @@ -239,6 +309,7 @@ MainWindow::MainWindow(QWidget *parent) : this, SLOT(onLockStatus())); connect(interfaceScreensaver, SIGNAL(unlock()), this, SLOT(onUnlockStatus())); + } MainWindow::~MainWindow() @@ -259,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 ")); @@ -275,6 +346,64 @@ void MainWindow::closeEvent(QCloseEvent *event) return QWidget::closeEvent(event); } +void MainWindow::setUkeyTypeTip(QString text) +{ + QString textTip = text; + if (!textTip.isEmpty()) { +// QFontMetrics font(m_ukeyMessageLabel->font()); +// QString textTip = font.elidedText(textTip, Qt::ElideRight, m_messageLabel->width()-8); + QPalette pe; + pe.setColor(QPalette::WindowText,Qt::red); + ui->ukeyMessage->setPalette(pe); + ui->ukeyMessage->setText(textTip); + ui->ukeyMessage->setToolTip(text); + ui->ukeyMessage->show(); + } else { + ui->ukeyMessage->hide(); + } +} + +void MainWindow::startLoadingUkey() +{ + isLoadingUkey = true; + ui->loadingUkeyWidget->show(); + if(!m_loadingTimer) + { + m_loadingTimer = new QTimer(this); + m_loadingTimer->setInterval(150); + connect(m_loadingTimer, &QTimer::timeout, this, &MainWindow::updateLoadingPixmap); + } + + m_loadingPixmap = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(27,27); + ui->loadingUkeyBtn->setIcon(m_loadingPixmap); + ui->loadingUkeyBtn->setIconSize(QSize(27, 27)); + m_loadingTimer->start(); + ui->loadingUkeyWidget->adjustSize(); + ui->cmbUsers->hide(); + ui->widgetUkeyAuth->hide(); + ui->lePassword->hide(); + ui->widgetPasswdAuth->hide(); +} + +void MainWindow::stopLoadingUkey() +{ + isLoadingUkey = false; + if(m_loadingTimer){ + m_loadingTimer->stop(); + } + ui->loadingUkeyWidget->hide(); + //ui->cmbUsers->show(); + ui->widgetUkeyAuth->show(); +} + +void MainWindow::updateLoadingPixmap() +{ + QMatrix matrix; + matrix.rotate(90.0); + m_loadingPixmap = m_loadingPixmap.transformed(matrix, Qt::FastTransformation); + ui->loadingUkeyBtn->setIcon(QIcon(m_loadingPixmap)); +} + void MainWindow::paintEvent(QPaintEvent *event) { @@ -331,6 +460,13 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) return true; } } + if(event->type() == QEvent::MouseButtonRelease) { //禁用鼠标中键 + QMouseEvent *mouseevent = static_cast(event); + if(mouseevent->button() == Qt::MidButton){ + event->ignore(); + return true; + } + } } return false; } @@ -406,7 +542,11 @@ void MainWindow::on_btnCancel_clicked() void MainWindow::on_btnAuth_clicked() { - on_lePassword_returnPressed(); + if(ui->widgetUkeyAuth->isVisible()){ + on_ukeyPassword_returnPressed(); + }else{ + on_lePassword_returnPressed(); + } } void MainWindow::onLockStatus() @@ -442,6 +582,14 @@ void MainWindow::editIcon() ui->lePassword->setTextMargins(1, 1, 4+ m_modeButton->width(), 1); } +void MainWindow::on_ukeyPassword_returnPressed() +{ + if(m_loginOptsWidget && m_deviceInfo){ + m_loginOptsWidget->SetExtraInfo(ui->ukeyPassword->text(),"pincode"); + m_loginOptsWidget->startAuth(m_deviceInfo, getUid(userName)); + } +} + void MainWindow::on_lePassword_returnPressed() { emit accept(ui->lePassword->text()); @@ -469,10 +617,8 @@ void MainWindow::on_btnBioAuth_clicked() void MainWindow::on_returnButton_clicked() { - m_loginOptsWidget->stopAuth(); accept(BIOMETRIC_IGNORE); - } /*** end of control's slot ***/ @@ -557,8 +703,7 @@ void MainWindow::setUsers(const QStringList &usersList) } ui->cmbUsers->show(); - ui->cmbUsers->adjustSize(); - ui->cmbUsers->height(); + //ui->cmbUsers->adjustSize(); } /* void MainWindow::setDetails(const QString &subPid, const QString &callerPid, const QString &actionId, @@ -593,16 +738,17 @@ void MainWindow::setPrompt(const QString &text, bool echo) } //qDebug() << "6666"; m_timer->start(); + unlock_countdown(); ui->lePassword->clear(); ui->lePassword->setPlaceholderText(prompt); - switchWidget(PASSWORD); + // switchWidget(PASSWORD); } /* 转换pam英文提示,目前转换的就3个翻译 Authenticated failed, account locked! - Authenticated failed, 1 login attempts left + Authenticated failed, 1 login attemps left Account locked, 4 minutes left */ QString MainWindow::check_is_pam_message(QString text) @@ -618,13 +764,15 @@ QString MainWindow::check_is_pam_message(QString text) char l_str[1024]; int a,b; //兼容旧版本翻译,以及适配新版本翻译 - if(text.contains("attempts",Qt::CaseSensitive) && sscanf(str,"Authenticated failed, %d login attempts left",&a)) - snprintf(l_str,1024,_("Authenticated failed, %d login attempts left"),a); - else if(text.contains("attempts",Qt::CaseSensitive) && sscanf(str,"Authenticated failed, %d login attempts left",&a)) - snprintf(l_str,1024,_("Authenticated failed, %d login attempts left"),a); + //因为不知道什么原因,pam发过来的始终为英文,因此这里主动加载pam的翻译文件,使用gettext获取翻译 + if(text.contains("attemps",Qt::CaseSensitive) && sscanf(str,"Authenticated failed, %d login attemps left",&a)) + snprintf(l_str,1024,_("Authenticated failed, %d login attemps left"),a); else if(text.contains("attempts",Qt::CaseSensitive) && sscanf(str,"Authenticated failed, %d login attempts left",&a)) snprintf(l_str,1024,_("Authenticated failed, %d login attempts left"),a); + else if(text.contains("attempt",Qt::CaseSensitive) && sscanf(str,"Authenticated failed, %d login attempt left",&a)) + snprintf(l_str,1024,_("Authenticated failed, %d login attempt left"),a); else if(text.contains("days",Qt::CaseSensitive) && sscanf(str,"Account locked, %d days left",&a)){ + //这里的消息是多个字符串拼接起来的,无法在翻译文件中找到对应的句子,只能自己翻译 strTrans = tr("Account locked,") + QString("%1 ").arg(a) + tr("days left"); return strTrans; } @@ -639,6 +787,10 @@ QString MainWindow::check_is_pam_message(QString text) else if(text.contains("seconds",Qt::CaseSensitive) && sscanf(str,"Account locked, %d seconds left",&a)){ strTrans = tr("Account locked,") + QString("%1 ").arg(a) + tr("seconds left"); return strTrans; + }else if(text.contains("Warning: ",Qt::CaseSensitive) && sscanf(str,"Warning: your password will expire in %d day",&a)){ + snprintf(l_str,1024,_("Warning: your password will expire in %d day"),a); + }else if(text.contains("Warning: ",Qt::CaseSensitive) && sscanf(str,"Warning: your password will expire in %d days",&a)){ + snprintf(l_str,1024,_("Warning: your password will expire in %d days"),a); } else{ return _(str); @@ -661,7 +813,7 @@ void MainWindow::setMessage(const QString &text,situation situat) QColor color = palette().color(QPalette::WindowText); QPalette pal(this->palette()); pal.setColor(QPalette::WindowText,QColor(color)); - ui->lblMessage->setPalette(pal); + ui->lblMessage->setPalette(pal); } // qDebug()<<"receive:text = "<lblMessage->setToolTip(text); } ui->lblMessage->adjustSize(); - ui->widgetPasswdAuth->adjustSize(); + //ui->widgetPasswdAuth->adjustSize(); // ui->lblMessage->setText(text); } @@ -708,6 +860,7 @@ void MainWindow::setAuthResult(bool result, const QString &text) void MainWindow::clearEdit() { ui->lePassword->setText(""); + ui->ukeyPassword->setText(""); } void MainWindow::switchAuthMode(Mode mode) @@ -727,6 +880,10 @@ void MainWindow::switchAuthMode(Mode mode) m_loginOptsWidget->setEnabled(true); } + if(m_loginOptsWidget->getHasUkeyOptions()){ + m_loginOptsWidget->show(); + } + switch(mode){ case PASSWORD: { @@ -743,8 +900,9 @@ void MainWindow::switchAuthMode(Mode mode) if(isHiddenSwitchButton) ui->btnBioAuth->hide(); + // if(enableBioAuth && useDoubleAuth){ - // DeviceInfoPtr device = bioDevices.getDefaultDevice(getuid()); + // DeviceInfoPtr device = bioDevices.getDefaultDevice(getUid(userName)); // if(device){ // widgetBioAuth->startAuth(getUid(userName), device); // } @@ -753,6 +911,11 @@ void MainWindow::switchAuthMode(Mode mode) break; case BIOMETRIC: { + if(authMode == PASSWORD){ + emit accept(BIOMETRIC_IGNORE); + isFirstAuth = false; + return; + } authMode = mode; qDebug() << "switch to biometric"; if (m_deviceInfo) { @@ -761,22 +924,28 @@ void MainWindow::switchAuthMode(Mode mode) m_deviceInfo = DeviceInfoPtr(); } } - /*if(authMode == PASSWORD) { - emit accept(BIOMETRIC_IGNORE); - return; - }else */if(!enableBioAuth){ + + if(!enableBioAuth){ qDebug() << "It doesn't meet the condition for enabling biometric authentication, switch to password."; emit accept(BIOMETRIC_IGNORE); + isFirstAuth = false; return; } else if(authMode == BIOMETRIC) { - QString strDeviceName = m_loginOptsWidget->GetDefaultDevice(getuid()); - //如果默认设备为空的话,第一次不启动生物识别认证 + QString strDeviceName; + if(isLoadingUkey){ + strDeviceName = m_loginOptsWidget->GetDefaultDevice(uid, UniT_General_Ukey); + }else{ + strDeviceName = m_loginOptsWidget->GetDefaultDevice(uid); + } + //如果默认设备为空的话,第一次不启动生物识别认证 if(strDeviceName.isEmpty() && !m_deviceInfo) { qDebug() << "No default device"; emit accept(BIOMETRIC_IGNORE); + isFirstAuth = false; return; } + //第一次,获取默认设备的设备信息,之后使用的则是从设备选择窗口传出的设备信息 if(!m_deviceInfo) { @@ -784,13 +953,34 @@ void MainWindow::switchAuthMode(Mode mode) } if(!m_deviceInfo){ emit accept(BIOMETRIC_IGNORE); + isFirstAuth = false; return; } + if(m_failMap.contains(uid) && m_failMap[uid].contains(m_deviceInfo->device_id) && m_failMap[uid][m_deviceInfo->device_id] >= maxFailedTimes){ emit accept(BIOMETRIC_IGNORE); + isFirstAuth = false; return; } + + if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + if(isFirstAuth){ + isFirstAuth = false; + m_deviceInfo = nullptr; + emit accept(BIOMETRIC_IGNORE); + return ; + } + switchLoginOptType(LOGINOPT_TYPE_GENERAL_UKEY); + stopLoadingUkey(); + startBioAuth(); + m_loginOptsWidget->setCurrentDevice(m_deviceInfo); + m_loginOptsWidget->updateUIStatus(false); + + return ; + } + + isFirstAuth = false; startBioAuth(); emit accept(BIOMETRIC_IGNORE); return; @@ -799,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) { @@ -887,6 +1077,7 @@ void MainWindow::switchWidget(Mode mode) if(is_Mavis){ ui->cmbUsers->setFixedHeight(48); ui->lePassword->setFixedHeight(48); + ui->ukeyPassword->setFixedHeight(48); ui->btnAuth->setFixedHeight(48); ui->btnCancel->setFixedHeight(48); } @@ -895,6 +1086,7 @@ void MainWindow::switchWidget(Mode mode) { setMinimumWidth(420); setMaximumWidth(420); + if (m_deviceInfo && m_loginOptsWidget->findDeviceById(m_deviceInfo->device_id)) { switchLoginOptType(m_loginOptsWidget->convertDeviceType(m_deviceInfo->biotype)); } else { @@ -905,27 +1097,27 @@ void MainWindow::switchWidget(Mode mode) } int height; if(fontSize = 10){ - height = 120 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + height = 130 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); } else if(fontSize = 11 ){ - height = 140 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ - + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() - + ui->btnAuth->height(); - } else if (fontSize = 12){ height = 150 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); - } else if (fontSize = 13){ + } else if (fontSize = 12){ height = 160 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); + } else if (fontSize = 13){ + height = 170 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + + ui->btnAuth->height(); } else if (fontSize = 14){ - height = 180 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + height = 190 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); } else if (fontSize = 15){ - height = 220 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + height = 230 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); } @@ -940,6 +1132,8 @@ void MainWindow::switchWidget(Mode mode) } setMinimumHeight(height + uOptsWidgetHeight + 10); setMaximumHeight(height + uOptsWidgetHeight + 10); + + //m_loginOptsWidget->updateUIStatus(); ui->btnBioAuth->setStyleSheet("QPushButton{font-size:14px;}QPushButton:hover{border:none;color:#3E6CE5;}QPushButton:pressed{border:none;}"); ui->btnBioAuth->setFlat(true); @@ -956,7 +1150,7 @@ void MainWindow::switchWidget(Mode mode) } ui->btnAuth->show(); ui->btnLoading->hide(); - ui->lePassword->setDisabled(false); + //ui->lePassword->setDisabled(false); if(w_timer && w_timer->isActive()) { w_timer->stop(); @@ -978,6 +1172,7 @@ void MainWindow::switchWidget(Mode mode) setMinimumHeight(482+ui->cmbUsers->height()+ui->lblHeader->height()); setMaximumHeight(482+ui->cmbUsers->height()+ui->lblHeader->height()); } + ui->btnCancel->hide(); ui->lblContent->hide(); ui->btnBioAuth->hide(); @@ -995,6 +1190,7 @@ void MainWindow::switchWidget(Mode mode) default: break; } + // adjustSize(); } @@ -1024,6 +1220,7 @@ void MainWindow::unlock_countdown() //ui->lblMessage->setToolTip(tr("Please try again in %1 minutes.").arg(nMinute)); ui->lePassword->setText(""); ui->lePassword->setDisabled(true); + ui->btnAuth->setDisabled(true); isLockingFlg = true; return ; } @@ -1034,6 +1231,7 @@ void MainWindow::unlock_countdown() //ui->lblMessage->setToolTip(tr("Please try again in %1 seconds.").arg(time_left%60)); ui->lePassword->setText(""); ui->lePassword->setDisabled(true); + ui->btnAuth->setDisabled(true); isLockingFlg = true; return ; } @@ -1043,6 +1241,7 @@ void MainWindow::unlock_countdown() ui->lblMessage->setToolTip(tr("Account locked permanently.")); ui->lePassword->setText(""); ui->lePassword->setDisabled(true); + ui->btnAuth->setDisabled(true); isLockingFlg = true; return ; } @@ -1052,6 +1251,9 @@ void MainWindow::unlock_countdown() ui->lePassword->setDisabled(false); ui->lePassword->setFocus(); } + if(ui->btnAuth){ + ui->btnAuth->setDisabled(false); + } if (isLockingFlg) { //setMessage(tr("Authentication failed, please try again."),ERROR); @@ -1132,12 +1334,27 @@ void MainWindow::root_unlock_countdown() return ; } +void MainWindow::onRespondUkey(const QString &text) +{ + if (m_loginOptsWidget){ + m_loginOptsWidget->SetExtraInfo(text,"pincode"); + } +} + void MainWindow::switchLoginOptType(unsigned uLoginOptType) { switch(uLoginOptType) { case LOGINOPT_TYPE_PASSWORD: { - m_loginOptsWidget->hide(); + //m_loginOptsWidget->hide(); + ui->lePassword->show(); + ui->cmbUsers->show(); + ui->widgetPasswdAuth->show(); + ui->widgetUkeyAuth->hide(); + ui->ukeyPassword->clearFocus(); + ui->loadingUkeyWidget->hide(); + setFocusProxy(ui->lePassword); + ui->cmbUsers->show(); } break; case LOGINOPT_TYPE_FACE: @@ -1155,6 +1372,31 @@ void MainWindow::switchLoginOptType(unsigned uLoginOptType) m_loginOptsWidget->setQRCodeMsg(""); } }); + + //m_loginOptsWidget->hide(); + ui->lePassword->show(); + ui->widgetUkeyAuth->hide(); + ui->loadingUkeyWidget->hide(); + ui->ukeyPassword->clearFocus(); + setFocusProxy(ui->lePassword); + ui->cmbUsers->show(); + ui->widgetPasswdAuth->show(); + } + break; + case LOGINOPT_TYPE_GENERAL_UKEY: + { + ui->lePassword->hide(); + ui->cmbUsers->hide(); + if(m_deviceInfo){ + stopLoadingUkey(); + ui->widgetUkeyAuth->show(); + }else{ + startLoadingUkey(); + } + setFocusProxy(ui->ukeyPassword); + ui->ukeyPassword->setFocusPolicy(Qt::StrongFocus); + ui->ukeyPassword->setFocus(); + ui->widgetPasswdAuth->hide(); } break; default: @@ -1171,7 +1413,9 @@ void MainWindow::switchLoginOptType(unsigned uLoginOptType) no_changes = true; if (m_deviceInfo->biotype == REMOTE_QRCODE_TYPE) { setLoginTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype))); - } else { + }else if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + setUkeyTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype))); + }else { setLoginTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype))); } m_loginOptsWidget->setDeviceDisable(m_deviceInfo->device_id, true); @@ -1215,6 +1459,11 @@ void MainWindow::switchLoginOptType(unsigned uLoginOptType) setLoginTypeTip(tr("Use the bound wechat scanning code or enter the password to unlock")); } break; + case LOGINOPT_TYPE_GENERAL_UKEY: + { + setLoginTypeTip(""); + } + break; default: return; } @@ -1248,7 +1497,11 @@ void MainWindow::setLoginTypeTip(QString strLoginTypeTip) void MainWindow::startBioAuthDelay() { if (m_deviceInfo) { - m_loginOptsWidget->startAuth(m_deviceInfo, getUid(userName)); + if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + + }else{ + m_loginOptsWidget->startAuth(m_deviceInfo, getUid(userName)); + } switchLoginOptType(m_loginOptsWidget->convertDeviceType(m_deviceInfo->biotype)); } else { switchLoginOptType(LOGINOPT_TYPE_PASSWORD); @@ -1259,6 +1512,11 @@ void MainWindow::startBioAuthDelay() void MainWindow::startBioAuth(unsigned uTimeout) { m_loginOptsWidget->stopAuth(); + + if(m_deviceInfo && m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){ + switchLoginOptType(m_loginOptsWidget->convertDeviceType(m_deviceInfo->biotype)); + } + if(!m_bioTimer){ m_bioTimer = new QTimer(this); connect(m_bioTimer, SIGNAL(timeout()), this, SLOT(startBioAuthDelay())); @@ -1306,35 +1564,43 @@ void MainWindow::onUpdateWndSize(unsigned uLoginOptType, unsigned uLoginOptSize) // ui->lblHeader->adjustSize(); int height; if(fontSize = 10){ - height = 120 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + height = 130 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); } else if(fontSize = 11 ){ - height = 140 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ - + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() - + ui->btnAuth->height(); - } else if (fontSize = 12){ height = 150 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); - } else if (fontSize = 13){ + } else if (fontSize = 12){ height = 160 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); + } else if (fontSize = 13){ + height = 170 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + + ui->btnAuth->height(); } else if (fontSize = 14){ - height = 180 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + height = 190 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); } else if (fontSize = 15){ - height = 220 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + height = 230 + ui->lblHeader->height() /*+ ui->lblContent->height()*/ + ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height() + ui->btnAuth->height(); } if (m_loginOptsWidget->isHidden()) { height -= 20 ; } - setMinimumHeight(height + uOptsWidgetHeight); - setMaximumHeight(height + uOptsWidgetHeight); + + if(uLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY){ + + setMinimumHeight(height + uOptsWidgetHeight + 10); + setMaximumHeight(height + uOptsWidgetHeight + 10); + }else{ + + setMinimumHeight(height + uOptsWidgetHeight); + setMaximumHeight(height + uOptsWidgetHeight); + } } void MainWindow::setEditInputMethod(bool bEnable) diff --git a/polkit-agent/src/mainwindow.h b/polkit-agent/src/mainwindow.h index 894e938..8b3dbd2 100644 --- a/polkit-agent/src/mainwindow.h +++ b/polkit-agent/src/mainwindow.h @@ -64,6 +64,10 @@ public: void switchLoginOptType(unsigned uLoginOptType); void setEditInputMethod(bool bEnable); void setCurProject(bool isMavis); + void setUkeyTypeTip(QString text); + void startLoadingUkey(); + void stopLoadingUkey(); + void updateLoadingPixmap(); private: uid_t getUid(const QString &userName); @@ -88,6 +92,7 @@ public slots: private slots: void on_btnDetails_clicked(); void on_lePassword_returnPressed(); + void on_ukeyPassword_returnPressed(); void on_btnBioAuth_clicked(); void on_returnButton_clicked(); void on_cmbUsers_currentTextChanged(const QString &userName); @@ -98,6 +103,7 @@ private slots: void onConfigurationChanged(QString key); void onLockStatus(); void onUnlockStatus(); + void onRespondUkey(const QString &text); signals: void accept(const QString &text); @@ -105,6 +111,7 @@ signals: void switchToPassword(); void switchToBiometric(); void userChanged(const QString &userName); + void restartAuth(); private: Ui::MainWindow *ui; @@ -125,6 +132,9 @@ private: bool pwdShow = false; bool isHover = false; + //ukey优先级比密码低,该变量用于判断是否第一次认证,并选中密码 + bool isFirstAuth = true; + QTimer *m_timer; //const DeviceInfo *device = NULL; bool isLockingFlg; //判断当前是否正在锁定倒计时 @@ -154,6 +164,10 @@ private: QTimer *w_timer; QPixmap m_waitingPixmap; + + QTimer *m_loadingTimer = nullptr; + QPixmap m_loadingPixmap; + bool isLoadingUkey = false; }; #endif // MAINWINDOW_H diff --git a/polkit-agent/src/mainwindow.ui b/polkit-agent/src/mainwindow.ui index 22b4aa5..e9cf404 100644 --- a/polkit-agent/src/mainwindow.ui +++ b/polkit-agent/src/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 459 - 432 + 547 @@ -42,7 +42,7 @@ 0 - 12 + 24 @@ -67,6 +67,37 @@ 0 + + + + + 382 + 0 + + + + + 382 + 16777215 + + + + + 75 + true + + + + + + + + + + true + + + @@ -95,35 +126,155 @@ - - - true - + 0 - 36 + 116 - - - 16777215 - 36 - + + + + + + 0 + + + 0 + + + 0 + + + + + + + + true + + + + + + + + + + + + + + + + + true - + 8 - + + + + + 0 + 116 + + + + + + + + 0 + + + 0 + + + 0 + + + 9 + + + + + 0 + + + 6 + + + 0 + + + 0 + + + 0 + + + + + Qt::NoContextMenu + + + + + + + + + + + 0 + 25 + + + + Qt::LeftToRight + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + + + + Qt::AlignCenter + + + + + + + + + @@ -131,6 +282,9 @@ 80 + + + 0 @@ -154,18 +308,6 @@ - - - 372 - 36 - - - - - 16777215 - 36 - - Qt::NoContextMenu @@ -204,37 +346,6 @@ - - - - - 382 - 0 - - - - - 382 - 16777215 - - - - - 75 - true - - - - - - - - - - true - - - @@ -255,9 +366,15 @@ 8 + + 24 + 0 + + 24 + 0 diff --git a/polkit-agent/src/modeButton.cpp b/polkit-agent/src/modeButton.cpp index ddf2239..53d0ffc 100644 --- a/polkit-agent/src/modeButton.cpp +++ b/polkit-agent/src/modeButton.cpp @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - **/ #include "modeButton.h" #include diff --git a/polkit-agent/src/modeButton.h b/polkit-agent/src/modeButton.h index 01d774f..b8fa08f 100644 --- a/polkit-agent/src/modeButton.h +++ b/polkit-agent/src/modeButton.h @@ -1,20 +1,3 @@ -/* - * Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - **/ #ifndef MODEBUTTON_H #define MODEBUTTON_H diff --git a/uniauth-backend/CMakeLists.txt b/uniauth-backend/CMakeLists.txt index ed3ad48..4ba44ec 100644 --- a/uniauth-backend/CMakeLists.txt +++ b/uniauth-backend/CMakeLists.txt @@ -19,8 +19,8 @@ set(bin_SRCS ) add_executable(uniauth-backend ${bin_SRCS}) -target_link_libraries(uniauth-backend Qt5::Core Qt5::DBus) +target_link_libraries(uniauth-backend Qt5::Core Qt5::DBus -lukui-log4qt) install(TARGETS uniauth-backend DESTINATION bin) -install(FILES org.ukui.UniauthBackend.conf DESTINATION /usr/share/dbus-1/system.d/) +install(FILES org.ukui.UniauthBackend.conf DESTINATION /etc/dbus-1/system.d/) install(FILES org.ukui.UniauthBackend.service DESTINATION /usr/share/dbus-1/system-services/) diff --git a/uniauth-backend/src/biodeviceinfo.h b/uniauth-backend/src/biodeviceinfo.h index 994bb17..3ec5c81 100644 --- a/uniauth-backend/src/biodeviceinfo.h +++ b/uniauth-backend/src/biodeviceinfo.h @@ -47,6 +47,7 @@ enum BioType { __MAX_NR_BIOTYPES }; +#define UNIT_GENERAL_UKEY (6) #define REMOTE_QRCODE_TYPE (8) Q_DECLARE_METATYPE(DeviceInfo) diff --git a/uniauth-backend/src/main.cpp b/uniauth-backend/src/main.cpp index dae33a6..e52bac8 100644 --- a/uniauth-backend/src/main.cpp +++ b/uniauth-backend/src/main.cpp @@ -17,9 +17,11 @@ **/ #include #include "serviceinterface.h" +#include int main(int argc, char *argv[]) { + initUkuiLog4qt("ukui-biometric-uniauth"); QCoreApplication a(argc, argv); ServiceInterface serviveInterface; diff --git a/uniauth-backend/src/serviceinterface.cpp b/uniauth-backend/src/serviceinterface.cpp index 3862868..b6ae9f0 100644 --- a/uniauth-backend/src/serviceinterface.cpp +++ b/uniauth-backend/src/serviceinterface.cpp @@ -86,6 +86,9 @@ void ServiceInterface::setDefaultDevice(QString userName, int bioDevType, QStrin case BIOTYPE_VOICEPRINT: settings.setValue("VP_DefaultDevice", deviceName); break; + case UNIT_GENERAL_UKEY: + settings.setValue("GU_DefaultDevice",deviceName); + break; case REMOTE_QRCODE_TYPE: settings.setValue("WC_DefaultDevice", deviceName); break; @@ -138,6 +141,9 @@ QString ServiceInterface::getDefaultDevice(QString userName, int bioDevType) case BIOTYPE_VOICEPRINT: strBioDefType = "VP_DefaultDevice"; break; + case UNIT_GENERAL_UKEY: + strBioDefType = "GU_DefaultDevice"; + break; case REMOTE_QRCODE_TYPE: strBioDefType = "WC_DefaultDevice"; break; @@ -173,6 +179,9 @@ QString ServiceInterface::getDefaultDevice(QString userName, int bioDevType) case BIOTYPE_VOICEPRINT: defaultDevice = settings.value("VP_DefaultDevice").toString(); break; + case UNIT_GENERAL_UKEY: + defaultDevice = settings.value("GU_DefaultDevice").toString(); + break; case REMOTE_QRCODE_TYPE: defaultDevice = settings.value("WC_DefaultDevice").toString(); break; @@ -198,6 +207,9 @@ QString ServiceInterface::getDefaultDevice(QString userName, int bioDevType) case BIOTYPE_VOICEPRINT: defaultDevice = settings2.value("VP_DefaultDevice").toString(); break; + case UNIT_GENERAL_UKEY: + defaultDevice = settings2.value("GU_DefaultDevice").toString(); + break; case REMOTE_QRCODE_TYPE: defaultDevice = settings2.value("WC_DefaultDevice").toString(); break; @@ -238,6 +250,9 @@ QStringList ServiceInterface::getAllDefaultDevice(QString userName) case BIOTYPE_VOICEPRINT: strBioDefType = "VP_DefaultDevice"; break; + case UNIT_GENERAL_UKEY: + strBioDefType = "GU_DefaultDevice"; + break; case REMOTE_QRCODE_TYPE: strBioDefType = "WC_DefaultDevice"; break; @@ -277,6 +292,9 @@ QStringList ServiceInterface::getAllDefaultDevice(QString userName) case BIOTYPE_VOICEPRINT: defaultDevice = settings.value("VP_DefaultDevice").toString(); break; + case UNIT_GENERAL_UKEY: + defaultDevice = settings.value("GU_DefaultDevice").toString(); + break; case REMOTE_QRCODE_TYPE: defaultDevice = settings.value("WC_DefaultDevice").toString(); break; @@ -300,6 +318,9 @@ QStringList ServiceInterface::getAllDefaultDevice(QString userName) case BIOTYPE_VOICEPRINT: defaultDevice = settings2.value("VP_DefaultDevice").toString(); break; + case UNIT_GENERAL_UKEY: + defaultDevice = settings2.value("GU_DefaultDevice").toString(); + break; case REMOTE_QRCODE_TYPE: defaultDevice = settings2.value("WC_DefaultDevice").toString(); break; @@ -334,6 +355,9 @@ void ServiceInterface::setCommDefaultDevice(int bioDevType, QString deviceName) case BIOTYPE_VOICEPRINT: settings.setValue("VP_DefaultDevice", deviceName); break; + case UNIT_GENERAL_UKEY: + settings.setValue("GU_DefaultDevice", deviceName); + break; case REMOTE_QRCODE_TYPE: settings.setValue("WC_DefaultDevice", deviceName); break; @@ -366,6 +390,9 @@ QString ServiceInterface::getCommDefaultDevice(int bioDevType) case BIOTYPE_VOICEPRINT: defaultDevice = settings2.value("VP_DefaultDevice").toString(); break; + case UNIT_GENERAL_UKEY: + defaultDevice = settings2.value("GU_DefaultDevice").toString(); + break; case REMOTE_QRCODE_TYPE: defaultDevice = settings2.value("WC_DefaultDevice").toString(); break; @@ -707,6 +734,9 @@ void ServiceInterface::initData() case BIOTYPE_VOICEPRINT: strBioDefType = "VP_DefaultDevice"; break; + case UNIT_GENERAL_UKEY: + strBioDefType = "GU_DefaultDevice"; + break; case REMOTE_QRCODE_TYPE: strBioDefType = "WC_DefaultDevice"; break; @@ -742,6 +772,9 @@ void ServiceInterface::initData() case BIOTYPE_VOICEPRINT: strBioDefType = "VP_DefaultDevice"; break; + case UNIT_GENERAL_UKEY: + strBioDefType = "GU_DefaultDevice"; + break; case REMOTE_QRCODE_TYPE: strBioDefType = "WC_DefaultDevice"; break;