pull/632/head
Mr Chen 5 months ago
parent 6858a827f9
commit 83711db1c8
  1. 9
      web/admin/files/files.py
  2. 25
      web/utils/file.py

@ -79,6 +79,15 @@ def zip():
path = request.form.get('path', '')
return file.zip(sfile, dfile, stype, path)
# 文件权限查看
@blueprint.route('/file_access', endpoint='file_access', methods=['POST'])
@panel_login_required
def file_access():
filename = request.form.get('filename', '')
data = file.getAccess(filename)
data['sys_users'] = file.getSysUserList()
return data
# 复制文件内容
@blueprint.route('/copy_file', endpoint='copy_file', methods=['POST'])
@panel_login_required

@ -294,6 +294,17 @@ def unzip(sfile, dfile, stype, path):
except:
return mw.returnData(False, '文件解压失败!')
def getAccess(filename):
data = {}
try:
stat = os.stat(filename)
data['chmod'] = str(oct(stat.st_mode)[-3:])
data['chown'] = pwd.getpwuid(stat.st_uid).pw_name
except:
data['chmod'] = 755
data['chown'] = 'www'
return data
def copyDir(src_file, dst_file):
if not os.path.exists(src_file):
return mw.returnData(False, '指定目录不存在!')
@ -649,6 +660,20 @@ def getAccess(fname):
data['chown'] = 'www'
return data
def getSysUserList():
pwd_file = '/etc/passwd'
if os.path.exists(pwd_file):
content = mw.readFile(pwd_file)
clist = content.split('\n')
sys_users = []
for line in clist:
if line.find(":")<0:
continue
lines = line.split(":",1)
sys_users.append(lines[0])
return sys_users
return ['root','mysql','www']
def fileDelete(path):
if not os.path.exists(path):
return mw.returnData(False, '指定文件不存在!')

Loading…
Cancel
Save