From 0251603f0aa064109138d40d06aa892f49e7abc7 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Thu, 14 Jun 2018 11:13:08 +0200 Subject: luci-mod-admin-full: fix empty SSH-Keys issue If you delete all ssh keys in the textarea then LuCI will rais an error. So if you added one ssh-key to the textarea and then you want to delete them again that is not possbile in LuCI. To fix this remove "rmempty" attribute and add a remove function which will called if the textarea is empty. Signed-off-by: Florian Eckert --- .../luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua index 493a735bd..6c1c1235c 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua @@ -104,16 +104,17 @@ end keys = s2:option(TextValue, "_data", "") keys.wrap = "off" keys.rows = 3 -keys.rmempty = false function keys.cfgvalue() return fs.readfile("/etc/dropbear/authorized_keys") or "" end function keys.write(self, section, value) - if value then - fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n")) - end + return fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n")) +end + +function keys.remove(self, section, value) + return fs.writefile("/etc/dropbear/authorized_keys", "") end end -- cgit v1.2.3