Enter an IP Address:
Enter a Subnet Mask:
Enable DHCP
Disable DHCP
1 个解决方案
#1
1
This must be a combination of filesystem permissions and SELinux configuration problem.
这必须是文件系统权限和SELinux配置问题的组合。
The filesystem part is easier to fix. Your web server process probably runs as the apache user, so make sure it has the correct permissions to the file you want to rewrite. To confirm the filesystem permissions are ok, temporarily disable SELinux and check if the writing works:
and then fix your SELinux settings. Here are some hints for that from this other answer, in particular:
然后修复SELinux设置。以下是其他答案中的一些提示,特别是:
You must either give the directory structure a context of httpd_sys_rw_content_t, or give them a context of public_content_rw_t and enable allow_httpd_anon_write and/or allow_httpd_sys_script_anon_write. See the httpd_selinux(8) man page for details.
In addition, I would rewrite your script like this:
另外,我会像这样重写你的脚本:
#!/bin/bash
cOnfig=/var/www/net.config
while IFS== read name value; do
case $name in
IPADDR) IPADDR=$value ;;
SUBNET) SUBNET=$value ;;
DHCP) DHCP=$value ;;
esac
done <<(sed -e 's/&/\n/g' <<<$QUERY_STRING)
is_valid() {
# todo: validate the input params
return 1
}
if is_valid; then
sed -i.bak e "s/IPADDR=.*/IPADDR=$IPADDR/g" -e "s/NETMASK=.*/NETMASK=$SUBNET/g" $config
title='IP CHANGED'
body=$(cat <
SUBNET changed to: $SUBNET
DHCP $DHCP
EOF
)
else
body='What are you trying to pull, mister?'
fi
cat <