diff --git a/ukuisearch-systemdbus/sysdbusregister.cpp b/ukuisearch-systemdbus/sysdbusregister.cpp index 9a811a8..6b538b4 100644 --- a/ukuisearch-systemdbus/sysdbusregister.cpp +++ b/ukuisearch-systemdbus/sysdbusregister.cpp @@ -23,12 +23,10 @@ #include #include #include +#include SysdbusRegister::SysdbusRegister() { -// mHibernateFile = "/etc/systemd/sleep.conf"; -// mHibernateSet = new QSettings(mHibernateFile, QSettings::IniFormat, this); -// mHibernateSet->setIniCodec("UTF-8"); } SysdbusRegister::~SysdbusRegister() @@ -39,39 +37,20 @@ void SysdbusRegister::exitService() { qApp->exit(0); } -//QString SysdbusRegister::GetComputerInfo() { -// QByteArray ba; -// FILE * fp = NULL; -// char cmd[128]; -// char buf[1024]; -// sprintf(cmd, "dmidecode -t system"); +/* + * + * sprintf(cmd, "echo 9999999 | sudo tee -a /proc/sys/fs/inotify/max_user_watches"); + * sprintf(cmd, "sysctl -w fs.inotify.max_user_watches=\"9999999\""); + * sprintf(cmd, "echo fs.inotify.max_user_watches=9999999 | sudo tee -a /etc/sysctl.conf"); +*/ -// if ((fp = popen(cmd, "r")) != NULL){ -// rewind(fp); -// while (!feof(fp)) { -// fgets(buf, sizeof (buf), fp); -// ba.append(buf); -// } -// pclose(fp); -// fp = NULL; -// } -// return QString(ba); -//} - -QString SysdbusRegister::setInotifyMaxUserWatches5() +QString SysdbusRegister::setInotifyMaxUserWatchesStep1() { -// QString cmd; -//// cmd = QString("echo 9999999 | sudo tee -a /proc/sys/fs/inotify/max_user_watches"); -// cmd = QString("reboot"); -// QProcess p; -// p.start(cmd); -// return 123; QByteArray ba; FILE * fp = NULL; char cmd[128]; char buf[1024]; sprintf(cmd, "echo 9999999 | sudo tee -a /proc/sys/fs/inotify/max_user_watches"); - if ((fp = popen(cmd, "r")) != NULL){ rewind(fp); while (!feof(fp)) { @@ -81,46 +60,58 @@ QString SysdbusRegister::setInotifyMaxUserWatches5() pclose(fp); fp = NULL; } + else{ + return QString("popen open failed"); + } return QString(ba); } -////获取免密登录状态 -//QString SysdbusRegister::getNoPwdLoginStatus(){ -// QByteArray ba; -// FILE * fp = NULL; -// char cmd[128]; -// char buf[1024]; -// sprintf(cmd, "cat /etc/group |grep nopasswdlogin"); -// if ((fp = popen(cmd, "r")) != NULL){ -// rewind(fp); -// fgets(buf, sizeof (buf), fp); -// ba.append(buf); -// pclose(fp); -// fp = NULL; -// }else{ -// qDebug()<<"popen文件打开失败"< autoSettings = QSharedPointer(new QSettings(filename, QSettings::IniFormat)); @@ -143,19 +134,9 @@ QString SysdbusRegister::setInotifyMaxUserWatches5() // return time; //} -//void SysdbusRegister::setSuspendThenHibernate(QString time) { -// mHibernateSet->beginGroup("Sleep"); - -// mHibernateSet->setValue("HibernateDelaySec", time); - -// mHibernateSet->endGroup(); -// mHibernateSet->sync(); -//} - //void SysdbusRegister::setPasswdAging(int days, QString username) { // QString cmd; // cmd = QString("chage -M %1 %2").arg(days).arg(username); -//// cmd = QString("reboot"); // QProcess::execute(cmd); //} diff --git a/ukuisearch-systemdbus/sysdbusregister.h b/ukuisearch-systemdbus/sysdbusregister.h index 9cbf83b..2483fe1 100644 --- a/ukuisearch-systemdbus/sysdbusregister.h +++ b/ukuisearch-systemdbus/sysdbusregister.h @@ -50,7 +50,9 @@ public slots: Q_SCRIPTABLE void exitService(); // Q_SCRIPTABLE QString GetComputerInfo(); - Q_SCRIPTABLE QString setInotifyMaxUserWatches5(); + Q_SCRIPTABLE QString setInotifyMaxUserWatchesStep1(); + Q_SCRIPTABLE QString setInotifyMaxUserWatchesStep2(); + Q_SCRIPTABLE QString setInotifyMaxUserWatchesStep3(); // // 设置免密登录状态 // Q_SCRIPTABLE void setNoPwdLoginStatus();