openwrt / luci

LuCI - OpenWrt Configuration Interface
Apache License 2.0
6.29k stars 2.51k forks source link

luci-app-ddns failed to execute cbi dispatcher #2057

Closed finasfinas closed 6 years ago

finasfinas commented 6 years ago

I can't access the luci page for ddns on my custom build C7 image since a couple of months ago. Yesterday I created a custom build for R7800 and the exact same problem happens. removing ddns file from config dir does not solve the issue. this is the error:

Failed to execute cbi dispatcher target for entry '/admin/services/ddns'.
The called action terminated with an exception:
/usr/lib/lua/luci/controller/ddns.lua:84: attempt to index field '?' (a nil value)
stack traceback:
    /usr/lib/lua/luci/controller/ddns.lua:84: in function 'service_version'
    /usr/lib/lua/luci/controller/ddns.lua:91: in function 'service_ok'
    /usr/lib/lua/luci/model/cbi/ddns/overview.lua:16: in function 'e'
    /usr/lib/lua/luci/cbi.lua:48: in function 'load'
    /usr/lib/lua/luci/dispatcher.lua:672: in function </usr/lib/lua/luci/dispatcher.lua:667>
dibdot commented 6 years ago

Which ddns version did you use? Did you try to install/reproduce this issue with official/buildbot generated packages?

What's the output of: /usr/lib/ddns/dynamic_dns_lucihelper.sh -V

Maintainer: @Ansuel

Ansuel commented 6 years ago

ummm ddns doesn't use the lucihelper script anymore to obtain the version if LuCI IPKG utility is found... Can you post the content of the file? ( /usr/lib/lua/luci/controller/ddns.lua )

finasfinas commented 6 years ago

Hi guys, Thanks for shimming in. I'm using trunk for both OpenWRT and packages. Compiled today. I haven't tried the official packages but I would suspect they would work properly, if not, someone would have certainly noticed this already. I have this problem for a couple of months now. Yesterday I compiled a brand new build for the R7800 that I just got, configured the build from scratch with make menuconfig and when flashing the original netgear firmware with my build I noticed the same issue ( even with the default OpenWRT configurations ). This leads me to believe that it is something that I select/ deselect on the build that leads to this issue but I am unsure what it can be. ddns and luci-ddns are not packages, they are built into the build as all the packages I use. also, I have:

cat /usr/lib/lua/luci/controller/ddns.lua

module("luci.controller.ddns",package.seeall) local u=require"nixio" local y=require"nixio.fs" local h=require"luci.dispatcher" local a=require"luci.http" local e=require"luci.i18n" local i=require"luci.model.ipkg" local c=require"luci.sys" local f=require"luci.model.uci" local w=require"luci.util" local t=require"luci.tools.ddns" luci_helper="/usr/lib/ddns/dynamic_dns_lucihelper.sh" local o="ddns-scripts" local s="2.7.7" local d="luci-app-ddns" local n="Dynamic DNS" local r="2.4.9-1" function index() local e=require"nixio.fs" local t=require"luci.sys" local t=require"luci.model.uci" if not e.access("/etc/config/ddns")then e.writefile("/etc/config/ddns","") end local t=t.cursor() local a=false t:foreach("ddns","service",function(e) if not e["lookup_host"]and e["domain"]then t:set("ddns",e[".name"],"lookuphost",e["domain"]) a=true end end) if a then t:commit("ddns")end t:unload("ddns") entry({"admin","services","ddns"},cbi("ddns/overview"),("Dynamic DNS"),59) entry({"admin","services","ddns","detail"},cbi("ddns/detail"),nil).leaf=true entry({"admin","services","ddns","hints"},cbi("ddns/hints", {hideapplybtn=true,hidesavebtn=true,hideresetbtn=true}),nil).leaf=true entry({"admin","services","ddns","global"},cbi("ddns/global"),nil).leaf=true entry({"admin","services","ddns","logview"},call("logread")).leaf=true entry({"admin","services","ddns","startstop"},post("startstop")).leaf=true entry({"admin","services","ddns","status"},call("status")).leaf=true end function app_description() return e.translate("Dynamic DNS allows that your router can be reached with ".. "a fixed hostname while having a dynamically changing IP address.") ..[[
]] ..e.translate("OpenWrt Wiki")..": " ..[[]] ..e.translate("DDNS Client Documentation")..[[]] .." --- " ..[[]] ..e.translate("DDNS Client Configuration")..[[]] end function app_title_back() return[[<a href="]] ..h.build_url("admin","services","ddns") ..[[">]] ..e.translate(n) ..[[]] end function app_title_main() tmp={} tmp[#tmp+1]=[[<a href="javascript:alert(']] tmp[#tmp+1]=e.translate("Version Information") tmp[#tmp+1]=[[\n\n]]..d tmp[#tmp+1]=[[\n]]..e.translate("Version")..[[: ]]..r tmp[#tmp+1]=[[\n\n]]..o..[[ ]]..e.translate("required")..[[:]] tmp[#tmp+1]=[[\n]]..e.translate("Version")..[[: ]] tmp[#tmp+1]=s..[[ ]]..e.translate("or higher") tmp[#tmp+1]=[[\n\n]]..o..[[ ]]..e.translate("installed")..[[:]] tmp[#tmp+1]=[[\n]]..e.translate("Version")..[[: ]] tmp[#tmp+1]=(service_version()or e.translate("NOT installed")) tmp[#tmp+1]=[[\n\n]] tmp[#tmp+1]=[[')">]] tmp[#tmp+1]=e.translate(n) tmp[#tmp+1]=[[]] return table.concat(tmp) end function service_version() local t=luci_helper.." -V | awk {'print $2'} " local e if i then e=i.info(o)[o].Version else e=w.exec(t) end if e and#e>0 then return e or nil end end function service_ok() return i.compare_versions((service_version()or"0"),">=",s) end local function m() local u=f.cursor() local a=c.init.enabled("ddns")and 1 or 0 local e=h.build_url("admin","system","startup") local n={} n[#n+1]={ enabled=a, url_up=e, } u:foreach("ddns","service",function(e) local s=e[".name"] local l=tonumber(e["enabled"])or 0 local d="empty" local a="empty" local o=t.calc_seconds( tonumber(e["force_interval"])or 72, e["force_unit"]or"hours") local r=t.get_pid(s) local h=c.uptime() local i=t.get_lastupd(s) if i>h then i=0 end if i==0 then d="never" else local e=os.time()-h+i d=t.epoch2date(e) a=t.epoch2date(e+o) end o=(o>h)and h or o if r>0 and(i+o-h)<=0 then a="verify" elseif o==0 then a="runonce" elseif r==0 and l==0 then a="disabled" elseif r==0 and l~=0 then a="stopped" end local o=e["interface"]or"wan" local h=tonumber(e["use_ipv6"])or 0 local i=(h==1)and"IPv6"or"IPv4" o=i.." / "..o local i=e["lookup_host"]or"nolookup" local u=t.calc_seconds( tonumber(e["check_interval"])or 10, e["check_unit"]or"minutes") local t=t.get_regip(s,u) if t=="NOFILE"then local a=e["dns_server"]or"" local r=tonumber(e["force_ipversion"]or 0) local n=tonumber(e["force_dnstcp"]or 0) local o=tonumber(e["is_glue"]or 0) local e=luci_helper..[[ -]] if(h==1)then e=e..[[6]]end if(r==1)then e=e..[[f]]end if(n==1)then e=e..[[t]]end if(o==1)then e=e..[[g]]end e=e..[[l ]]..i e=e..[[ -S ]]..s if(#a>0)then e=e..[[ -d ]]..a end e=e..[[ -- get_registered_ip]] t=c.exec(e) end if t==""then t="nodata" end n[#n+1]={ section=s, enabled=l, iface=o, lookup=i, reg_ip=t, pid=r, datelast=d, datenext=a } end) u:unload("ddns") return n end function logread(e) local t=f.cursor() local o=t:get("ddns","global","ddns_logdir")or"/var/log/ddns" local e=o.."/"..e..".log" local e=y.readfile(e) if not e or#e==0 then e="nodata" end t:unload("ddns") a.write(e) end function startstop(o,n) local e=f.cursor() local t=t.get_pid(o) local i={} if t>0 then local e=u.kill(t,15) u.nanosleep(2) i=m() a.prepare_content("application/json") a.write_json(i) return end local t=true local s=e:changes("ddns") for e,a in pairs(s)do if e~="ddns"then t=false break end for a,e in pairs(a)do if a~=o then t=false break end for e,a in pairs(e)do if e~="enabled"then t=false break end end end end if not t then a.write("uncommitted") return end e:set("ddns",o,"enabled",((n=="true")and"1"or"0")) e:save("ddns") e:commit("ddns") e:unload("ddns") local e="%s -S %s -- start"%{luci_helper,w.shellquote(o)} os.execute(e) u.nanosleep(3) i=m() a.prepare_content("application/json") a.write_json(i) end function status() local e=m() a.prepare_content("application/json") a.write_json(e) end

hnyman commented 6 years ago

Removal of opkg might be the reason, if I combine Ansuel's comments and you explanation:

**remove opkg**
**Remove ipkg/opkg status data files in final images is not enabled ( it is as default )**

vs.

ddns doesn't use the lucihelper script anymore to obtain the version if LuCI IPKG utility is found.

You have rather non-standard options (gcc, binutils, minify, opkg removal) ... So no wonder that something happens. opkg and opkg data are used in LuCI (and Openwrt) by various package scripts. Removing them will mean that some things will not work ok, and as opkg is pretty much assumed to be present in the build, not all scripts have fallback for that case. I haven't checked ddns sources closely, so this is pure hunch.

finasfinas commented 6 years ago

indeed, installing opkg resolves the issue. thanks for narrowing down this for me. I'm closing the issue.