Closed acooler15 closed 3 years ago
dnsmasq[1]: cannot access directory /var/etc/dnsmasq-ssrplus.d: No such file or directory
安装procd-ujail后,/etc/init.d/dnsmasq文件中的procd_add_jail_mount生效,但是/var/etc/并不在列表中,导致dnsmasq无法读取/var/etc/dnsmasq-ssrplus.d中的内容。
/etc/init.d/dnsmasq
procd_add_jail_mount
/var/etc/
/var/etc/dnsmasq-ssrplus.d
将luci-app-ssr-plus的/root/usr/share/shadowsocksr/update.lua#L12和/root/etc/init.d/shadowsocksr#L20的TMP_DNSMASQ_PATH的值修改为/var/dnsmasq.d/dnsmasq-ssrplus.d。
TMP_DNSMASQ_PATH
/var/dnsmasq.d/dnsmasq-ssrplus.d
diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 7021029..593b5ea 100755 --- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -17,7 +17,7 @@ LOCK_FILE=/var/lock/ssrplus.lock LOG_FILE=/var/log/ssrplus.log TMP_PATH=/var/etc/ssrplus TMP_BIN_PATH=$TMP_PATH/bin -TMP_DNSMASQ_PATH=/var/etc/dnsmasq-ssrplus.d +TMP_DNSMASQ_PATH=/var/dnsmasq.d/dnsmasq-ssrplus.d tcp_config_file= udp_config_file= shunt_config_file= diff --git a/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua b/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua index ccf8546..f07bc12 100755 --- a/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua +++ b/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua @@ -9,7 +9,7 @@ require "luci.model.uci" local icount = 0 local args = arg[1] local uci = luci.model.uci.cursor() -local TMP_DNSMASQ_PATH = "/var/etc/dnsmasq-ssrplus.d" +local TMP_DNSMASQ_PATH = "/var/dnsmasq.d/dnsmasq-ssrplus.d" local TMP_PATH = "/var/etc/ssrplus" -- match comments/title/whitelist/ip address/excluded_domain local comment_pattern = "^[!\\[@]+"
结果: 失败。 原因分析: /etc/init.d/dnsmasq中dnsmasqconfdir变量的值默认为/tmp/dnsmasq.d。
dnsmasqconfdir
/tmp/dnsmasq.d
将luci-app-ssr-plus的/root/usr/share/shadowsocksr/update.lua#L12和/root/etc/init.d/shadowsocksr#L20的TMP_DNSMASQ_PATH的值修改为/tmp/dnsmasq.d/dnsmasq-ssrplus.d。
/tmp/dnsmasq.d/dnsmasq-ssrplus.d
diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 7021029..ffa01a8 100755 --- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -17,7 +17,7 @@ LOCK_FILE=/var/lock/ssrplus.lock LOG_FILE=/var/log/ssrplus.log TMP_PATH=/var/etc/ssrplus TMP_BIN_PATH=$TMP_PATH/bin -TMP_DNSMASQ_PATH=/var/etc/dnsmasq-ssrplus.d +TMP_DNSMASQ_PATH=/tmp/dnsmasq.d/dnsmasq-ssrplus.d tcp_config_file= udp_config_file= shunt_config_file= @@ -810,8 +810,8 @@ start_rules() { start() { set_lock echolog "----------start------------" - mkdir -p /var/run /var/lock /var/log /var/dnsmasq.d $TMP_BIN_PATH $TMP_DNSMASQ_PATH - echo "conf-dir=${TMP_DNSMASQ_PATH}" >"/var/dnsmasq.d/dnsmasq-ssrplus.conf" + mkdir -p /var/run /var/lock /var/log /tmp/dnsmasq.d $TMP_BIN_PATH $TMP_DNSMASQ_PATH + echo "conf-dir=${TMP_DNSMASQ_PATH}" >"/tmp/dnsmasq.d/dnsmasq-ssrplus.conf" if load_config; then Start_Run start_rules @@ -844,7 +844,7 @@ start() { boot() { echolog "boot!" - mkdir -p /var/run /var/lock /var/log /var/dnsmasq.d $TMP_BIN_PATH $TMP_DNSMASQ_PATH + mkdir -p /var/run /var/lock /var/log /tmp/dnsmasq.d $TMP_BIN_PATH $TMP_DNSMASQ_PATH ulimit -n 65535 start } @@ -869,8 +869,8 @@ stop() { $PS -w | grep -v "grep" | grep "$TMP_PATH" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 & killall -q -9 v2ray-plugin obfs-local xray-plugin rm -f /var/lock/ssr-monitor.lock - if [ -f "/var/dnsmasq.d/dnsmasq-ssrplus.conf" ]; then - rm -rf /var/dnsmasq.d/dnsmasq-ssrplus.conf $TMP_DNSMASQ_PATH $TMP_PATH/*-ssr-*.json $TMP_PATH/ssr-server*.json + if [ -f "/tmp/dnsmasq.d/dnsmasq-ssrplus.conf" ]; then + rm -rf /tmp/dnsmasq.d/dnsmasq-ssrplus.conf $TMP_DNSMASQ_PATH $TMP_PATH/*-ssr-*.json $TMP_PATH/ssr-server*.json /etc/init.d/dnsmasq restart >/dev/null 2>&1 fi del_cron diff --git a/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua b/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua index ccf8546..3e83271 100755 --- a/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua +++ b/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua @@ -9,7 +9,7 @@ require "luci.model.uci" local icount = 0 local args = arg[1] local uci = luci.model.uci.cursor() -local TMP_DNSMASQ_PATH = "/var/etc/dnsmasq-ssrplus.d" +local TMP_DNSMASQ_PATH = "/tmp/dnsmasq.d/dnsmasq-ssrplus.d" local TMP_PATH = "/var/etc/ssrplus" -- match comments/title/whitelist/ip address/excluded_domain local comment_pattern = "^[!\\[@]+"
结果: 成功
修改dnsmasq,为其增加一个list类型的配置extra_mount。 基于openwrt/package master 分支
extra_mount
openwrt/package
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index 3250b2179b..c437719dc6 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -954,6 +954,7 @@ dnsmasq_start() config_list_foreach "$cfg" "interface" append_interface config_list_foreach "$cfg" "notinterface" append_notinterface } + config_get EXTRA_MOUNT "$cfg" "extra_mount" "" config_get_bool ignore_hosts_dir "$cfg" ignore_hosts_dir 0 if [ "$ignore_hosts_dir" = "1" ]; then xappend "--addn-hosts=$HOSTFILE"
The patch of test 2 makes sense.
错误信息:
dnsmasq[1]: cannot access directory /var/etc/dnsmasq-ssrplus.d: No such file or directory
错误原因:
安装procd-ujail后,
/etc/init.d/dnsmasq
文件中的procd_add_jail_mount
生效,但是/var/etc/
并不在列表中,导致dnsmasq无法读取/var/etc/dnsmasq-ssrplus.d
中的内容。测试:
Test 1
将luci-app-ssr-plus的/root/usr/share/shadowsocksr/update.lua#L12和/root/etc/init.d/shadowsocksr#L20的
TMP_DNSMASQ_PATH
的值修改为/var/dnsmasq.d/dnsmasq-ssrplus.d
。结果: 失败。 原因分析:
/etc/init.d/dnsmasq
中dnsmasqconfdir
变量的值默认为/tmp/dnsmasq.d
。Test 2
将luci-app-ssr-plus的/root/usr/share/shadowsocksr/update.lua#L12和/root/etc/init.d/shadowsocksr#L20的
TMP_DNSMASQ_PATH
的值修改为/tmp/dnsmasq.d/dnsmasq-ssrplus.d
。结果: 成功
Test 3
修改dnsmasq,为其增加一个list类型的配置
extra_mount
。 基于openwrt/package
master 分支结果: 成功