同步yangtze分支代码修改

This commit is contained in:
liudun 2024-01-19 10:21:18 +08:00
parent 160e76c94b
commit 23b1dc268a
46 changed files with 1364 additions and 453 deletions

View File

@ -87,5 +87,22 @@
<source>Unable to verify %1, please enter password.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UKEY AUTHENTICATION</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>BIOMETRIC AUTHENTICATION IS CLOSED</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>AUTHENTICATION END</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter the ukey password
</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -4,7 +4,16 @@
<context>
<name>QObject</name>
<message>
<location filename="../src/main.cpp" line="100"/>
<source>Enter the ukey password</source>
<translation>ukey密码</translation>
</message>
<message>
<location filename="../src/main.cpp" line="110"/>
<source>Enter the ukey password</source>
<translation>ukey密码\n</translation>
</message>
<message>
<location filename="../src/main.cpp" line="131"/>
<source>Try it again</source>
<translation></translation>
</message>
@ -81,7 +90,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/main.cpp" line="249"/>
<location filename="../src/main.cpp" line="282"/>
<source>UKEY AUTHENTICATION</source>
<translation>ukey认证</translation>
</message>
<message>
<location filename="../src/main.cpp" line="284"/>
<source>BIOMETRIC AUTHENTICATION</source>
<translation></translation>
</message>
@ -116,7 +130,12 @@
<translation>%1.</translation>
</message>
<message>
<location filename="../src/main.cpp" line="302"/>
<location filename="../src/main.cpp" line="357"/>
<source>AUTHENTICATION END</source>
<translation></translation>
</message>
<message>
<location filename="../src/main.cpp" line="359"/>
<source>BIOMETRIC AUTHENTICATION END</source>
<translation></translation>
</message>

View File

@ -20,6 +20,7 @@
#include <QTranslator>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <termios.h>
#include <pwd.h>
@ -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, &current);
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<int,int> 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]<maxFailedTimes)
if(m_failedTimes[curDeviceInfo->device_id]<maxFailedTimes)
{
showMessage(QObject::tr("Failed to verify %1, you still have %2 verification opportunities").arg(bioDevices.bioTypeToString_tr(deviceInfo->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>();
deviceInfo = std::make_shared<DeviceInfo>();
*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){

View File

@ -35,6 +35,7 @@ include_directories(
${Qt5Widgets_INCLUDE_DIRS}
${Qt5DBus_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
${GIOUNIX2_INCLUDE_DIRS}
include
../common
)

View File

@ -82,6 +82,10 @@
<source>QRCode</source>
<translation></translation>
</message>
<message>
<source>ukey</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BioDevicesWidget</name>
@ -108,5 +112,9 @@
<source>Login Options</source>
<translation></translation>
</message>
<message>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -28,7 +28,7 @@
</message>
<message>
<source>Password</source>
<translation type="vanished"></translation>
<translation></translation>
</message>
<message>
<source>Current Device: </source>
@ -99,7 +99,12 @@
<translation></translation>
</message>
<message>
<location filename="../src/biodevices.cpp" line="467"/>
<location filename="../src/biodevices.cpp" line="657"/>
<source>ukey</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/biodevices.cpp" line="659"/>
<source>QRCode</source>
<translation></translation>
</message>
@ -139,6 +144,11 @@
<source>Login Options</source>
<translation></translation>
</message>
<message>
<location filename="../src/loginoptionswidget.cpp" line="294"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<source>Wechat</source>
<translation type="vanished"></translation>

View File

@ -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 result> )
*/
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);

View File

@ -45,6 +45,7 @@ public:
QMap<int, QList<DeviceInfo>> getUserDevices(int uid);
QList<DeviceInfo> 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);

View File

@ -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<int, DeviceList> 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);

View File

@ -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

View File

@ -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<QVariant> 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()<<args;
if(deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
QList<QVariant> 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<QDBusVariant> 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<QVariant> variantList = result.arguments();
listsize = variantList[0].value<int>();
variantList[1].value<QDBusArgument>() >> qlist;
for (int i = 0; i < listsize; i++) {
featureInfo = new FeatureInfo;
qlist[i].variant().value<QDBusArgument>() >> *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<int> 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)

View File

@ -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()<<strDeviceName;
if(!strDeviceName.isEmpty()) {
ptrDevInfo = findDevice(strDeviceName);
if (ptrDevInfo) {
if (GetUserDevFeatureCount(uid,ptrDevInfo->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()<<strDeviceName;
if(!strDeviceName.isEmpty()) {
ptrDevInfo = findDevice(strDeviceName);
if (ptrDevInfo) {
@ -583,6 +653,8 @@ QString BioDevices::bioTypeToString_tr(int type)
return tr("Face");
case BIOTYPE_VOICEPRINT:
return tr("VoicePrint");
case LOGINOPT_TYPE_GENERAL_UKEY:
return tr("ukey");
case REMOTE_QRCODE_TYPE:
return tr("QRCode");
}

View File

@ -75,6 +75,27 @@ QDebug operator <<(QDebug stream, const DeviceInfo &deviceInfo)
return stream;
}
/* For the type FeatureInfo */
QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo)
{
argument.beginStructure();
argument << featureInfo.uid << featureInfo.biotype
<< featureInfo.device_shortname << featureInfo.index
<< featureInfo.index_name;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(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");
}

View File

@ -31,6 +31,7 @@
#include <QHBoxLayout>
#include <QButtonGroup>
#include <QToolButton>
#include <QSizePolicy>
#include <QTimer>
#include <QPixmap>
#include <QPainter>
@ -40,6 +41,7 @@
#include <QFont>
#include <QDebug>
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:"<<nDrvId;
DeviceMap::iterator itDevInfo = m_mapDevices.begin();
@ -202,11 +226,17 @@ DeviceInfoPtr LoginOptionsWidget::getFirstDevInfo()
return devInfo;
}
bool LoginOptionsWidget::getHasUkeyOptions()
{
return isShowUkey;
}
void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QString strDrvName)
{
if (m_mapOptBtns.contains(nDrvId)) {
return ;
}
QToolButton *newButton = new QToolButton();
// newButton->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<int, QToolButton*>::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->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;

42
debian/changelog vendored
View File

@ -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 <yangmin@kylinos.cn> 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 <yangmin@kylinos.cn> 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 <yangmin@kylinos.cn> 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 <yangmin@kylinos.cn> Mon, 17 Apr 2023 14:09:28 +0800
ukui-biometric-auth (3.22.0.0-ok4~0413) yangtze; urgency=medium
* BUG号:I643GT 【提权】授权窗口无图标
* 需求号:无
* 其他修改说明:无
-- Yang Min <yangmin@kylinos.cn> Thu, 13 Apr 2023 17:59:37 +0800
ukui-biometric-auth (3.22.0.0-ok3~1101) yangtze; urgency=medium
* 其他修改说明:修复编包问题,重新编包

8
debian/control vendored
View File

@ -4,7 +4,7 @@ Priority: optional
Maintainer: Kylin Team <team+kylin@tracker.debian.org>
Uploaders: handsome_feng <jianfengli@ubuntukylin.com>
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

95
debian/copyright vendored
View File

@ -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 <http://www.gnu.org/licenses/>
.
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 <yanghao@kylinos.cn>
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 <http://www.gnu.org/licenses/>
.
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 <yanghao@kylinos.cn>
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 <http://www.gnu.org/licenses/>
.
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 <yanghao@kylinos.cn>
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 <http://www.gnu.org/licenses/>
.
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 <yanghao@kylinos.cn>
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 <http://www.gnu.org/licenses/>
.
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 <yanghao@kylinos.cn>
License: GPL-3+
This package is free software; you can redistribute it and/or modify

View File

@ -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/*

View File

@ -1,6 +1,3 @@
man/bioauth.1
man/bioctl.1
man/biodrvctl.1
man/bioctl-helper.1
man/biorestart.1
man/uniauth-backend.1

View File

@ -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
}

View File

@ -1 +1 @@
3.0 (quilt)
3.0 (native)

View File

@ -1,3 +1,4 @@
/etc/xdg/*
/usr/share/applications/*
/usr/lib/*
/usr/share/ukui-biometric/i18n_qm/polkit/*.qm

BIN
images/huawei/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1 +1 @@
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M1.5,6.14a.5.5,0,0,1-.5-.5V4.34A3.35,3.35,0,0,1,4.34,1H5.42a.5.5,0,0,1,0,1H4.34A2.34,2.34,0,0,0,2,4.34v1.3A.5.5,0,0,1,1.5,6.14Z" fill="#262626"/><path d="M5.32,15h-1A3.35,3.35,0,0,1,1,11.66V10.57a.5.5,0,0,1,1,0v1.09A2.34,2.34,0,0,0,4.34,14h1a.5.5,0,0,1,0,1Z" fill="#262626"/><path d="M11.66,15h-1.1a.5.5,0,0,1,0-1h1.1A2.34,2.34,0,0,0,14,11.66v-1a.5.5,0,1,1,1,0v1A3.35,3.35,0,0,1,11.66,15Z" fill="#262626"/><path d="M14.5,5.88a.5.5,0,0,1-.5-.5v-1A2.34,2.34,0,0,0,11.66,2h-1a.5.5,0,0,1,0-1h1A3.35,3.35,0,0,1,15,4.34v1A.5.5,0,0,1,14.5,5.88Z" fill="#262626"/><path d="M5.91,5a.92.92,0,1,0,.92.91A.91.91,0,0,0,5.91,5Z" fill="#1a1a1a"/><path d="M11,5l-.19,0A1,1,0,0,0,11,7l.19,0A1,1,0,0,0,11,5Z" fill="#1a1a1a"/><path d="M5.63,10.65s0,1.35,2,1.35a2.94,2.94,0,0,0,2.71-1.35" fill="none" stroke="#1a1a1a" stroke-linecap="round" stroke-miterlimit="10"/><line x1="8" y1="7.27" x2="8" y2="9" fill="none" stroke="#1a1a1a" stroke-linecap="round" stroke-miterlimit="10"/></svg>
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M1.5,6.14a.5.5,0,0,1-.5-.5V4.34A3.36,3.36,0,0,1,4.34,1H5.42a.5.5,0,0,1,0,1H4.34A2.34,2.34,0,0,0,2,4.34H2v1.3A.5.5,0,0,1,1.5,6.14Z" fill="#262626"/><path d="M5.32,15h-1A3.36,3.36,0,0,1,1,11.66V10.57a.5.5,0,0,1,1,0v1.09A2.34,2.34,0,0,0,4.34,14h1a.5.5,0,0,1,0,1Z" fill="#262626"/><path d="M11.66,15h-1.1a.5.5,0,0,1,0-1h1.1A2.34,2.34,0,0,0,14,11.66h0v-1a.5.5,0,0,1,1,0v1A3.36,3.36,0,0,1,11.66,15Z" fill="#262626"/><path d="M14.5,5.88a.5.5,0,0,1-.5-.5v-1A2.34,2.34,0,0,0,11.7,2h-1a.5.5,0,0,1,0-1h1A3.36,3.36,0,0,1,15,4.34v1a.5.5,0,0,1-.46.54Z" fill="#262626"/><path d="M5.91,5a.92.92,0,1,0,.92.92h0A.91.91,0,0,0,5.92,5Z" fill="#262626"/><path d="M11,5h-.19A1,1,0,0,0,11,7h.19A1,1,0,0,0,11,5Z" fill="#262626"/><path d="M7.86,12.51H7.59c-1.94,0-2.46-1.21-2.46-1.85a.5.5,0,0,1,1,0c0,.1.08.86,1.5.86a2.45,2.45,0,0,0,2.29-1.12.5.5,0,0,1,.84.54A3.42,3.42,0,0,1,7.86,12.51ZM6.13,10.65h0Z" fill="#262626"/><path d="M8,9.5A.5.5,0,0,1,7.5,9V7.27a.5.5,0,0,1,1,0V9A.5.5,0,0,1,8,9.5Z" fill="#262626"/></svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1 +1 @@
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M2.35,5.66,2,5.48A.68.68,0,0,0,2.35,5.66Z" fill="#262626"/><path d="M2,10.63l.32-.18A.68.68,0,0,0,2,10.63Z" fill="#262626"/><path d="M13.58,10a.42.42,0,0,1,.42.42v3.16a.42.42,0,0,1-.42.42H8.42A.42.42,0,0,1,8,13.58V10.42A.42.42,0,0,1,8.42,10h5.16m0-1H8.42A1.43,1.43,0,0,0,7,10.42v3.16A1.43,1.43,0,0,0,8.42,15h5.16A1.43,1.43,0,0,0,15,13.58V10.42A1.43,1.43,0,0,0,13.58,9Z"/><path d="M11.85,7a.15.15,0,0,1,.15.15V9H10V7.15A.15.15,0,0,1,10.15,7h1.7m0-1h-1.7A1.16,1.16,0,0,0,9,7.15V10h4V7.15A1.16,1.16,0,0,0,11.85,6Z"/><path d="M2.5,4.42a.54.54,0,0,0-.22,0,.61.61,0,0,0-.41.58A.65.65,0,0,0,2,5.48a.68.68,0,0,0,.32.18l.15,0a.64.64,0,0,0,.63-.64.52.52,0,0,0,0-.11A.62.62,0,0,0,2.5,4.42Z" fill="none"/><path d="M2.5,10.42l-.15,0a.68.68,0,0,0-.32.18.65.65,0,0,0-.16.42.61.61,0,0,0,.41.59.54.54,0,0,0,.22,0,.62.62,0,0,0,.61-.52.5.5,0,0,0,0-.12A.63.63,0,0,0,2.5,10.42Z" fill="none"/><path d="M7.5,2.69A.64.64,0,0,0,8,2.43a.62.62,0,0,0,.13-.38A.62.62,0,0,0,8,1.68a.8.8,0,0,0-.13-.13.59.59,0,0,0-.74,0A.8.8,0,0,0,7,1.68a.62.62,0,0,0-.13.37A.62.62,0,0,0,7,2.43.64.64,0,0,0,7.5,2.69Z" fill="none"/><path d="M8,8V8a2,2,0,0,1,.36-1.14A1.31,1.31,0,0,0,8,6.65a1.3,1.3,0,0,0-1,0,1.47,1.47,0,0,0-.47.27,1.51,1.51,0,0,0-.5.86,1.24,1.24,0,0,0,0,.27,1.27,1.27,0,0,0,0,.28,1.42,1.42,0,0,0,.4.74A2.4,2.4,0,0,1,8,8Z" fill="none"/><path d="M8.13,2.05A.62.62,0,0,0,8,1.68a.8.8,0,0,0-.13-.13.59.59,0,0,0-.74,0A.8.8,0,0,0,7,1.68a.62.62,0,0,0-.13.37A.62.62,0,0,0,7,2.43a.61.61,0,0,0,1,0A.62.62,0,0,0,8.13,2.05Z" fill="none"/><path d="M2.5,4.42a.54.54,0,0,0-.22,0,.61.61,0,0,0-.41.58A.65.65,0,0,0,2,5.48a.68.68,0,0,0,.32.18l.15,0a.64.64,0,0,0,.63-.64.52.52,0,0,0,0-.11A.62.62,0,0,0,2.5,4.42Z" fill="none"/><path d="M2.5,10.42l-.15,0a.68.68,0,0,0-.32.18.65.65,0,0,0-.16.42.61.61,0,0,0,.41.59.54.54,0,0,0,.22,0,.62.62,0,0,0,.61-.52.5.5,0,0,0,0-.12A.63.63,0,0,0,2.5,10.42Z" fill="none"/><path d="M13.12,5.11s0,0,0-.06a.61.61,0,0,0-.41-.58.54.54,0,0,0-.22,0,.65.65,0,0,0-.34.11A1.68,1.68,0,0,1,13.12,5.11Z" fill="none"/><path d="M14,5.05a1.5,1.5,0,0,0-2.89-.55h.74a1.63,1.63,0,0,1,.31,0,.65.65,0,0,1,.34-.11.54.54,0,0,1,.22,0,.61.61,0,0,1,.41.58s0,0,0,.06a1.68,1.68,0,0,1,.38,1h0A1.45,1.45,0,0,0,14,5.05Z" fill="#262626"/><path d="M8.54,5.8A2,2,0,0,0,8,5.61V3.46A1.49,1.49,0,0,0,9,2.05a1.5,1.5,0,1,0-3,0A1.49,1.49,0,0,0,7,3.46V5.61a2.45,2.45,0,0,0-1.36.79L4,5.43a1.58,1.58,0,0,0,0-.38,1.5,1.5,0,1,0-1.5,1.5,1.53,1.53,0,0,0,.89-.29l1.75,1A2.56,2.56,0,0,0,5,8.05a2.57,2.57,0,0,0,.14.79l-1.75,1a1.54,1.54,0,0,0-.89-.3A1.5,1.5,0,1,0,4,11.05a1.57,1.57,0,0,0,0-.37l1.69-1a2.57,2.57,0,0,0,.39.35,2.46,2.46,0,0,1,.4-1A1.42,1.42,0,0,1,6,8.33a1.27,1.27,0,0,1,0-.28,1.24,1.24,0,0,1,0-.27,1.51,1.51,0,0,1,.5-.86A1.47,1.47,0,0,1,7,6.65a1.3,1.3,0,0,1,1,0,1.31,1.31,0,0,1,.36.21c0-.06.1-.1.14-.15V6.15A2,2,0,0,1,8.54,5.8Zm-6-.11-.15,0A.68.68,0,0,1,2,5.48a.65.65,0,0,1-.16-.43.61.61,0,0,1,.41-.58.54.54,0,0,1,.22,0,.62.62,0,0,1,.61.52.52.52,0,0,1,0,.11A.64.64,0,0,1,2.5,5.69Zm.61,5.48a.62.62,0,0,1-.61.52.54.54,0,0,1-.22,0,.61.61,0,0,1-.41-.59A.65.65,0,0,1,2,10.63a.68.68,0,0,1,.32-.18l.15,0a.63.63,0,0,1,.63.63A.5.5,0,0,1,3.11,11.17ZM7.5,2.69A.64.64,0,0,1,7,2.43a.62.62,0,0,1-.13-.38A.62.62,0,0,1,7,1.68a.8.8,0,0,1,.13-.13.59.59,0,0,1,.74,0A.8.8,0,0,1,8,1.68a.62.62,0,0,1,.13.37A.62.62,0,0,1,8,2.43.64.64,0,0,1,7.5,2.69Z" fill="#262626"/></svg>
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M4.5,5A2.5,2.5,0,0,1,7,7.14L7,7.5l0,.36A2.49,2.49,0,1,1,4.5,5m0-1A3.5,3.5,0,1,0,8,8h6.58A.47.47,0,0,0,15,7.53V7.47A.47.47,0,0,0,14.53,7H8A3.49,3.49,0,0,0,4.5,4Z" fill="#262626"/><rect x="9" y="7" width="1" height="3" rx="0.5" fill="#262626"/><rect x="12" y="7" width="1" height="3" rx="0.5" fill="#262626"/></svg>

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 417 B

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
<style type="text/css">
.st0{display:none;}
.st1{display:inline;fill:#262626;}
.st2{display:inline;fill:none;stroke:#262626;stroke-linecap:round;stroke-miterlimit:10;}
.st3{fill:#262626;}
.st4{fill:none;stroke:#262626;stroke-linecap:round;stroke-miterlimit:10;}
</style>
<g id="图层_1" class="st0">
<path class="st1" d="M5,5.6C5,5.3,5.3,5,5.6,5c0,0,0,0,0,0h5.8C11.7,5,12,5.3,12,5.6v0v7.8c0,0.3-0.3,0.6-0.6,0.6l0,0H5.6
C5.3,14,5,13.7,5,13.4V5.6 M4,5.6v7.8C4,14.3,4.7,15,5.6,15h5.8c0.9,0,1.6-0.7,1.6-1.6c0,0,0,0,0,0V5.6C13,4.7,12.3,4,11.4,4
c0,0,0,0,0,0H5.6C4.7,4,4,4.7,4,5.6L4,5.6z"/>
<path class="st1" d="M7,3h3v1H7V3 M6,3v2h5V3c0-0.6-0.4-1-1-1H7C6.4,2,6,2.4,6,3z"/>
<path class="st1" d="M8,6.5v6C8,12.8,8.2,13,8.5,13S9,12.8,9,12.5v-6C9,6.2,8.8,6,8.5,6S8,6.2,8,6.5z"/>
<path class="st2" d="M8,10.5L8,10.5c-0.8,0-1.5-0.7-1.5-1.5V8"/>
<path class="st2" d="M9,9.5L9,9.5c0.8,0,1.5-0.7,1.5-1.5V7"/>
</g>
<g id="图层_1_x5F_复制">
<path class="st3" d="M3,4.6C3,4.3,3.3,4,3.6,4c0,0,0,0,0,0h7.8C11.7,4,12,4.3,12,4.6v0v8.8c0,0.3-0.3,0.6-0.6,0.6l0,0H3.6
C3.3,14,3,13.7,3,13.4V4.6 M2,4.6v8.8C2,14.3,2.7,15,3.6,15h7.8c0.9,0,1.6-0.7,1.6-1.6c0,0,0,0,0,0V4.6C13,3.7,12.3,3,11.4,3
c0,0,0,0,0,0H3.6C2.7,3,2,3.7,2,4.6L2,4.6z"/>
<path class="st3" d="M5,2h5v1H5V2 M4,2v2h7V2c0-0.6-0.4-1-1-1H5C4.4,1,4,1.4,4,2z"/>
<path class="st3" d="M7,6.5v6C7,12.8,7.2,13,7.5,13S8,12.8,8,12.5v-6C8,6.2,7.8,6,7.5,6S7,6.2,7,6.5z"/>
<path class="st4" d="M7,10.5L7,10.5c-0.8,0-1.5-0.7-1.5-1.5V8"/>
<path class="st4" d="M8,9.5L8,9.5c0.8,0,1.5-0.7,1.5-1.5V7"/>
<rect x="7" y="1" class="st3" width="1" height="2"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -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 "")

View File

@ -24,12 +24,12 @@
#include <unistd.h>
#include <sys/stat.h>
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);
}

View File

@ -31,13 +31,15 @@
#include <security/pam_ext.h>
#include <signal.h>
#include <errno.h>
#include <glib.h>
#include <string.h>
#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;
}

View File

@ -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)

View File

@ -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

View File

@ -304,7 +304,17 @@
<translation></translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="627"/>
<location filename="../src/mainwindow.cpp" line="104"/>
<source>Insert the ukey into the USB port</source>
<translation>USBཡི</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="106"/>
<source>Enter the ukey password</source>
<translation></translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="764"/>
<source>hours left</source>
<translation></translation>
</message>

View File

@ -88,7 +88,7 @@
</message>
<message>
<source>Password</source>
<translation type="vanished"></translation>
<translation></translation>
</message>
<message>
<location filename="../src/mainwindow.ui" line="302"/>
@ -304,7 +304,17 @@
<translation></translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="627"/>
<location filename="../src/mainwindow.cpp" line="104"/>
<source>Insert the ukey into the USB port</source>
<translation>USB端口</translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="106"/>
<source>Enter the ukey password</source>
<translation></translation>
</message>
<message>
<location filename="../src/mainwindow.cpp" line="764"/>
<source>hours left</source>
<translation></translation>
</message>

View File

@ -24,19 +24,19 @@
#include "generic.h"
#include "sessionmanager.h"
#include "biodevices.h"
#include <ukui-log4qt.h>
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);

View File

@ -35,7 +35,7 @@
#include "PolkitListener.h"
#include "mainwindow.h"
#include "generic.h"
//#include <libkysysinfo.h>
#include <libkysysinfo.h>
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);

View File

@ -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 <http://www.gnu.org/licenses/>.
*
**/
#include "kalabel.h"

View File

@ -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 <http://www.gnu.org/licenses/>.
*
**/
#ifndef KALABEL_H
#define KALABEL_H

View File

@ -24,6 +24,7 @@
#include <QPainterPath>
#include <QDir>
#include <QFont>
#include <QLineEdit>
#include <QPainter>
#include <QPixmap>
#include <QFontMetrics>
@ -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<QMouseEvent*>(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()<<"receivetext = "<<text;
@ -683,7 +835,7 @@ void MainWindow::setMessage(const QString &text,situation situat)
ui->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)

View File

@ -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

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>459</width>
<height>432</height>
<height>547</height>
</rect>
</property>
<property name="sizePolicy">
@ -42,7 +42,7 @@
<number>0</number>
</property>
<property name="bottomMargin">
<number>12</number>
<number>24</number>
</property>
<item>
<layout class="QFormLayout" name="formLayout">
@ -67,6 +67,37 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="lblHeader">
<property name="minimumSize">
<size>
<width>382</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>382</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lblContent">
<property name="styleSheet">
@ -95,35 +126,155 @@
</layout>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="cmbUsers">
<property name="enabled">
<bool>true</bool>
</property>
<widget class="QWidget" name="loadingUkeyWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>36</height>
<height>116</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>36</height>
</size>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="loadingUkeyBtn">
<property name="text">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="loadingUkeyLbl">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="cmbUsers">
<property name="enabled">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<layout class="QFormLayout" name="bioDeviceLayout">
<property name="bottomMargin">
<number>8</number>
</property>
</layout>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QWidget" name="widgetUkeyAuth" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>116</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QFormLayout" name="formLayout_3">
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QLineEdit" name="ukeyPassword">
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="KALabel" name="ukeyMessage">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="ukeyTipLbl">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="9" column="1">
<widget class="QWidget" name="widgetPasswdAuth" native="true">
<property name="minimumSize">
<size>
@ -131,6 +282,9 @@
<height>80</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
@ -154,18 +308,6 @@
</property>
<item row="0" column="0" colspan="2">
<widget class="QLineEdit" name="lePassword">
<property name="minimumSize">
<size>
<width>372</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>36</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
@ -204,37 +346,6 @@
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lblHeader">
<property name="minimumSize">
<size>
<width>382</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>382</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -255,9 +366,15 @@
<property name="spacing">
<number>8</number>
</property>
<property name="leftMargin">
<number>24</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>24</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>

View File

@ -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 <http://www.gnu.org/licenses/>.
*
**/
#include "modeButton.h"
#include <QIcon>

View File

@ -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 <http://www.gnu.org/licenses/>.
*
**/
#ifndef MODEBUTTON_H
#define MODEBUTTON_H

View File

@ -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/)

View File

@ -47,6 +47,7 @@ enum BioType {
__MAX_NR_BIOTYPES
};
#define UNIT_GENERAL_UKEY (6)
#define REMOTE_QRCODE_TYPE (8)
Q_DECLARE_METATYPE(DeviceInfo)

View File

@ -17,9 +17,11 @@
**/
#include <QCoreApplication>
#include "serviceinterface.h"
#include <ukui-log4qt.h>
int main(int argc, char *argv[])
{
initUkuiLog4qt("ukui-biometric-uniauth");
QCoreApplication a(argc, argv);
ServiceInterface serviveInterface;

View File

@ -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;