MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / ExecShell

Method ExecShell

class/files.py:4026–4041  ·  view source on GitHub ↗
(self, get)

Source from the content-addressed store, hash-verified

4024
4025 # 执行SHELL命令
4026 def ExecShell(self, get):
4027 disabled = ['vi', 'vim', 'top', 'passwd', 'su']
4028 get.shell = get.shell.strip()
4029 tmp = get.shell.split(' ')
4030 if tmp[0] in disabled:
4031 return public.returnMsg(False, 'FILE_SHELL_ERR', (tmp[0],))
4032 shellStr = '''#!/bin/bash
4033PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
4034export PATH
4035cd %s
4036%s
4037''' % (get.path, get.shell)
4038 public.writeFile('/tmp/panelShell.sh', shellStr)
4039 public.ExecShell(
4040 'nohup bash /tmp/panelShell.sh > /tmp/panelShell.pl 2>&1 &')
4041 return public.returnMsg(True, 'FILE_SHELL_EXEC')
4042
4043 # 取SHELL执行结果
4044 def GetExecShellMsg(self, get):

Callers 15

PackagePanelFunction · 0.80
get_ipaddressFunction · 0.80
CreateSSLFunction · 0.80
set_panel_portFunction · 0.80
sync_tencent_sslFunction · 0.80
get_temp_loginFunction · 0.80
get_temp_login_ipv4Function · 0.80
close_reverse_proxyFunction · 0.80
check_disk_spaceFunction · 0.80
bt_cliFunction · 0.80
PackagePanelFunction · 0.80
get_ipaddressFunction · 0.80

Calls 3

returnMsgMethod · 0.80
writeFileMethod · 0.80
splitMethod · 0.45

Tested by 15

test_nginx_confFunction · 0.64
test_sshMethod · 0.64
test_jdkFunction · 0.64
backup_redis_dataMethod · 0.64
backup_sqlite_dataMethod · 0.64
restore_sqlite_dataMethod · 0.64
backup_mysql_dataMethod · 0.64
backup_mongodb_dataMethod · 0.64
backup_pgsql_dataMethod · 0.64
init_mysql_rootMethod · 0.64
input_mysql_sqlMethod · 0.64
restore_pgsql_dataMethod · 0.64