Skip to content

Commit

Permalink
5.9.24
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Jul 2, 2019
1 parent 51816f3 commit 10d7cbe
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion BTPanel/__init__.py
Expand Up @@ -89,7 +89,7 @@ def service_status():
@app.before_request @app.before_request
def basic_auth_check(): def basic_auth_check():
if app.config['BASIC_AUTH_OPEN']: if app.config['BASIC_AUTH_OPEN']:
if request.path in ['/public']: return; if request.path in ['/public','/download']: return;
auth = request.authorization auth = request.authorization
if not comm.get_sk(): return; if not comm.get_sk(): return;
if not auth: return send_authenticated() if not auth: return send_authenticated()
Expand Down
2 changes: 1 addition & 1 deletion class/database.py
Expand Up @@ -102,7 +102,7 @@ def IsSqlError(self,mysqlMsg):
if "libmysqlclient" in mysqlMsg: if "libmysqlclient" in mysqlMsg:
result = self.rep_lnk() result = self.rep_lnk()
os.system("pip uninstall mysql-python -y") os.system("pip uninstall mysql-python -y")
os.system("pip install mysql-python") os.system("pip install pymysql")
public.writeFile('data/restart.pl','True') public.writeFile('data/restart.pl','True')
return public.returnMsg(False,"执行失败,已尝试自动修复,请稍候重试!") return public.returnMsg(False,"执行失败,已尝试自动修复,请稍候重试!")
return None return None
Expand Down
14 changes: 8 additions & 6 deletions class/letsencrypt.py
Expand Up @@ -24,9 +24,9 @@
import argparse, subprocess, json, os, sys, base64, binascii, time, hashlib, re, copy, textwrap, logging, requests import argparse, subprocess, json, os, sys, base64, binascii, time, hashlib, re, copy, textwrap, logging, requests


try: try:
from urllib.request import urlopen, Request # Python 3 from urllib.request import urlopen, Request # 3
except ImportError: except ImportError:
from urllib2 import urlopen, Request # Python 2 from urllib2 import urlopen, Request # 2


DEFAULT_CA = "https://acme-v02.api.letsencrypt.org" DEFAULT_CA = "https://acme-v02.api.letsencrypt.org"
# DEFAULT_CA = "https://acme-staging-v02.api.letsencrypt.org" # DEFAULT_CA = "https://acme-staging-v02.api.letsencrypt.org"
Expand Down Expand Up @@ -65,7 +65,8 @@ def _do_request(url, data=None, err_msg="Error", depth=0):
if depth < 100 and code == 400 and resp_data['type'] == "urn:ietf:params:acme:error:badNonce": if depth < 100 and code == 400 and resp_data['type'] == "urn:ietf:params:acme:error:badNonce":
raise IndexError(resp_data) raise IndexError(resp_data)
if code not in [200, 201, 204]: if code not in [200, 201, 204]:
raise ValueError("{0}:\nUrl: {1}\nData: {2}\nResponse Code: {3}\nResponse: {4}".format(err_msg, url, data, code, resp_data)) # print("{0}:\nUrl: {1}\nData: {2}\nResponse Code: {3}".format(err_msg, url, data, code))
sys.exit(json.dumps(resp_data))
return resp_data, code, headers return resp_data, code, headers


def _send_signed_request(url, payload, err_msg, depth=0): def _send_signed_request(url, payload, err_msg, depth=0):
Expand Down Expand Up @@ -167,7 +168,8 @@ def _poll_until_not(url, pending_statuses, err_msg):
authorization = _poll_until_not(auth_url, ["pending"], "Error checking challenge status for {0}".format(domain)) authorization = _poll_until_not(auth_url, ["pending"], "Error checking challenge status for {0}".format(domain))
if authorization['status'] != "valid": if authorization['status'] != "valid":
public.WriteFile(os.path.join(path, "check_authorization_status_response"), json.dumps(authorization), mode="w") public.WriteFile(os.path.join(path, "check_authorization_status_response"), json.dumps(authorization), mode="w")
raise ValueError("Challenge did not pass for {0}: {1}".format(domain, authorization)) print("Challenge did not pass for {0}".format(domain, ))
sys.exit(json.dumps(authorization))
log.info("{0} verified!".format(domain)) log.info("{0} verified!".format(domain))


# finalize the order with the csr # finalize the order with the csr
Expand Down Expand Up @@ -195,12 +197,12 @@ def _poll_until_not(url, pending_statuses, err_msg):
data = json.loads(sys.argv[1]) data = json.loads(sys.argv[1])
print (data) print (data)
sitedomain = data['siteName'] sitedomain = data['siteName']
path = os.path.join("/www/server/panel/vhost/cert/", sitedomain) path = data['path']
public.ExecShell("mkdir -p {}".format(path)) public.ExecShell("mkdir -p {}".format(path))
KEY_PREFIX = os.path.join(path, "privkey") KEY_PREFIX = os.path.join(path, "privkey")
ACCOUNT_KEY = os.path.join(path, "letsencrypt-account.key") ACCOUNT_KEY = os.path.join(path, "letsencrypt-account.key")
DOMAIN_KEY = os.path.join(path, "privkey.pem") DOMAIN_KEY = os.path.join(path, "privkey.pem")
DOMAIN_DIR = os.path.join("/www/wwwroot", sitedomain) DOMAIN_DIR = data['sitePath']
DOMAINS = data['DOMAINS'] DOMAINS = data['DOMAINS']
DOMAIN_PEM = KEY_PREFIX + ".pem" DOMAIN_PEM = KEY_PREFIX + ".pem"
DOMAIN_CSR = KEY_PREFIX + ".csr" DOMAIN_CSR = KEY_PREFIX + ".csr"
Expand Down
9 changes: 7 additions & 2 deletions class/panelMysql.py
Expand Up @@ -31,8 +31,13 @@ def __Conn(self):
if sys.version_info[0] == 2: if sys.version_info[0] == 2:
reload(MySQLdb) reload(MySQLdb)
except Exception as ex: except Exception as ex:
self.__DB_ERR = ex try:
return False; import pymysql
pymysql.install_as_MySQLdb()
import MySQLdb
except Exception as e:
self.__DB_ERR = e
return False;
try: try:
myconf = public.readFile('/etc/my.cnf'); myconf = public.readFile('/etc/my.cnf');
rep = "port\s*=\s*([0-9]+)" rep = "port\s*=\s*([0-9]+)"
Expand Down
12 changes: 6 additions & 6 deletions class/panelSite.py
Expand Up @@ -2537,12 +2537,12 @@ def SetNginx(self,get):
if public.get_webserver() == 'nginx': if public.get_webserver() == 'nginx':
shutil.copyfile(ng_file, '/tmp/ng_file_bk.conf') shutil.copyfile(ng_file, '/tmp/ng_file_bk.conf')


if os.path.exists('/www/server/nginx/src/ngx_cache_purge'): #if os.path.exists('/www/server/nginx/src/ngx_cache_purge'):
cureCache += ''' cureCache += '''
location ~ /purge(/.*) { location ~ /purge(/.*) {
proxy_cache_purge cache_one $1$is_args$args; proxy_cache_purge cache_one $host$1$is_args$args;
#access_log /www/wwwlogs/%s_purge_cache.log; #access_log /www/wwwlogs/%s_purge_cache.log;
}''' % (get.sitename) }''' % (get.sitename)
if os.path.exists(ng_file): if os.path.exists(ng_file):
self.CheckProxy(get) self.CheckProxy(get)
ng_conf = public.readFile(ng_file) ng_conf = public.readFile(ng_file)
Expand Down
2 changes: 1 addition & 1 deletion license.txt
Expand Up @@ -7,7 +7,7 @@
宝塔:宝塔面板(主体: 东莞市百塔网络科技有限公司) 宝塔:宝塔面板(主体: 东莞市百塔网络科技有限公司)
用户许可定义:用户在基于明显的用途说明后主动安装、使用、注册、管理软件,以及同意宝塔提供相关服务所订立的协议 用户许可定义:用户在基于明显的用途说明后主动安装、使用、注册、管理软件,以及同意宝塔提供相关服务所订立的协议


一、宝塔需尊守的约定 一、宝塔需遵守的约定
1.1 除付费插件外,确保所有代码用户皆可阅读。 1.1 除付费插件外,确保所有代码用户皆可阅读。
1.2 确保用户在完成所有环境部署后,在不依赖宝塔云端支持下也可永久运行。 1.2 确保用户在完成所有环境部署后,在不依赖宝塔云端支持下也可永久运行。
1.3 除付费插件外,禁止对源代码进行加密和混淆。 1.3 除付费插件外,禁止对源代码进行加密和混淆。
Expand Down

0 comments on commit 10d7cbe

Please sign in to comment.