Browse Source

Add enter system password,applied to different user systems

dongjunhong 2 months ago
parent
commit
a2257bb76a

+ 15 - 2
src/tool/tool_getLicense/mainwindow.cpp

@@ -15,7 +15,15 @@ MainWindow::MainWindow(QWidget *parent)
         std::string scode = text.toStdString();
         if (scode=="catarcshenlanv2pro")
         {
-            ui->setupUi(this);
+            bool code_ok;
+            sys_code = QInputDialog::getText(this, tr("Enter system password:"),
+                                             tr("system password:"), QLineEdit::Password,
+                                             Q_NULLPTR, &code_ok);
+            if (code_ok && !sys_code.isEmpty())
+            {
+                ui->setupUi(this);
+            }
+
         }
     }
 
@@ -32,7 +40,11 @@ void MainWindow::on_pushButton_clicked()
 void MainWindow::on_pushButton_2_clicked()
 {
     QProcess process;
-    QString command="echo 'nvidia' | sudo -S blkid";
+    QString command="echo '"+sys_code+"' | sudo -S blkid";
+    if (command.isEmpty())
+    {
+        qDebug()<<"system password error";
+    }
     process.start("/bin/bash", QStringList() << "-c" << command);
     process.waitForFinished();
     QString output=process.readAllStandardOutput();
@@ -55,6 +67,7 @@ void MainWindow::on_pushButton_2_clicked()
        diskid=subStr;
     } else {
        qDebug() << "UUID not found.";
+       return;
     }
     QString final_license="catarc"+diskid+"shenlanv2pro";
     QString hashedStr=hashString(final_license);

+ 1 - 0
src/tool/tool_getLicense/mainwindow.h

@@ -26,6 +26,7 @@ private slots:
 
 private:
     Ui::MainWindow *ui;
+    QString sys_code;
     QString hashString(const QString &str) {
         QString strippedStr = str;
         strippedStr.remove(QChar('-'));

+ 2 - 2
src/tool/tool_getLicense/tool_getLicense.pro

@@ -3,8 +3,8 @@ QT       += core gui
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
 CONFIG += c++11
-
-
+QMAKE_LFLAGS += -no-pie
+CONFIG -= app_bundle
 # The following define makes your compiler emit warnings if you use
 # any Qt feature that has been marked deprecated (the exact warnings
 # depend on your compiler). Please consult the documentation of the