Skip to content

Commit

Permalink
fix: 修复回环检测误判 wmiexe 的问题 (fixed TencentBlueKing#2194)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuoZhuoCrayon authored and wyyalt committed May 9, 2024
1 parent 8889b40 commit 3d01b84
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions script_tools/setup_pagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ def execute_cmd(
from wmiexec import WMIEXEC
except ImportError:
# WMI 执行文件不存在,从下载源同步
download_file(f"{args.download_url}/wmiexec.py", str(Path(__file__).parent))
# wmiexec 是下载到脚本执行目录下,不属于回环
download_file(f"{args.download_url}/wmiexec.py", str(Path(__file__).parent), skip_lo_check=True)
from wmiexec import WMIEXEC

executor = WMIEXEC(cmd_str, username, password, domain, share=share, noOutput=is_no_output)
Expand Down Expand Up @@ -389,7 +390,7 @@ def json_parser(json_file: str) -> List:
return configs


def download_file(url: str, dest_dir: str):
def download_file(url: str, dest_dir: str, skip_lo_check: bool = False):
"""get files via http"""
try:
# 创建下载目录
Expand All @@ -407,7 +408,7 @@ def download_file(url: str, dest_dir: str):
)
return

if args.lan_eth_ip in url:
if args.lan_eth_ip in url and not skip_lo_check:
logger.logging("download_file", "File download skipped due to lo ip")
return

Expand Down

0 comments on commit 3d01b84

Please sign in to comment.