Openwrt 網頁多用戶訪問

一、添加用戶訪問web

1、vim ./lua/luci/controller/admin/index.lua
page.sysauth = {"root","win"}

2、vim ./lua/luci/controller/admin/servicectl.lua
entry({"servicectl"}, alias("servicectl", "status")).sysauth = {"root","win"}



二、修改默認用戶爲admin

1、vim /etc/passwd
admin:x:0:0:root:/var:/bin/false  //這樣就不能ssh登入了

2、vim /etc/shadow
admin::0:0:99999:7:::  //默認無密碼
admin:$1$IUy8Oqop$u9kDk9L5JyvKaa2UCZUCR.:16595:0:99999:7::: //默認密碼admin

3、vim ./usr/lib/lua/luci/dispatcher.lua
if not user or not util.contains(accs, user) then
           if (not user) then return end -- send non 'admin' system user back to a login page with a user/passwd error
           require("luci.i18n")
           require("luci.template")
           context.path = {}
                                
           luci.template.render("sysauth", {duser=default, fuser=user})
                                                   
           return

4、vim ./lua/luci/controller/admin/index.lua
page.sysauth = "admin"

5、vim ./lua/luci/controller/admin/servicectl.lua
entry({"servicectl"}, alias("servicectl", "status")).sysauth = luci.dispatcher.context.authuser

6、 edit /usr/lib/lua/luci/controller/admin/system.lua and change line 326 to read
       stat = luci.sys.user.setpasswd("admin", p1)
this is important or luci will change the root password instead of the admin password under system->administration

7、vim usr/lib/lua/luci/view/themes/bootstrap/header.htm  //提示語言修改
<%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("admin") and not luci.sys.user.getpasswd("admin") then -%>
<%:There is no password set on this router. Please configure a admin password to protect the web interface and enable SSH.%><br>
發佈了154 篇原創文章 · 獲贊 12 · 訪問量 52萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章