From 362888edb014dd0eacbb449e5ac103fe00af7d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E5=87=AF=E5=BC=BA?= <1144319010@qq.com> Date: Tue, 29 Oct 2024 10:02:46 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8Duid=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/src/main/java/io/mpms/util/UidUtil.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 proxy/src/main/java/io/mpms/util/UidUtil.java diff --git a/proxy/src/main/java/io/mpms/util/UidUtil.java b/proxy/src/main/java/io/mpms/util/UidUtil.java new file mode 100644 index 0000000..7248cbd --- /dev/null +++ b/proxy/src/main/java/io/mpms/util/UidUtil.java @@ -0,0 +1,65 @@ +package io.jpom.util; + +import cn.hutool.core.io.FileUtil; +import cn.jiangzeyin.common.JsonMessage; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.util.ArrayList; + +/** + * @author hzw + * @date 2023年07月04日 上午11:11 + */ + +@Slf4j +public class UidUtil { + static final String PASSWD_PATH = "/etc/passwd"; + + /** + * uid 获取用户名 + */ + public static String getUserNameByUid(String uid) { + File file = new File(PASSWD_PATH); + String userName = ""; + if (file.exists() && file.isFile()) { + ArrayList readPasswdFiles = FileUtil.readUtf8Lines(file, new ArrayList<>()); + for (String passwordItem : readPasswdFiles) { + if (passwordItem.contains(uid)) { + String[] passwordItemSplit = passwordItem.split(":"); + if (uid.equals(passwordItemSplit[2])) { + userName = passwordItemSplit[0]; + break; + } + } + } + } + if (userName.isEmpty()) { + userName = "NULL"; + } + return userName; + } + + public static String getAllUid() { + File file = new File(PASSWD_PATH); + JSONArray retArray = new JSONArray(); + String retString; + + if (file.exists() && file.isFile()) { + ArrayList readPasswdFiles = FileUtil.readUtf8Lines(file, new ArrayList<>()); + for (String passwordItem : readPasswdFiles) { + String[] items = passwordItem.split(":"); + JSONObject arrayItem = new JSONObject(); + arrayItem.put("username", items[0]); + arrayItem.put("uid", items[2]); + retArray.add(arrayItem); + } + retString = JsonMessage.getString(200, "查询成功", retArray); + } else { + retString = JsonMessage.getString(404, "passwd文件不存在"); + } + return retString; + } +} -- Gitee From 3ee1904225d287bcd893e3f97226468768c805c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E5=87=AF=E5=BC=BA?= <1144319010@qq.com> Date: Tue, 29 Oct 2024 10:13:51 +0800 Subject: [PATCH 02/11] =?UTF-8?q?Revert=20"=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8Duid=E8=8E=B7=E5=8F=96"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 362888edb014dd0eacbb449e5ac103fe00af7d24. --- proxy/src/main/java/io/mpms/util/UidUtil.java | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 proxy/src/main/java/io/mpms/util/UidUtil.java diff --git a/proxy/src/main/java/io/mpms/util/UidUtil.java b/proxy/src/main/java/io/mpms/util/UidUtil.java deleted file mode 100644 index 7248cbd..0000000 --- a/proxy/src/main/java/io/mpms/util/UidUtil.java +++ /dev/null @@ -1,65 +0,0 @@ -package io.jpom.util; - -import cn.hutool.core.io.FileUtil; -import cn.jiangzeyin.common.JsonMessage; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; - -import java.io.File; -import java.util.ArrayList; - -/** - * @author hzw - * @date 2023年07月04日 上午11:11 - */ - -@Slf4j -public class UidUtil { - static final String PASSWD_PATH = "/etc/passwd"; - - /** - * uid 获取用户名 - */ - public static String getUserNameByUid(String uid) { - File file = new File(PASSWD_PATH); - String userName = ""; - if (file.exists() && file.isFile()) { - ArrayList readPasswdFiles = FileUtil.readUtf8Lines(file, new ArrayList<>()); - for (String passwordItem : readPasswdFiles) { - if (passwordItem.contains(uid)) { - String[] passwordItemSplit = passwordItem.split(":"); - if (uid.equals(passwordItemSplit[2])) { - userName = passwordItemSplit[0]; - break; - } - } - } - } - if (userName.isEmpty()) { - userName = "NULL"; - } - return userName; - } - - public static String getAllUid() { - File file = new File(PASSWD_PATH); - JSONArray retArray = new JSONArray(); - String retString; - - if (file.exists() && file.isFile()) { - ArrayList readPasswdFiles = FileUtil.readUtf8Lines(file, new ArrayList<>()); - for (String passwordItem : readPasswdFiles) { - String[] items = passwordItem.split(":"); - JSONObject arrayItem = new JSONObject(); - arrayItem.put("username", items[0]); - arrayItem.put("uid", items[2]); - retArray.add(arrayItem); - } - retString = JsonMessage.getString(200, "查询成功", retArray); - } else { - retString = JsonMessage.getString(404, "passwd文件不存在"); - } - return retString; - } -} -- Gitee From 5366a39a16065bbe843a15a78522c32686bf6bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E5=87=AF=E5=BC=BA?= <1144319010@qq.com> Date: Tue, 29 Oct 2024 10:15:22 +0800 Subject: [PATCH 03/11] =?UTF-8?q?Revert=20"Revert=20"=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8Duid=E8=8E=B7=E5=8F=96""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3ee1904225d287bcd893e3f97226468768c805c0. --- proxy/src/main/java/io/mpms/util/UidUtil.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 proxy/src/main/java/io/mpms/util/UidUtil.java diff --git a/proxy/src/main/java/io/mpms/util/UidUtil.java b/proxy/src/main/java/io/mpms/util/UidUtil.java new file mode 100644 index 0000000..7248cbd --- /dev/null +++ b/proxy/src/main/java/io/mpms/util/UidUtil.java @@ -0,0 +1,65 @@ +package io.jpom.util; + +import cn.hutool.core.io.FileUtil; +import cn.jiangzeyin.common.JsonMessage; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.util.ArrayList; + +/** + * @author hzw + * @date 2023年07月04日 上午11:11 + */ + +@Slf4j +public class UidUtil { + static final String PASSWD_PATH = "/etc/passwd"; + + /** + * uid 获取用户名 + */ + public static String getUserNameByUid(String uid) { + File file = new File(PASSWD_PATH); + String userName = ""; + if (file.exists() && file.isFile()) { + ArrayList readPasswdFiles = FileUtil.readUtf8Lines(file, new ArrayList<>()); + for (String passwordItem : readPasswdFiles) { + if (passwordItem.contains(uid)) { + String[] passwordItemSplit = passwordItem.split(":"); + if (uid.equals(passwordItemSplit[2])) { + userName = passwordItemSplit[0]; + break; + } + } + } + } + if (userName.isEmpty()) { + userName = "NULL"; + } + return userName; + } + + public static String getAllUid() { + File file = new File(PASSWD_PATH); + JSONArray retArray = new JSONArray(); + String retString; + + if (file.exists() && file.isFile()) { + ArrayList readPasswdFiles = FileUtil.readUtf8Lines(file, new ArrayList<>()); + for (String passwordItem : readPasswdFiles) { + String[] items = passwordItem.split(":"); + JSONObject arrayItem = new JSONObject(); + arrayItem.put("username", items[0]); + arrayItem.put("uid", items[2]); + retArray.add(arrayItem); + } + retString = JsonMessage.getString(200, "查询成功", retArray); + } else { + retString = JsonMessage.getString(404, "passwd文件不存在"); + } + return retString; + } +} -- Gitee From f6ed54075ea285e86ab98182e4c470e32c9cf3c3 Mon Sep 17 00:00:00 2001 From: zywang <1144319010@qq.com> Date: Tue, 29 Oct 2024 10:48:43 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8Duid=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/src/main/java/io/mpms/util/UidUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/src/main/java/io/mpms/util/UidUtil.java b/proxy/src/main/java/io/mpms/util/UidUtil.java index 7248cbd..384a923 100644 --- a/proxy/src/main/java/io/mpms/util/UidUtil.java +++ b/proxy/src/main/java/io/mpms/util/UidUtil.java @@ -58,7 +58,7 @@ public class UidUtil { } retString = JsonMessage.getString(200, "查询成功", retArray); } else { - retString = JsonMessage.getString(404, "passwd文件不存在"); + retString = JsonMessage.getString(404, "文件不存在"); } return retString; } -- Gitee From 405879ccc5fa5260d9ac5e160e106f4e48aba4d1 Mon Sep 17 00:00:00 2001 From: zywang Date: Tue, 29 Oct 2024 02:59:36 +0000 Subject: [PATCH 05/11] =?UTF-8?q?Revert=20"=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8Duid=E8=8E=B7=E5=8F=96"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f6ed54075ea285e86ab98182e4c470e32c9cf3c3. --- proxy/src/main/java/io/mpms/util/UidUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/src/main/java/io/mpms/util/UidUtil.java b/proxy/src/main/java/io/mpms/util/UidUtil.java index 384a923..7248cbd 100644 --- a/proxy/src/main/java/io/mpms/util/UidUtil.java +++ b/proxy/src/main/java/io/mpms/util/UidUtil.java @@ -58,7 +58,7 @@ public class UidUtil { } retString = JsonMessage.getString(200, "查询成功", retArray); } else { - retString = JsonMessage.getString(404, "文件不存在"); + retString = JsonMessage.getString(404, "passwd文件不存在"); } return retString; } -- Gitee From 6cae08754d847cc507bb0617cbbf3fcdfca683cb Mon Sep 17 00:00:00 2001 From: zywang Date: Tue, 29 Oct 2024 02:59:58 +0000 Subject: [PATCH 06/11] =?UTF-8?q?Revert=20"Revert=20"=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8Duid=E8=8E=B7=E5=8F=96""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 405879ccc5fa5260d9ac5e160e106f4e48aba4d1. --- proxy/src/main/java/io/mpms/util/UidUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/src/main/java/io/mpms/util/UidUtil.java b/proxy/src/main/java/io/mpms/util/UidUtil.java index 7248cbd..384a923 100644 --- a/proxy/src/main/java/io/mpms/util/UidUtil.java +++ b/proxy/src/main/java/io/mpms/util/UidUtil.java @@ -58,7 +58,7 @@ public class UidUtil { } retString = JsonMessage.getString(200, "查询成功", retArray); } else { - retString = JsonMessage.getString(404, "passwd文件不存在"); + retString = JsonMessage.getString(404, "文件不存在"); } return retString; } -- Gitee From f6134b78091a0e3097a12858f7ca80e82fcf40c4 Mon Sep 17 00:00:00 2001 From: zywang <1144319010@qq.com> Date: Tue, 29 Oct 2024 11:00:39 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8Duid=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/src/main/java/io/mpms/util/UidUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/src/main/java/io/mpms/util/UidUtil.java b/proxy/src/main/java/io/mpms/util/UidUtil.java index 384a923..7248cbd 100644 --- a/proxy/src/main/java/io/mpms/util/UidUtil.java +++ b/proxy/src/main/java/io/mpms/util/UidUtil.java @@ -58,7 +58,7 @@ public class UidUtil { } retString = JsonMessage.getString(200, "查询成功", retArray); } else { - retString = JsonMessage.getString(404, "文件不存在"); + retString = JsonMessage.getString(404, "passwd文件不存在"); } return retString; } -- Gitee From 55893a09ca425ea1dbe375ee04d41282b2f61b30 Mon Sep 17 00:00:00 2001 From: zywang Date: Tue, 29 Oct 2024 03:03:38 +0000 Subject: [PATCH 08/11] =?UTF-8?q?Revert=20"=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8Duid=E8=8E=B7=E5=8F=96"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f6134b78091a0e3097a12858f7ca80e82fcf40c4. --- proxy/src/main/java/io/mpms/util/UidUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/src/main/java/io/mpms/util/UidUtil.java b/proxy/src/main/java/io/mpms/util/UidUtil.java index 7248cbd..384a923 100644 --- a/proxy/src/main/java/io/mpms/util/UidUtil.java +++ b/proxy/src/main/java/io/mpms/util/UidUtil.java @@ -58,7 +58,7 @@ public class UidUtil { } retString = JsonMessage.getString(200, "查询成功", retArray); } else { - retString = JsonMessage.getString(404, "passwd文件不存在"); + retString = JsonMessage.getString(404, "文件不存在"); } return retString; } -- Gitee From 7caeb67cfa4791c837642006fe0e3464166990df Mon Sep 17 00:00:00 2001 From: zywang <15700683392> Date: Tue, 29 Oct 2024 11:07:21 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8Duid=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/src/main/java/io/mpms/util/UidUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/src/main/java/io/mpms/util/UidUtil.java b/proxy/src/main/java/io/mpms/util/UidUtil.java index 384a923..7248cbd 100644 --- a/proxy/src/main/java/io/mpms/util/UidUtil.java +++ b/proxy/src/main/java/io/mpms/util/UidUtil.java @@ -58,7 +58,7 @@ public class UidUtil { } retString = JsonMessage.getString(200, "查询成功", retArray); } else { - retString = JsonMessage.getString(404, "文件不存在"); + retString = JsonMessage.getString(404, "passwd文件不存在"); } return retString; } -- Gitee From 312bf3d8428cbeae7e9044612bfac0fac87a93d2 Mon Sep 17 00:00:00 2001 From: zywang Date: Tue, 29 Oct 2024 11:26:29 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/mpms/util/SystemUtils.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 proxy/src/main/java/io/mpms/util/SystemUtils.java diff --git a/proxy/src/main/java/io/mpms/util/SystemUtils.java b/proxy/src/main/java/io/mpms/util/SystemUtils.java new file mode 100644 index 0000000..e76570a --- /dev/null +++ b/proxy/src/main/java/io/mpms/util/SystemUtils.java @@ -0,0 +1,27 @@ +package io.jpom.util; + +import com.alibaba.fastjson.JSONObject; +import io.jpom.common.BaseFileOpr; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SystemUtils { + + + public JSONObject getVersion() { + JSONObject rel = new JSONObject(); + String system = BaseFileOpr.getFileContent("/etc/issue"); + String kernel = BaseFileOpr.getFileContent("/proc/version"); + + if (!system.isEmpty()) { + rel.put("system", system.replaceAll("\\\\n", "").replaceAll("\\\\l", "").replaceAll("\\n", "").replaceAll("\0", "")); + } + + if (!kernel.isEmpty()) { + rel.put("kernel", kernel.replaceAll("\\n", "").replaceAll("\0", "")); + } + + return rel; + } + +} -- Gitee From b3cae9daa59e53feeac9d0d73db6cd6d42197cfd Mon Sep 17 00:00:00 2001 From: zywang Date: Tue, 29 Oct 2024 13:30:03 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/src/main/java/io/mpms/util/SystemUtils.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/proxy/src/main/java/io/mpms/util/SystemUtils.java b/proxy/src/main/java/io/mpms/util/SystemUtils.java index e76570a..cba5f79 100644 --- a/proxy/src/main/java/io/mpms/util/SystemUtils.java +++ b/proxy/src/main/java/io/mpms/util/SystemUtils.java @@ -6,22 +6,16 @@ import org.springframework.context.annotation.Configuration; @Configuration public class SystemUtils { - - public JSONObject getVersion() { JSONObject rel = new JSONObject(); String system = BaseFileOpr.getFileContent("/etc/issue"); String kernel = BaseFileOpr.getFileContent("/proc/version"); - if (!system.isEmpty()) { rel.put("system", system.replaceAll("\\\\n", "").replaceAll("\\\\l", "").replaceAll("\\n", "").replaceAll("\0", "")); } - if (!kernel.isEmpty()) { rel.put("kernel", kernel.replaceAll("\\n", "").replaceAll("\0", "")); } - return rel; } - } -- Gitee