mirror of https://github.com/jumpserver/jumpserver
fix(upload, download, exec, gn) 修复上传下载文件名,上传目录层次,执行命令回车报错,g+不存在id报错
1. 上传下载文件名 改为 时间+随机4位字母数字 2. 命令回车判断,为空返回 3. g+1判断,不过不存在该组,则返回 close #52 close #93 ref https://github.com/jumpserver/jumpserver/issues/53 ref https://github.com/jumpserver/jumpserver/issues/93pull/97/head
parent
0b9b94bc0b
commit
a88d8ca410
13
connect.py
13
connect.py
|
@ -523,7 +523,13 @@ class Nav(object):
|
|||
if gid_pattern.match(str_r):
|
||||
gid = int(str_r.lstrip('g'))
|
||||
# 获取资产组包含的资产
|
||||
user_asset_search = get_object(AssetGroup, id=gid).asset_set.all()
|
||||
asset_group = get_object(AssetGroup, id=gid)
|
||||
if asset_group:
|
||||
user_asset_search = asset_group.asset_set.all()
|
||||
else:
|
||||
color_print('没有该资产组或没有权限')
|
||||
return
|
||||
|
||||
else:
|
||||
# 匹配 ip, hostname, 备注
|
||||
for asset in user_asset_all:
|
||||
|
@ -609,6 +615,9 @@ class Nav(object):
|
|||
command = raw_input("\033[1;32mCmds>:\033[0m ").strip()
|
||||
if command == 'q':
|
||||
break
|
||||
elif not command:
|
||||
color_print('命令不能为空...')
|
||||
continue
|
||||
runner.run('shell', command, pattern=pattern)
|
||||
ExecLog(host=asset_name_str, user=self.user.username, cmd=command, remote_ip=remote_ip,
|
||||
result=runner.results).save()
|
||||
|
@ -661,7 +670,7 @@ class Nav(object):
|
|||
|
||||
runner = MyRunner(res)
|
||||
runner.run('copy', module_args='src=%s dest=%s directory_mode'
|
||||
% (tmp_dir, tmp_dir), pattern=pattern)
|
||||
% (tmp_dir, '/tmp'), pattern=pattern)
|
||||
ret = runner.results
|
||||
FileLog(user=self.user.name, host=asset_name_str, filename=filename_str,
|
||||
remote_ip=remote_ip, type='upload', result=ret).save()
|
||||
|
|
|
@ -484,7 +484,8 @@ def my_render(template, data, request):
|
|||
|
||||
|
||||
def get_tmp_dir():
|
||||
dir_name = os.path.join('/tmp', uuid.uuid4().hex)
|
||||
seed = uuid.uuid4().hex[:4]
|
||||
dir_name = os.path.join('/tmp', '%s-%s' % (datetime.datetime.now().strftime('%Y%m%d-%H%M%S'), seed))
|
||||
mkdir(dir_name, mode=0777)
|
||||
return dir_name
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ def upload(request):
|
|||
res = gen_resource({'user': user, 'asset': asset_select})
|
||||
runner = MyRunner(res)
|
||||
runner.run('copy', module_args='src=%s dest=%s directory_mode'
|
||||
% (upload_dir, upload_dir), pattern='*')
|
||||
% (upload_dir, '/tmp'), pattern='*')
|
||||
ret = runner.results
|
||||
logger.debug(ret)
|
||||
FileLog(user=request.user.username, host=' '.join([asset.hostname for asset in asset_select]),
|
||||
|
|
Loading…
Reference in New Issue