From 5f22a5e3faf404e0a32a267c7433ad849e9f0bed Mon Sep 17 00:00:00 2001 From: chenxinquan Date: Thu, 16 Nov 2023 15:43:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9F=BA=E7=BA=BF=E6=89=AB?= =?UTF-8?q?=20=E6=8F=8F=E9=A1=B9'97=E5=85=B3=E9=97=AD=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=BF=A1=E4=BB=BB=E6=9C=BA=E5=88=B6rhosts'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\273\273\346\234\272\345\210\266rhosts.py" | 71 +++++++++++++++++++ ...73\273\346\234\272\345\210\266rhosts.yaml" | 22 ++++++ 2 files changed, 93 insertions(+) create mode 100755 "data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/97/97\345\205\263\351\227\255\347\263\273\347\273\237\344\277\241\344\273\273\346\234\272\345\210\266rhosts.py" create mode 100755 "data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/97/97\345\205\263\351\227\255\347\263\273\347\273\237\344\277\241\344\273\273\346\234\272\345\210\266rhosts.yaml" diff --git "a/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/97/97\345\205\263\351\227\255\347\263\273\347\273\237\344\277\241\344\273\273\346\234\272\345\210\266rhosts.py" "b/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/97/97\345\205\263\351\227\255\347\263\273\347\273\237\344\277\241\344\273\273\346\234\272\345\210\266rhosts.py" new file mode 100755 index 0000000..99da8ff --- /dev/null +++ "b/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/97/97\345\205\263\351\227\255\347\263\273\347\273\237\344\277\241\344\273\273\346\234\272\345\210\266rhosts.py" @@ -0,0 +1,71 @@ + +import os +import sys + +################################ +# 常量 + +# for get_env_lang() +STR_GET_ENV_LANG_ZH = "语言环境为中文" +STR_GET_ENV_LANG_EN = "语言环境为英文" +STR_GET_ENV_LANG_UNKNOW = "语言环境未知" + +################################ +# 环境检查函数 + +def get_env_lang(): +# lang = os.getenv("LANG") +# if lang.startswith("zh"): +# return STR_GET_ENV_LANG_ZH +# elif lang.startswith("en"): +# return STR_GET_ENV_LANG_EN +# else: +# return STR_GET_ENV_LANG_UNKNOW +# + if arg_lang == "zh": + return STR_GET_ENV_LANG_ZH + elif arg_lang == "en": + return STR_GET_ENV_LANG_EN + else: + return STR_GET_ENV_LANG_UNKNOW + +def is_root(): + if os.geteuid() == 0: + print(STR_IS_ROOT_TRUE) + return True + else: + print(STR_IS_ROOT_FALSE) + return False + +################################ +# 辅助函数 +def l_print(zh_str, en_str) : + if STR_GET_ENV_LANG_ZH == get_env_lang() : + print(zh_str); + else : + print(en_str); + + +################################ +# 功能函数 +def rhosts(): + + output = os.popen('find / -maxdepth 3 -name rhosts 2>/dev/null ').read().strip() + + if "" == output : + l_print("[OK] 测试通过", + "[OK] pass") + else: + l_print("[ERROR] 测试未通过", + "[ERROR] fail") + +################################ +# main +if __name__ == "__main__": + if len(sys.argv)>1: + arg_lang = sys.argv[1] + else: + arg_lang = 'zh' + + rhosts() + exit(0) diff --git "a/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/97/97\345\205\263\351\227\255\347\263\273\347\273\237\344\277\241\344\273\273\346\234\272\345\210\266rhosts.yaml" "b/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/97/97\345\205\263\351\227\255\347\263\273\347\273\237\344\277\241\344\273\273\346\234\272\345\210\266rhosts.yaml" new file mode 100755 index 0000000..a716094 --- /dev/null +++ "b/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/97/97\345\205\263\351\227\255\347\263\273\347\273\237\344\277\241\344\273\273\346\234\272\345\210\266rhosts.yaml" @@ -0,0 +1,22 @@ +FormatVer: 20230623 +Id: rhosts +Belong: baseline +SiteInfo: + Name: 97关闭系统信任机制rhosts +Power : "root" +SiteRequests: + Implement: + ImArray: + - Inter : python3 + InterArgs : + Exec : 97关闭系统信任机制rhosts.py + Args : + Inter: + - "[ERROR]" + Condition: None +RepairArgs: + - Inter : python3 + InterArgs : + Exec : + Args : + RepairPower: #root # root权限或者普通用户权限 -- Gitee