diff --git a/0001-format-code.patch b/0001-format-code.patch new file mode 100644 index 0000000000000000000000000000000000000000..b1db6131ad6a00dff9dec877722f0e63c08f7a3a --- /dev/null +++ b/0001-format-code.patch @@ -0,0 +1,119 @@ +From 8dbd8088e6895367eb09f3a01389a6ebe3ce9feb Mon Sep 17 00:00:00 2001 +From: FanSheng Meng +Date: Mon, 16 Oct 2023 14:07:46 +0800 +Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81=E6=A0=BC?= + =?UTF-8?q?=E5=BC=8F?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + .../centos7/openeuler/centos72openeuler.py | 6 ++---- + views/migration.py | 11 +++++++---- + 2 files changed, 9 insertions(+), 8 deletions(-) + +diff --git a/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py b/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py +index 05a444c..7ccdb44 100644 +--- a/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py ++++ b/ut-Migration-tools-0.1/centos7/openeuler/centos72openeuler.py +@@ -28,7 +28,6 @@ def run_subprocess(cmd): + print(output) # Print the output to console + return output, process.returncode + except subprocess.CalledProcessError as e: +- #print(f"Command '{e.cmd}' failed with return code {e.returncode}.") + print(e.stderr) # Print the error output to console + return e.stderr, e.returncode + +@@ -87,6 +86,7 @@ def add_boot_option(): + except Exception as e: + print(e) + ++ + def swap_release(release): + tmp_dir = '/var/tmp' + rpme_release = 'rpm -qf /etc/os-release | xargs -i rpm -e --nodeps {}' +@@ -163,6 +163,7 @@ def system_sync(): + return False + return True + ++ + def main(): + if not check_pkg("yum-utils"): + print("please install yum-utils") +@@ -187,7 +188,6 @@ def main(): + with open(repofile, 'w') as f: + f.write(openeuler_repo) + +- + openEuler_release = 'openEuler-release' + if not check_pkg(openEuler_release): + print("swaping release") +@@ -240,7 +240,6 @@ def main(): + print("Removing confilct package yum...") + system_sync() + +- + # boot cui + print("set boot target to cui") + cmd = 'systemctl set-default multi-user.target' +@@ -263,6 +262,5 @@ def main(): + os.system("reboot") + + +- + if __name__ == '__main__': + main() +diff --git a/views/migration.py b/views/migration.py +index 1312d33..477627b 100644 +--- a/views/migration.py ++++ b/views/migration.py +@@ -1,12 +1,11 @@ + # SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. + # SPDX-License-Identifier: MulanPubL-2.0-or-later +- +-from flask import * + import os +- ++from flask import * + from client_requests import * + from func.utils import * + ++ + def check_services(data, url): + info = post_client_data(data, url) + if info is None or info.status_code != 200: +@@ -27,26 +26,30 @@ def check_os(data): + if services: + return services + ++ + def check_storage(data): + services = check_services(data, '/check_storage') + if services: + return services + ++ + def close_tool(data): + os.system('kill -9 `ps -ef | grep "start_webview.py" | grep -v grep | awk \'{print $2}\'`') + data = {"ip": "0.0.0.0"} + data_json = json.dumps(data) + return data_json + ++ + def check_user(data): + services = check_services(data, '/check_user') + if services: + json_data = json.loads(data) +- with open('/usr/lib/migration-tools-server/.passwd.txt','w',encoding='utf-8') as f: ++ with open('/usr/lib/migration-tools-server/.passwd.txt', 'w', encoding='utf-8') as f: + text = json_data['passwd'] + f.write(text) + return services + ++ + def check_repo(data): + services = check_services(data, '/check_repo') + if services: +-- +2.20.1 + diff --git a/0001-use-kill-not-kill-INT-when-stop-service.patch b/0001-use-kill-not-kill-INT-when-stop-service.patch deleted file mode 100644 index d5136536511ebc42462e69dc79d1e2e00c738e79..0000000000000000000000000000000000000000 --- a/0001-use-kill-not-kill-INT-when-stop-service.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 192fd69de19a78afe81a5a2c5a8270057f12ee3d Mon Sep 17 00:00:00 2001 -From: lixin -Date: Mon, 18 Mar 2024 10:32:17 +0800 -Subject: [PATCH] use kill instead of kill-INT - ---- - server/migration-tools-server.service | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/server/migration-tools-server.service b/server/migration-tools-server.service -index 8cd53a3..dd16c95 100644 ---- a/server/migration-tools-server.service -+++ b/server/migration-tools-server.service -@@ -5,7 +5,7 @@ After=network-online.target - [Service] - Type=simple - ExecStart=/usr/bin/python3 /usr/lib/migration-tools-server/index.py --ExecStop=/bin/kill-INT $MAINPID -+ExecStop=/bin/kill -HUP $MAINPID - - [Install] - WantedBy=multi-user.target --- -2.41.0 - diff --git a/0002-modify-description.patch b/0002-modify-description.patch deleted file mode 100644 index 3a0f836fb4f87a5d8db8a5945dd1b03c8a69b9c9..0000000000000000000000000000000000000000 --- a/0002-modify-description.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 52c434875d1cda64d0abd96e115001ffef0d2cc5 Mon Sep 17 00:00:00 2001 -From: lixin -Date: Mon, 1 Apr 2024 11:04:00 +0800 -Subject: [PATCH] modify-description - ---- - templates/MT_agreement.html | 2 +- - templates/MT_migration_results.html | 2 +- - templates/MT_note.html | 12 +++++++----- - 3 files changed, 9 insertions(+), 7 deletions(-) - -diff --git a/templates/MT_agreement.html b/templates/MT_agreement.html -index be70ca8..d15a399 100755 ---- a/templates/MT_agreement.html -+++ b/templates/MT_agreement.html -@@ -26,7 +26,7 @@ -
- 欢迎使用统信服务器系统迁移软件。 -
-- 此迁移工具用于将【当前操作系统】替换为【统信服务器操作系统 V20】,并将 RPM 软件包替换为统信的 RPM 软件包。 -+ 此迁移工具用于将【当前操作系统】替换为【openEuler-20.03-LTS-SP1或统信服务器操作系统】,并将 RPM 软件包替换为统信的 RPM 软件包。 - - 协议许可: -
-diff --git a/templates/MT_migration_results.html b/templates/MT_migration_results.html -index 3ff802b..fef5292 100755 ---- a/templates/MT_migration_results.html -+++ b/templates/MT_migration_results.html -@@ -35,6 +35,7 @@ -
-
- -+

注意:(openEuler系统迁移暂不支持导出日志/报告功能)

-
-
-
-@@ -88,7 +89,6 @@ -
-
-
-- -
- - -diff --git a/templates/MT_note.html b/templates/MT_note.html -index 099523b..1a79009 100755 ---- a/templates/MT_note.html -+++ b/templates/MT_note.html -@@ -33,11 +33,13 @@ -
-

1. 迁移一旦开始,过程不可逆。请确保您已将系统的数据与设置进行【完整备份】。

-

2. 迁移前请获得管理员许可,再进行迁移工作。

--

3. 请提前获取【统信服务器操作系统 V20 】的软件仓库地址。

--

4. 迁移过程中请保证稳定的网络连接。

--

5. 迁移过程中请不要进行任何操作。

--

6. 该迁移工具目前仅支持 CentOS 7 / CentOS 8 操作系统。

--

7. 请确保在 '/var/cache' 中至少有 10GB 的可用空间。

-+

3. openEuler系统迁移目前仅支持centos7.4-7.6 cui迁移至openEuler-20.03-LTS-SP1

-+

3. openEuler系统迁移无需填写软件源

-+

4. 如需迁移UOS系统,请提前准备【统信服务器操作系统 V20 】的软件仓库地址。

-+

5. 迁移过程中请保证稳定的网络连接。

-+

6. 迁移过程中请不要进行任何操作。

-+

7. 该迁移工具目前仅支持 CentOS 7 / CentOS 8 操作系统。

-+

8. 请确保在 '/var/cache' 中至少有 10GB 的可用空间。

-
-
-
--- -2.43.0 - diff --git a/0003-adjust-the-display-sequence.patch b/0003-adjust-the-display-sequence.patch deleted file mode 100644 index 17b127012d179f904f64c6c9c20aec5e8560f834..0000000000000000000000000000000000000000 --- a/0003-adjust-the-display-sequence.patch +++ /dev/null @@ -1,26 +0,0 @@ -From ae5f25582a87a84cbc33914c27ab66e358ca271f Mon Sep 17 00:00:00 2001 -From: lixin -Date: Tue, 2 Apr 2024 17:13:01 +0800 -Subject: [PATCH] adjust the display sequence - ---- - templates/MT_check_root.html | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/templates/MT_check_root.html b/templates/MT_check_root.html -index eb4dc3f..cb5d346 100755 ---- a/templates/MT_check_root.html -+++ b/templates/MT_check_root.html -@@ -55,8 +55,8 @@ - -
- -
- --- -2.43.0 - diff --git a/0004-fix-cancel-button-function-in-tool.patch b/0004-fix-cancel-button-function-in-tool.patch deleted file mode 100644 index ab7b5e1d3622a529400f5d66c436bd80d8d1a249..0000000000000000000000000000000000000000 --- a/0004-fix-cancel-button-function-in-tool.patch +++ /dev/null @@ -1,155 +0,0 @@ -From 0878a6820be950685d5c79abe8a655b2734b4534 Mon Sep 17 00:00:00 2001 -From: lihaipeng -Date: Tue, 27 Aug 2024 15:27:38 +0800 -Subject: [PATCH 2/2] fix-cancel-button-function-in-tool - ---- - templates/MT_agreement.html | 6 +++--- - templates/MT_check_evn.html | 8 ++++---- - templates/MT_check_root.html | 4 ++-- - templates/MT_kernel.html | 4 ++-- - templates/MT_note.html | 4 ++-- - templates/MT_repo.html | 4 ++-- - 6 files changed, 15 insertions(+), 15 deletions(-) - -diff --git a/templates/MT_agreement.html b/templates/MT_agreement.html -index d15a399..40150bf 100755 ---- a/templates/MT_agreement.html -+++ b/templates/MT_agreement.html -@@ -86,7 +86,7 @@ -
-
- -- -+ - 下一步 -
- -@@ -119,8 +119,8 @@ - }); - - function close_tool() { -- alert("确定关闭迁移软件吗?") -- } -+ alert("确定关闭迁移软件吗?") -+ } - - - -diff --git a/templates/MT_check_evn.html b/templates/MT_check_evn.html -index fe9c8d8..47b2029 100755 ---- a/templates/MT_check_evn.html -+++ b/templates/MT_check_evn.html -@@ -52,7 +52,7 @@ -
-
-
-- -+ - - - -@@ -131,9 +131,9 @@ - window.location.href="MT_check_user" - } - -- function close_tool() { -- alert("确定关闭迁移软件吗?"); -- } -+ function close_tool() { -+ window.location.href="MT_note" -+ } - - - -diff --git a/templates/MT_check_root.html b/templates/MT_check_root.html -index cb5d346..5e4ce52 100755 ---- a/templates/MT_check_root.html -+++ b/templates/MT_check_root.html -@@ -72,7 +72,7 @@ -
-
-
-- -+ - - - -@@ -122,7 +122,7 @@ - } - - function close_tool() { -- alert("确定关闭迁移软件吗?"); -+ window.location.href="MT_check_env" - } - - $("#uname_id").bind("input propertychange",function(event){ -diff --git a/templates/MT_kernel.html b/templates/MT_kernel.html -index e8b93c8..9553bc6 100755 ---- a/templates/MT_kernel.html -+++ b/templates/MT_kernel.html -@@ -53,7 +53,7 @@ -
-
-
-- -+ - - - -@@ -115,7 +115,7 @@ - - - function close_tool() { -- alert("确定关闭迁移软件吗?"); -+ window.location.href="MT_repo" - } - - -diff --git a/templates/MT_note.html b/templates/MT_note.html -index 1a79009..2da1294 100755 ---- a/templates/MT_note.html -+++ b/templates/MT_note.html -@@ -48,7 +48,7 @@ -
-
-
-- -+ - - - -@@ -75,7 +75,7 @@ - } - - function close_tool() { -- alert("确定关闭迁移软件吗?"); -+ window.location = '/MT_agreement'; - } - - -diff --git a/templates/MT_repo.html b/templates/MT_repo.html -index 2c145af..c5fa384 100755 ---- a/templates/MT_repo.html -+++ b/templates/MT_repo.html -@@ -54,7 +54,7 @@ -
-
-
-- -+ - -
- -@@ -102,7 +102,7 @@ - } - - function close_tool() { -- alert("确定关闭迁移软件吗"); -+ window.location.href="MT_check_user" - } - - $("#repo_pwd").bind("input propertychange",function(event){ --- -2.43.0 - diff --git a/100-CVE-2024-24892.patch b/100-CVE-2024-24892.patch deleted file mode 100644 index 25ac45aff0ff5d3adc5f0bb9f076706ef0a28d51..0000000000000000000000000000000000000000 --- a/100-CVE-2024-24892.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 27f65f5c5e38b6d0cee28db3591784266a47de9e Mon Sep 17 00:00:00 2001 -From: lixin -Date: Tue, 12 Mar 2024 10:42:07 +0800 -Subject: [PATCH] CVE-2024-24892 - ---- - index.py | 50 ++++++++++++++++++++++++++++++++------------------ - 1 file changed, 32 insertions(+), 18 deletions(-) - -diff --git a/index.py b/index.py -index 239148e..f604fc2 100644 ---- a/index.py -+++ b/index.py -@@ -4,6 +4,7 @@ - # SPDX-License-Identifier: MulanPubL-2.0-or-later - import os - import json -+import paramiko - from func import share - from urls import server_mods - from flask import Flask, render_template, request, Response -@@ -202,29 +203,42 @@ def export_migration_reports(): - :return: - """ - mod = check_methods() -- f = open("/usr/lib/migration-tools-server/.passwd.txt", "r") -- password = f.read() -- f.close() - if mod: - data = request.get_data() - json_data = json.loads(data) -- mkdir_log_pwd = "/var/uos-migration/" -- isExists=os.path.exists(mkdir_log_pwd) -- if not isExists: -- try: -- os.makedirs(mkdir_log_pwd) -- print(mkdir_log_pwd) -- except: -- print("export report mkdir error:%s" % mkdir_log_pwd) -- -+ user = json_data.get('info').split("|")[0] - info = mod.split(',') -- scp_log = "sshpass -p '%s'" % password + " scp -r %s" % json_data.get('info').split("|")[0] + "@%s" % info[1] \ -- + ":/var/tmp/uos-migration/UOS*.tar.gz /var/uos-migration/" -+ ip = info[1].strip('"') -+ port = 22 -+ -+ with open("/usr/lib/migration-tools-server/.passwd.txt", "r") as f: -+ password = f.read() -+ -+ remote_dir = local_dir = "/var/tmp/uos-migration" -+ if not os.path.exists(local_dir): -+ os.makedirs(local_dir) -+ -+ client = paramiko.SSHClient() -+ client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - try: -- os.system(scp_log) -- print(scp_log) -- except: -- print('export report scp error:%s' % scp_log) -+ client.connect(ip, port, user, password) -+ sftp = client.open_sftp() -+ -+ remote_files = sftp.listdir(remote_dir) -+ # 遍历远程文件列表 -+ for filename in remote_files: -+ if filename.endswith('.tar.gz'): -+ remote_file_path = os.path.join(remote_dir, filename) -+ local_file_path = os.path.join(local_dir, filename) -+ sftp.get(remote_file_path, local_file_path) -+ -+ except Exception as e: -+ print(f"Error: {e}") -+ -+ finally: -+ # 关闭连接 -+ if client: -+ client.close() - return Response(mod, content_type='application/json') - - --- -2.41.0 - diff --git a/migration-tools.spec b/migration-tools.spec index 66784406e5cc3d7cc7adb74c2408a340109edbb0..ebd785d211dc1620fc53bb4e58035a4e42d5ab69 100644 --- a/migration-tools.spec +++ b/migration-tools.spec @@ -1,19 +1,13 @@ Name: migration-tools -Version: 1.0.1 -Release: 7 +Version: 1.0.2 +Release: 1 License: MulanPSL-2.0 Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system Source0: migration-tools.tar.gz Source1: requires.tar.gz Source2: xlwt-1.3.0-py2.py3-none-any.whl # patches -Patch0: 0001-use-kill-not-kill-INT-when-stop-service.patch -Patch1: 0002-modify-description.patch -Patch2: 0003-adjust-the-display-sequence.patch -Patch3: 0004-fix-cancel-button-function-in-tool.patch - -# CVE patches: >= 100 -Patch100: 100-CVE-2024-24892.patch +Patch0: 0001-format-code.patch BuildArch: noarch BuildRequires: systemd @@ -57,12 +51,9 @@ Migration software server side %setup -c %patch 0 -p1 -%patch 1 -p1 -%patch 2 -p1 -%patch 3 -p1 -%patch 100 -p1 %if 0%{?openEuler} +mkdir agent-requires cp -f %SOURCE1 agent-requires/ cp -f %SOURCE2 agent-requires/ %endif @@ -83,7 +74,7 @@ cp -r * $RPM_BUILD_ROOT/usr/lib/migration-tools-agent/ %endif # Install server config -%{__cp} -r $RPM_BUILD_ROOT/usr/lib/migration-tools-server/server/migration-tools.conf $RPM_BUILD_ROOT/etc/migration-tools +%{__cp} -r $RPM_BUILD_ROOT/usr/lib/migration-tools-server/server/uos-sysmig.conf $RPM_BUILD_ROOT/etc/migration-tools %{__cp} -r $RPM_BUILD_ROOT/usr/lib/migration-tools-server/server/migration-tools-server.service $RPM_BUILD_ROOT%{_unitdir} %posttrans @@ -115,6 +106,9 @@ rm -rf /usr/bin/migration-tools %endif %changelog +* Thu Oct 31 2024 xuezhixin - 1.0.2-1 +- add 0001-stander-code.patch + * Tue Aug 27 2024 lihaipeng - 1.0.1-7 - fix cancel button function in tool diff --git a/migration-tools.tar.gz b/migration-tools.tar.gz index 6ec73170fe4685e25f170c1d7dd4dcffd1e6c99f..c5ad89c6b2cadfe67f530090f7395c08e0cd588a 100644 Binary files a/migration-tools.tar.gz and b/migration-tools.tar.gz differ