435 lines
13 KiB
Diff
435 lines
13 KiB
Diff
From: =?utf-8?b?5p2o5pWP?= <yangmin@kylinos.cn>
|
|
Date: Fri, 19 Jan 2024 07:20:12 +0000
|
|
Subject: =?utf-8?b?ITYzIOWNleeCueeZu+W9lei/geenu+WIsOWQjuerryBNZXJnZSBwdWxs?=
|
|
=?utf-8?b?IHJlcXVlc3QgITYzIGZyb20g5YiY6L+c6bmPL29wZW5reWxpbi9uaWxl?=
|
|
|
|
---
|
|
src/lock-backend/dbusupperinterface.cpp | 17 +++----
|
|
src/lock-backend/dbusupperinterface.h | 8 ++--
|
|
src/lock-backend/main.cpp | 11 +++++
|
|
src/lock-backend/msysdbus.cpp | 71 +++++++++++++++++++++++++++++
|
|
src/lock-backend/msysdbus.h | 47 +++++++++++++++++++
|
|
src/lock-dialog/main.cpp | 7 ---
|
|
src/lock-dialog/msysdbus.cpp | 80 ---------------------------------
|
|
src/lock-dialog/msysdbus.h | 53 ----------------------
|
|
src/widgets/authdialog.cpp | 1 +
|
|
9 files changed, 143 insertions(+), 152 deletions(-)
|
|
create mode 100644 src/lock-backend/msysdbus.cpp
|
|
create mode 100644 src/lock-backend/msysdbus.h
|
|
delete mode 100644 src/lock-dialog/msysdbus.cpp
|
|
delete mode 100644 src/lock-dialog/msysdbus.h
|
|
|
|
diff --git a/src/lock-backend/dbusupperinterface.cpp b/src/lock-backend/dbusupperinterface.cpp
|
|
index 69bb7fa..bbe7b8d 100644
|
|
--- a/src/lock-backend/dbusupperinterface.cpp
|
|
+++ b/src/lock-backend/dbusupperinterface.cpp
|
|
@@ -645,9 +645,6 @@ int DbusUpperInterface::SetInformation(QString strJson)
|
|
case LOCK_CMD_ID_BIOAUTH_STOPAUTH:
|
|
nRet = BioStopAuth(rootObj);
|
|
break;
|
|
- case LOCK_CMD_ID_SEND_USER_PASSWORD:
|
|
- nRet = sendPassword(rootObj);
|
|
- break;
|
|
case LOCK_CMD_ID_KWIN_BLOCK_SHORTCUT:
|
|
nRet = blockShortcut(rootObj);
|
|
break;
|
|
@@ -2108,15 +2105,11 @@ QString DbusUpperInterface::getPublicEncrypt()
|
|
return QString(pubKey);
|
|
}
|
|
|
|
-bool DbusUpperInterface::sendPassword(const QJsonObject &objInfo)
|
|
+bool DbusUpperInterface::sendPassword(const QString username,QByteArray password)
|
|
{
|
|
if(priKey.isEmpty())
|
|
return false;
|
|
|
|
- QJsonObject obj = objInfo["Content"].toObject();
|
|
- QString username = obj["username"].toString();
|
|
- QByteArray password = obj["password"].toVariant().toByteArray();
|
|
-
|
|
QByteArray decryptText;
|
|
rsac.decrypt(password, decryptText, priKey); // 解密
|
|
|
|
@@ -2124,7 +2117,15 @@ bool DbusUpperInterface::sendPassword(const QJsonObject &objInfo)
|
|
if(m_pamAuth && m_pamAuth->inAuthentication() && (m_pamAuth->authenticationUser() == username)){
|
|
m_pamAuth->respond(QString(decryptText));
|
|
}
|
|
+ else if(m_pamAuth){
|
|
+ m_pamAuth->authenticate(username);
|
|
+ QTimer::singleShot(100, this, [=](){
|
|
+ m_pamAuth->respond(QString(decryptText));
|
|
+ });
|
|
+ }
|
|
}
|
|
+
|
|
+ return true;
|
|
}
|
|
|
|
void DbusUpperInterface::BioFindDeviceByName(QJsonObject &reqObj, QJsonObject &retObj)
|
|
diff --git a/src/lock-backend/dbusupperinterface.h b/src/lock-backend/dbusupperinterface.h
|
|
index 474fd0a..809ace9 100644
|
|
--- a/src/lock-backend/dbusupperinterface.h
|
|
+++ b/src/lock-backend/dbusupperinterface.h
|
|
@@ -126,6 +126,10 @@ public:
|
|
*/
|
|
int SetInformation(QString strJson);
|
|
|
|
+ QString getPublicEncrypt();
|
|
+
|
|
+ bool sendPassword(const QString username,QByteArray password);
|
|
+
|
|
public Q_SLOTS:
|
|
/**
|
|
* @brief 服务退出
|
|
@@ -347,10 +351,6 @@ private:
|
|
|
|
int BioStopAuth(const QJsonObject &objInfo);
|
|
|
|
- QString getPublicEncrypt();
|
|
-
|
|
- bool sendPassword(const QJsonObject &objInfo);
|
|
-
|
|
private:
|
|
/**
|
|
* @brief 初始化数据
|
|
diff --git a/src/lock-backend/main.cpp b/src/lock-backend/main.cpp
|
|
index fd5f148..1b2dcc7 100644
|
|
--- a/src/lock-backend/main.cpp
|
|
+++ b/src/lock-backend/main.cpp
|
|
@@ -31,6 +31,7 @@
|
|
#include "dbusupperinterface.h"
|
|
#include "screensaveradaptor.h"
|
|
#include "personalizeddata.h"
|
|
+#include "msysdbus.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
@@ -102,5 +103,15 @@ int main(int argc, char *argv[])
|
|
});
|
|
}
|
|
|
|
+ MSysDbus *m_sysDbus = new MSysDbus(interface,nullptr);
|
|
+
|
|
+ QString displayNum = QString(qgetenv("DISPLAY")).replace(":", "").replace(".", "_");
|
|
+ QString sysService = "org.ukui.screensaver._" + displayNum;
|
|
+ if (!QDBusConnection::systemBus().registerService("org.ukui.screensaver")) {
|
|
+ qDebug()<<"registerService failed";
|
|
+ }
|
|
+
|
|
+ QDBusConnection::systemBus().registerObject("/", "org.ukui.screensaver",m_sysDbus, QDBusConnection::ExportAllSlots);
|
|
+
|
|
return a.exec();
|
|
}
|
|
diff --git a/src/lock-backend/msysdbus.cpp b/src/lock-backend/msysdbus.cpp
|
|
new file mode 100644
|
|
index 0000000..4100d4d
|
|
--- /dev/null
|
|
+++ b/src/lock-backend/msysdbus.cpp
|
|
@@ -0,0 +1,71 @@
|
|
+/*
|
|
+ * Copyright (C) 2023 KylinSoft 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 <QDBusInterface>
|
|
+#include <QDebug>
|
|
+#include <QDBusReply>
|
|
+#include "dbusupperinterface.h"
|
|
+#include "msysdbus.h"
|
|
+#include "rsac.h"
|
|
+#include <openssl/rsa.h>
|
|
+#include <openssl/pem.h>
|
|
+#include <QTimer>
|
|
+
|
|
+MSysDbus::MSysDbus(DbusUpperInterface *interface,QObject *parent)
|
|
+ : QObject(parent)
|
|
+ , m_interface(interface)
|
|
+{
|
|
+ registerUniauth();
|
|
+}
|
|
+
|
|
+bool MSysDbus::sendPassword(const QString username,QByteArray password)
|
|
+{
|
|
+ if(m_interface)
|
|
+ return m_interface->sendPassword(username,password);
|
|
+
|
|
+ qWarning()<<"m_interface is nullptr";
|
|
+ return false;
|
|
+}
|
|
+
|
|
+QString MSysDbus::getPublicEncrypt()
|
|
+{
|
|
+ if(m_interface)
|
|
+ return m_interface->getPublicEncrypt();
|
|
+
|
|
+ qWarning()<<"m_interface is nullptr";
|
|
+ return "";
|
|
+}
|
|
+
|
|
+void MSysDbus::registerUniauth()
|
|
+{
|
|
+ QDBusInterface iface("org.ukui.UniauthBackend",
|
|
+ "/org/ukui/UniauthBackend",
|
|
+ "org.ukui.UniauthBackend",
|
|
+ QDBusConnection::systemBus());
|
|
+ iface.call("registerLoginApp");
|
|
+}
|
|
+
|
|
+
|
|
+void MSysDbus::sendSignalLoginFinished(QString username,bool res)
|
|
+{
|
|
+ QDBusInterface iface("org.ukui.UniauthBackend",
|
|
+ "/org/ukui/UniauthBackend",
|
|
+ "org.ukui.UniauthBackend",
|
|
+ QDBusConnection::systemBus());
|
|
+ iface.call("sendSignalLoginFinished",username,res);
|
|
+}
|
|
+
|
|
diff --git a/src/lock-backend/msysdbus.h b/src/lock-backend/msysdbus.h
|
|
new file mode 100644
|
|
index 0000000..162ea5b
|
|
--- /dev/null
|
|
+++ b/src/lock-backend/msysdbus.h
|
|
@@ -0,0 +1,47 @@
|
|
+/*
|
|
+ * Copyright (C) 2023 KylinSoftCo., 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 MSYSDBUS_H
|
|
+#define MSYSDBUS_H
|
|
+
|
|
+#include <QDBusConnection>
|
|
+#include <QObject>
|
|
+#include <QByteArray>
|
|
+#include "rsac.h"
|
|
+class DbusUpperInterface;
|
|
+
|
|
+class MSysDbus: public QObject
|
|
+{
|
|
+ Q_OBJECT
|
|
+public:
|
|
+ explicit MSysDbus(DbusUpperInterface *interface,QObject *parent = nullptr);
|
|
+
|
|
+public Q_SLOTS:
|
|
+ Q_SCRIPTABLE bool sendPassword(const QString username,QByteArray password);
|
|
+ Q_SCRIPTABLE QString getPublicEncrypt();
|
|
+Q_SIGNALS:
|
|
+ void closed();
|
|
+
|
|
+private:
|
|
+ void registerUniauth();
|
|
+ void sendSignalLoginFinished(QString username,bool res);
|
|
+
|
|
+ DbusUpperInterface *m_interface = nullptr;
|
|
+};
|
|
+
|
|
+
|
|
+#endif
|
|
diff --git a/src/lock-dialog/main.cpp b/src/lock-dialog/main.cpp
|
|
index f8de172..d93297e 100644
|
|
--- a/src/lock-dialog/main.cpp
|
|
+++ b/src/lock-dialog/main.cpp
|
|
@@ -41,7 +41,6 @@
|
|
#include "fullbackgroundwidget.h"
|
|
#include "screensaverwndadaptor.h"
|
|
#include "pluginsloader.h"
|
|
-#include "msysdbus.h"
|
|
#include "languagesetting.h"
|
|
#include "displayservice.h"
|
|
|
|
@@ -164,12 +163,6 @@ int main(int argc, char *argv[])
|
|
syslog(LOG_INFO, "[ukui-screensaver-dialog] window show done!!");
|
|
#endif
|
|
|
|
- MSysDbus *m_sysDbus = new MSysDbus(lockDialogModel,window);
|
|
-
|
|
- if (!QDBusConnection::systemBus().registerService("org.ukui.screensaver")) {
|
|
- qDebug()<<"registerService failed";
|
|
- }
|
|
-
|
|
if(cmdArgs.isLock) {
|
|
Q_EMIT lockDialogModel->showLock(false);
|
|
}
|
|
diff --git a/src/lock-dialog/msysdbus.cpp b/src/lock-dialog/msysdbus.cpp
|
|
deleted file mode 100644
|
|
index 7b9b039..0000000
|
|
--- a/src/lock-dialog/msysdbus.cpp
|
|
+++ /dev/null
|
|
@@ -1,80 +0,0 @@
|
|
-/*
|
|
- * Copyright (C) 2023 KylinSoft 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 <QDBusInterface>
|
|
-#include <QDBusReply>
|
|
-#include "msysdbus.h"
|
|
-#include "rsac.h"
|
|
-#include "lockdialogmodel.h"
|
|
-#include <openssl/rsa.h>
|
|
-#include <openssl/pem.h>
|
|
-#include <QTimer>
|
|
-
|
|
-MSysDbus::MSysDbus(LockDialogModel *model, QObject *parent)
|
|
- : QObject(parent)
|
|
- , m_modelLockDialog(model)
|
|
-
|
|
-{
|
|
- registerUniauth();
|
|
-}
|
|
-
|
|
-bool MSysDbus::sendPassword(const QString username,QByteArray password)
|
|
-{
|
|
-
|
|
- if(m_modelLockDialog){
|
|
- return Q_EMIT m_modelLockDialog->sendPassword(username,password);
|
|
- }
|
|
- return true;
|
|
-}
|
|
-
|
|
-QString MSysDbus::getPublicEncrypt()
|
|
-{
|
|
- if(m_modelLockDialog){
|
|
- return Q_EMIT m_modelLockDialog->getPublicEncrypt();
|
|
- }
|
|
- return "";
|
|
-}
|
|
-
|
|
-void MSysDbus::initRSA()
|
|
-{
|
|
- //rsac.generateKeyPair(priKey, pubKey, 2048);
|
|
-}
|
|
-
|
|
-void MSysDbus::registerUniauth()
|
|
-{
|
|
- QDBusInterface iface("org.ukui.UniauthBackend",
|
|
- "/org/ukui/UniauthBackend",
|
|
- "org.ukui.UniauthBackend",
|
|
- QDBusConnection::systemBus());
|
|
- QDBusReply<QString> stateReply = iface.call("registerLoginApp");
|
|
- if(!stateReply.isValid())
|
|
- {
|
|
- qDebug() << "registerLoginApp:" << stateReply.error();
|
|
- return ;
|
|
- }
|
|
-}
|
|
-
|
|
-
|
|
-void MSysDbus::sendSignalLoginFinished(QString username,bool res)
|
|
-{
|
|
- QDBusInterface iface("org.ukui.UniauthBackend",
|
|
- "/org/ukui/UniauthBackend",
|
|
- "org.ukui.UniauthBackend",
|
|
- QDBusConnection::systemBus());
|
|
- QDBusReply<QString> stateReply = iface.call("sendSignalLoginFinished",username,res);
|
|
-}
|
|
-
|
|
diff --git a/src/lock-dialog/msysdbus.h b/src/lock-dialog/msysdbus.h
|
|
deleted file mode 100644
|
|
index fe2aacf..0000000
|
|
--- a/src/lock-dialog/msysdbus.h
|
|
+++ /dev/null
|
|
@@ -1,53 +0,0 @@
|
|
-/*
|
|
- * Copyright (C) 2023 KylinSoftCo., 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 MSYSDBUS_H
|
|
-#define MSYSDBUS_H
|
|
-
|
|
-#include <QDBusConnection>
|
|
-#include <QObject>
|
|
-#include <QByteArray>
|
|
-#include "rsac.h"
|
|
-
|
|
-class LockDialogModel;
|
|
-class MSysDbus: public QObject
|
|
-{
|
|
- Q_OBJECT
|
|
-public:
|
|
- explicit MSysDbus(LockDialogModel *model, QObject *parent = nullptr);
|
|
- void setAuthWidget(LockDialogModel *model);
|
|
-
|
|
-public Q_SLOTS:
|
|
- Q_SCRIPTABLE bool sendPassword(const QString username,QByteArray password);
|
|
- Q_SCRIPTABLE QString getPublicEncrypt();
|
|
-Q_SIGNALS:
|
|
- void closed();
|
|
-
|
|
-private:
|
|
- void initRSA();
|
|
- void registerUniauth();
|
|
- void sendSignalLoginFinished(QString username,bool res);
|
|
-
|
|
- QString m_userName = "";
|
|
- QString m_password = "";
|
|
- LockDialogModel *m_modelLockDialog = nullptr;
|
|
- QByteArray priKey, pubKey;
|
|
- RSAC rsac;
|
|
-};
|
|
-
|
|
-
|
|
-#endif
|
|
diff --git a/src/widgets/authdialog.cpp b/src/widgets/authdialog.cpp
|
|
index e1934c1..2da300c 100644
|
|
--- a/src/widgets/authdialog.cpp
|
|
+++ b/src/widgets/authdialog.cpp
|
|
@@ -948,6 +948,7 @@ void AuthDialog::onPamAuthCompleted()
|
|
setUkeyTypeTip("");
|
|
authMode = UNKNOWN;
|
|
m_uCurLoginOptType = LOGINOPT_TYPE_PASSWORD;
|
|
+
|
|
Q_EMIT authSucceed(m_curUserInfo->name());
|
|
|
|
} else {
|