Replace Dos line endings with Unix ones where needed
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_system / sshkeys.lua
index a204d42..26410c9 100644 (file)
@@ -17,6 +17,7 @@ local keyfile = "/etc/dropbear/authorized_keys"
 f = SimpleForm("sshkeys", translate("a_s_sshkeys"), translate("a_s_sshkeys1"))
 
 t = f:field(TextValue, "keys")
+t.rmempty = true
 t.rows = 10
 function t.cfgvalue()
        return luci.fs.readfile(keyfile) or ""
@@ -24,11 +25,11 @@ end
 
 function f.handle(self, state, data)
        if state == FORM_VALID then
-               if (luci.fs.readfile(keyfile) or "") ~= data.keys then
-                       luci.fs.writefile(keyfile, data.keys)
+               if data.keys then
+                       luci.fs.writefile(keyfile, data.keys:gsub("\r\n", "\n"))
                end
        end
        return true
 end
 
-return f
\ No newline at end of file
+return f