diff --git a/data/DBus/SystemBus/dbus_limit.py b/data/DBus/SystemBus/dbus_limit.py new file mode 100644 index 0000000..fd79c72 --- /dev/null +++ b/data/DBus/SystemBus/dbus_limit.py @@ -0,0 +1,91 @@ +import subprocess +import os +import sys +import shutil + +def remove_file(file_path): + if os.path.exists(file_path): + os.remove(file_path) + #print(f"文件 {file_path} 已被删除") + + +def copy_file(source_path, backup_path): + try: + shutil.copy2(source_path, backup_path) + #print(f"文件已成功从 {source_path} 复制到 {backup_path}") + except IOError as e: + print(f"文件复制失败: {e}") + + + +def add_limit(limit_file): + data_to_write =f"""[servicecontrol] +status=off +""" + with open(limit_file, 'w') as file: + file.write(data_to_write) + +def popen_exec(command): + #print(f"command: {command}") + process = subprocess.Popen(command, stdout=subprocess.PIPE) + stdout, stderr = process.communicate() + stdout_str = stdout.decode('utf-8') + return stdout_str + +def calc_verify(limit_file,arch): + calc_prog_path=f"{os.getcwd()}/../data/DBus/SystemBus/calc_verify_{arch}" + absolute_path = os.path.abspath(calc_prog_path) + command = [absolute_path,limit_file] + verify=popen_exec(command) + #print(f"verify:{verify}") + with open(f"{limit_file}.verify", 'w') as file: + file.write(verify) + return + +def bakup_limit(dbusname,arch): + try: + limit_file="/etc/dbus-1/conf/"+dbusname+".limit" + bak_limit_file=limit_file+".bak" + verify_file="/etc/dbus-1/conf/"+dbusname+".limit.verify" + bak_verify_file=verify_file+".bak" + tmp_limit_file=limit_file+".tmp" + tmp_verify_file=tmp_limit_file+".verify" + if (not os.path.isfile(bak_limit_file)) and (not os.path.isfile(bak_verify_file)) and os.path.isfile(limit_file) and os.path.isfile(verify_file): + copy_file(limit_file,bak_limit_file) + copy_file(verify_file,bak_verify_file) + #prog_path=os.getcwd()+"/../data/DBus/SystemBus/system_bus_check.py" + #absolute_path = os.path.abspath(prog_path) + #print(f"absolute_path={absolute_path}") + add_limit(tmp_limit_file) + calc_verify(tmp_limit_file,arch) + copy_file(tmp_verify_file,verify_file) + copy_file(tmp_limit_file,limit_file) + remove_file(tmp_verify_file) + remove_file(tmp_limit_file) + + except Exception as e: + print(f"bakup_limit failed: {e}") + +def restore_limit(dbusname,arch): + try: + limit_file="/etc/dbus-1/conf/"+dbusname+".limit" + bak_limit_file=limit_file+".bak" + verify_file="/etc/dbus-1/conf/"+dbusname+".limit.verify" + bak_verify_file=verify_file+".bak" + if os.path.isfile(bak_limit_file) and os.path.isfile(bak_verify_file): + copy_file(bak_verify_file,verify_file) + copy_file(bak_limit_file,limit_file) + remove_file(bak_limit_file) + remove_file(bak_verify_file) + except Exception as e: + print(f"restore_limit failed: {e}") + + +if __name__ == '__main__': + if len(sys.argv) <= 3: + print('\n%s -h for help.' % (sys.argv[0])) + exit(0) + if sys.argv[1] == "bakup": + bakup_limit(sys.argv[2],sys.argv[3]) + elif sys.argv[1] == "restore": + restore_limit(sys.argv[2],sys.argv[3]) \ No newline at end of file diff --git a/data/DBus/SystemBus/kylin_system_bus_list.yaml b/data/DBus/SystemBus/kylin_system_bus_list.yaml new file mode 100644 index 0000000..bfe4010 --- /dev/null +++ b/data/DBus/SystemBus/kylin_system_bus_list.yaml @@ -0,0 +1,47 @@ +FormatVer: 20240508 +ListNames: + - org.ukui.GreeterDaemon + - com.kylin.file.system.fuse + - com.ukui.search.qt.systemdbus + - com.kylin.network.enhancement.optimization + - com.kylin.screen.rotation + - com.settings.daemon.qt.systemdbus + - org.ukui.powermanagement + - com.miracast.uibcctl + - com.kylin.systemupgrade + - com.kylin.daq + - com.ksc.virus + - org.freedesktop.activation + - org.ukui.Biometric + - org.ukui.libinput.proxy + - com.kysec.auth + - com.kylin.software.properties + - com.kylin.secriskbox + - com.kylin.system.proxy + - com.kylin.kydevmonit.domainhook + - com.kylin.UpgradeStrategies + - com.ukui.bluetooth + - com.kylin.backupserver + - com.kylin.backup + - com.kylin.ProcessManagerDaemon + - org.freedesktop.miracle.wifi + - com.kylin-os-manager + - com.ksc.scan + - com.kylin.connectivity.manager + - com.kylin.preinstall + - com.ksc.kysdkinit + - com.kylin.boxmanage + - com.kylin.logview + - com.kylin.network.qt.systemdbus + - com.kylin.os.manager.sessionbus + - com.kylin.os.manager.systembus + - com.kylinusbcreator.systemdbus + - org.ukui.groupmanager + - org.ukui.KSplash + - org.ukui.samba.share.config + - com.kylin.kim.backend + - com.ksc.defender + - com.drivermanager.USBMonitor + - com.control.center.qt.systemdbus + - com.kylin.kydoctor + - com.kylin.kysdk.conf2 \ No newline at end of file