Closed kokoichi206 closed 2 years ago
if [ ! -z "$post" ]; then
echo "${post}" >> "${FILE_PATH}"
echo "pien" >> /var/www/html/issues.txt
fi
/usr/lib/cgi-bin/issue_report.sh: 28: cannot create /tmp/log/issues.txt: Directory nonexistent
/usr/lib/cgi-bin/issue_report.sh: 29: cannot create /var/www/html/issues.txt: Permission denied
おそらく、セキュリティの観点から /tmp などの外部フォルダが見れなくなっている模様
→ /var/www/html 配下に保存するようにした
サーバーサイドのログの例
$ cat issues.txt
[Mon Nov 22 15:56:55 UTC 2021] issue "Railsー"
[Mon Nov 22 16:18:25 UTC 2021] issue "遠藤さくらさんが可愛すぎます"
とりあえずの cgi ファイルの例
#!/bin/sh
method="$REQUEST_METHOD"
### post data is expected to be passed as text/plane ###
POST_STRING=$(cat)
post="$POST_STRING"
if [ "${method}" = "POST" ]; then
# /tmp/log/ だと上手くいかなかった(なんで?)
LOG_DIR="/var/www/html/sakamichi_log/"
FILE_NAME="issues.txt"
FILE_PATH="${LOG_DIR}${FILE_NAME}"
TIME="date"
DATA_TYPE="issue"
if [ ! -z "$post" ]; then
echo [`date`] ${DATA_TYPE} "${post}" >> "${FILE_PATH}"
fi
status=$?
cat << EOF
Content-Type: application/json; charset=UTF-8
{
"status": "check"
}
EOF
elif [ "${method}" = "GET" ]; then
cat << EOF
Content-Type: application/json; charset=UTF-8
{
"me": "`whoami`",
"home_dir": "`ls ~/`",
"files_in /tmp/log/": "${FILES_IN_LOG}",
"pwd": "`pwd`",
"path": "${FILE_PATH}",
"ident": "${ident}",
"method": "${method}",
"post body": "${post}",
"success": "false"
}
EOF
fi
ある URL から確認もできるようにしたい
不具合の報告を受け取るリンクの作成