flask - 当代码指示要写入的文件时,apache2/mod_wsgi/python3/flask 使用什么凭据?
问题描述
这段简单的代码:
from flask import Flask, render_template, request, redirect, abort
import sys, time
import wh_settings as settings
app = Flask(__name__)
@app.route('/', methods=['POST', 'GET'])
def webhook():
if request.method == 'POST':
daily_events_fullpath = '/home/[user]/[target directory]/[filename]'
try:
with open(daily_events_fullpath, 'a') as fileobject:
fileobject.write("Hello World\n")
retval = """Hellow yellow kitty"""
except Exception as ex:
retval = str(ex)
else:
retval = """Not a 'POST'"""
return retval, 200
...导致:
[Errno 13] 权限被拒绝:'/home/[user]/[target directory]/[filename]'
(将 '[user]/[target directory]/[filename]' 替换为有效内容)
由于我设置了一个允许“www-data”写入该目录的 ACL(并使用“getfacl”对其进行了仔细检查),因此我认为 apache2/mod_wsgi/python3/flask 必须使用其他一些凭据来写入文件。
谁能告诉我如何找出正在使用的凭据?我查看了 /var/log/auth.log 并且没有“拒绝”条目用于尝试打开文件进行追加。
附加系统信息:
Opsys = Linux
Kernel ver = 5.3.0-1030-aws
distro = Ubuntu 18.04,4 LTS Server (no GUI)
SELinux is not installed
AppArmor is installed and enabled
解决方案
推荐阅读
- java - 我收到空值错误,因为 java.lang.AssertionError: Lists different at element [0]: != Selenium expected [] but found [Selenium]
- javascript - jQuery('#myModal:visible').length === 0 在 Javascript
- java - 使用 if 语句依次执行这两个代码
- react-native - 如何使用 SeionList 展开和折叠指定部分?
- cassandra - Write consistency = ALL: do I still need weekly repairs to avoid zombie records?
- java - 如何使用需要在 Oracle 数据库中调用存储过程的实体管理器创建 Clob?
- java - 无法通过 JDBC java 程序连接 hive2
- python - Seaborn 散点图 - 标记数据点
- asp.net-core-mvc - Azure Web 应用找不到 .NET Core 2.1 应用的视图
- angular - 从 express 向 mongoDB 发布请求