diff options
Diffstat (limited to 'modules/luci-mod-system')
12 files changed, 462 insertions, 621 deletions
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/password.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/password.js new file mode 100644 index 0000000000..7a79d7e2da --- /dev/null +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/password.js @@ -0,0 +1,31 @@ +function submitPassword(ev) { + var pw1 = document.body.querySelector('[name="pw1"]'), + pw2 = document.body.querySelector('[name="pw2"]'); + + if (!pw1.value.length || !pw2.value.length) + return; + + if (pw1.value === pw2.value) { + L.showModal(_('Change login password'), + E('p', { class: 'spinning' }, _('Changing password…'))); + + L.post('admin/system/admin/password/json', { password: pw1.value }, + function() { + showModal(_('Change login password'), [ + E('div', _('The system password has been successfully changed.')), + E('div', { 'class': 'right' }, + E('div', { class: 'btn', click: L.hideModal }, _('Dismiss'))) + ]); + + pw1.value = pw2.value = ''; + }); + } + else { + L.showModal(_('Change login password'), [ + E('div', { class: 'alert-message warning' }, + _('Given password confirmation did not match, password not changed!')), + E('div', { 'class': 'right' }, + E('div', { class: 'btn', click: L.hideModal }, _('Dismiss'))) + ]); + } +} diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/sshkeys.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/sshkeys.js new file mode 100644 index 0000000000..d298b3be98 --- /dev/null +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/sshkeys.js @@ -0,0 +1,215 @@ +SSHPubkeyDecoder.prototype = { + lengthDecode: function(s, off) + { + var l = (s.charCodeAt(off++) << 24) | + (s.charCodeAt(off++) << 16) | + (s.charCodeAt(off++) << 8) | + s.charCodeAt(off++); + + if (l < 0 || (off + l) > s.length) + return -1; + + return l; + }, + + decode: function(s) + { + var parts = s.split(/\s+/); + if (parts.length < 2) + return null; + + var key = null; + try { key = atob(parts[1]); } catch(e) {} + if (!key) + return null; + + var off, len; + + off = 0; + len = this.lengthDecode(key, off); + + if (len <= 0) + return null; + + var type = key.substr(off + 4, len); + if (type !== parts[0]) + return null; + + off += 4 + len; + + var len1 = off < key.length ? this.lengthDecode(key, off) : 0; + if (len1 <= 0) + return null; + + var curve = null; + if (type.indexOf('ecdsa-sha2-') === 0) { + curve = key.substr(off + 4, len1); + + if (!len1 || type.substr(11) !== curve) + return null; + + type = 'ecdsa-sha2'; + curve = curve.replace(/^nistp(\d+)$/, 'NIST P-$1'); + } + + off += 4 + len1; + + var len2 = off < key.length ? this.lengthDecode(key, off) : 0; + if (len2 < 0) + return null; + + if (len1 & 1) + len1--; + + if (len2 & 1) + len2--; + + var comment = parts.slice(2).join(' '), + fprint = parts[1].length > 68 ? parts[1].substr(0, 33) + '…' + parts[1].substr(-34) : parts[1]; + + switch (type) + { + case 'ssh-rsa': + return { type: 'RSA', bits: len2 * 8, comment: comment, fprint: fprint }; + + case 'ssh-dss': + return { type: 'DSA', bits: len1 * 8, comment: comment, fprint: fprint }; + + case 'ssh-ed25519': + return { type: 'ECDH', curve: 'Curve25519', comment: comment, fprint: fprint }; + + case 'ecdsa-sha2': + return { type: 'ECDSA', curve: curve, comment: comment, fprint: fprint }; + + default: + return null; + } + } +}; + +function SSHPubkeyDecoder() {} + +function renderKeys(keys) { + var list = document.querySelector('.cbi-dynlist[name="sshkeys"]'), + decoder = new SSHPubkeyDecoder(); + + while (!matchesElem(list.firstElementChild, '.add-item')) + list.removeChild(list.firstElementChild); + + keys.forEach(function(key) { + var pubkey = decoder.decode(key); + if (pubkey) + list.insertBefore(E('div', { + class: 'item', + click: removeKey, + 'data-key': key + }, [ + E('strong', pubkey.comment || _('Unnamed key')), E('br'), + E('small', [ + '%s, %s'.format(pubkey.type, pubkey.curve || _('%d Bit').format(pubkey.bits)), + E('br'), E('code', pubkey.fprint) + ]) + ]), list.lastElementChild); + }); + + if (list.firstElementChild === list.lastElementChild) + list.insertBefore(E('p', _('No public keys present yet.')), list.lastElementChild); +} + +function saveKeys(keys) { + L.showModal(_('Add key'), E('div', { class: 'spinning' }, _('Saving keys…'))); + L.post('admin/system/admin/sshkeys/json', { keys: JSON.stringify(keys) }, function(xhr, keys) { + renderKeys(keys); + L.hideModal(); + }); +} + +function addKey(ev) { + var decoder = new SSHPubkeyDecoder(), + list = findParent(ev.target, '.cbi-dynlist'), + input = list.querySelector('input[type="text"]'), + key = input.value.trim(), + pubkey = decoder.decode(key), + keys = []; + + if (!key.length) + return; + + list.querySelectorAll('.item').forEach(function(item) { + keys.push(item.getAttribute('data-key')); + }); + + if (keys.indexOf(key) !== -1) { + L.showModal(_('Add key'), [ + E('div', { class: 'alert-message warning' }, _('The given SSH public key has already been added.')), + E('div', { class: 'right' }, E('div', { class: 'btn', click: L.hideModal }, _('Close'))) + ]); + } + else if (!pubkey) { + L.showModal(_('Add key'), [ + E('div', { class: 'alert-message warning' }, _('The given SSH public key is invalid. Please supply proper public RSA or ECDSA keys.')), + E('div', { class: 'right' }, E('div', { class: 'btn', click: L.hideModal }, _('Close'))) + ]); + } + else { + keys.push(key); + saveKeys(keys); + input.value = ''; + } +} + +function removeKey(ev) { + var list = findParent(ev.target, '.cbi-dynlist'), + delkey = ev.target.getAttribute('data-key'), + keys = []; + + list.querySelectorAll('.item').forEach(function(item) { + var key = item.getAttribute('data-key'); + if (key !== delkey) + keys.push(key); + }); + + L.showModal(_('Delete key'), [ + E('div', _('Do you really want to delete the following SSH key?')), + E('pre', delkey), + E('div', { class: 'right' }, [ + E('div', { class: 'btn', click: L.hideModal }, _('Cancel')), + ' ', + E('div', { class: 'btn danger', click: function(ev) { saveKeys(keys) } }, _('Delete key')), + ]) + ]); +} + +function dragKey(ev) { + ev.stopPropagation(); + ev.preventDefault(); + ev.dataTransfer.dropEffect = 'copy'; +} + +function dropKey(ev) { + var file = ev.dataTransfer.files[0], + input = ev.currentTarget.querySelector('input[type="text"]'), + reader = new FileReader(); + + if (file) { + reader.onload = function(rev) { + input.value = rev.target.result.trim(); + addKey(ev); + input.value = ''; + }; + + reader.readAsText(file); + } + + ev.stopPropagation(); + ev.preventDefault(); +} + +window.addEventListener('dragover', function(ev) { ev.preventDefault() }); +window.addEventListener('drop', function(ev) { ev.preventDefault() }); + +requestAnimationFrame(function() { + L.get('admin/system/admin/sshkeys/json', null, function(xhr, keys) { + renderKeys(keys); + }); +}); diff --git a/modules/luci-mod-system/luasrc/controller/admin/system.lua b/modules/luci-mod-system/luasrc/controller/admin/system.lua index 4e83769ee0..3e58896d63 100644 --- a/modules/luci-mod-system/luasrc/controller/admin/system.lua +++ b/modules/luci-mod-system/luasrc/controller/admin/system.lua @@ -10,11 +10,14 @@ function index() entry({"admin", "system", "system"}, cbi("admin_system/system"), _("System"), 1) entry({"admin", "system", "clock_status"}, post_on({ set = true }, "action_clock_status")) - entry({"admin", "system", "admin"}, cbi("admin_system/admin"), _("Administration"), 2) - - if fs.access("/bin/opkg") then - entry({"admin", "system", "packages"}, post_on({ exec = "1" }, "action_packages"), _("Software"), 10) - entry({"admin", "system", "packages", "ipkg"}, form("admin_system/ipkg")) + entry({"admin", "system", "admin"}, firstchild(), _("Administration"), 2) + entry({"admin", "system", "admin", "password"}, template("admin_system/password"), _("Router Password"), 1) + entry({"admin", "system", "admin", "password", "json"}, post("action_password")) + + if fs.access("/etc/config/dropbear") then + entry({"admin", "system", "admin", "dropbear"}, cbi("admin_system/dropbear"), _("SSH Access"), 2) + entry({"admin", "system", "admin", "sshkeys"}, template("admin_system/sshkeys"), _("SSH-Keys"), 3) + entry({"admin", "system", "admin", "sshkeys", "json"}, post_on({ keys = true }, "action_sshkeys")) end entry({"admin", "system", "startup"}, form("admin_system/startup"), _("Startup"), 45) @@ -61,124 +64,6 @@ function action_clock_status() luci.http.write_json({ timestring = os.date("%c") }) end -function action_packages() - local fs = require "nixio.fs" - local ipkg = require "luci.model.ipkg" - local submit = (luci.http.formvalue("exec") == "1") - local update, upgrade - local changes = false - local install = { } - local remove = { } - local stdout = { "" } - local stderr = { "" } - local out, err - - -- Display - local display = luci.http.formvalue("display") or "available" - - -- Letter - local letter = string.byte(luci.http.formvalue("letter") or "A", 1) - letter = (letter == 35 or (letter >= 65 and letter <= 90)) and letter or 65 - - -- Search query - local query = luci.http.formvalue("query") - query = (query ~= '') and query or nil - - - -- Modifying actions - if submit then - -- Packets to be installed - local ninst = luci.http.formvalue("install") - local uinst = nil - - -- Install from URL - local url = luci.http.formvalue("url") - if url and url ~= '' then - uinst = url - end - - -- Do install - if ninst then - install[ninst], out, err = ipkg.install(ninst) - stdout[#stdout+1] = out - stderr[#stderr+1] = err - changes = true - end - - if uinst then - local pkg - for pkg in luci.util.imatch(uinst) do - install[uinst], out, err = ipkg.install(pkg) - stdout[#stdout+1] = out - stderr[#stderr+1] = err - changes = true - end - end - - -- Remove packets - local rem = luci.http.formvalue("remove") - if rem then - remove[rem], out, err = ipkg.remove(rem) - stdout[#stdout+1] = out - stderr[#stderr+1] = err - changes = true - end - - - -- Update all packets - update = luci.http.formvalue("update") - if update then - update, out, err = ipkg.update() - stdout[#stdout+1] = out - stderr[#stderr+1] = err - end - - - -- Upgrade all packets - upgrade = luci.http.formvalue("upgrade") - if upgrade then - upgrade, out, err = ipkg.upgrade() - stdout[#stdout+1] = out - stderr[#stderr+1] = err - end - end - - - -- List state - local no_lists = true - local old_lists = false - if fs.access("/var/opkg-lists/") then - local list - for list in fs.dir("/var/opkg-lists/") do - no_lists = false - if (fs.stat("/var/opkg-lists/"..list, "mtime") or 0) < (os.time() - (24 * 60 * 60)) then - old_lists = true - break - end - end - end - - - luci.template.render("admin_system/packages", { - display = display, - letter = letter, - query = query, - install = install, - remove = remove, - update = update, - upgrade = upgrade, - no_lists = no_lists, - old_lists = old_lists, - stdout = table.concat(stdout, ""), - stderr = table.concat(stderr, "") - }) - - -- Remove index cache - if changes then - fs.unlink("/tmp/luci-indexcache") - end -end - local function image_supported(image) return (os.execute("sysupgrade -T %q >/dev/null" % image) == 0) end @@ -301,38 +186,32 @@ function action_sysupgrade() msg = luci.i18n.translate("The system is flashing now.<br /> DO NOT POWER OFF THE DEVICE!<br /> Wait a few minutes before you try to reconnect. It might be necessary to renew the address of your computer to reach the device again, depending on your settings."), addr = (#keep > 0) and (#force > 0) and "192.168.1.1" or nil }) - fork_exec("sleep 1; killall dropbear uhttpd; sleep 1; /sbin/sysupgrade %s %s %q" %{ keep, force, image_tmp }) + luci.sys.process.exec({ "/bin/sh", "-c","sleep 1; killall dropbear uhttpd; sleep 1; /sbin/sysupgrade %s %s %q" %{ keep, force, image_tmp } }, nil, nil, true) end end function action_backup() - local reader = ltn12_popen("sysupgrade --create-backup - 2>/dev/null") - - luci.http.header( - 'Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' %{ - luci.sys.hostname(), - os.date("%Y-%m-%d") - }) + luci.http.header('Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' + %{ luci.sys.hostname(), os.date("%Y-%m-%d") }) luci.http.prepare_content("application/x-targz") - luci.ltn12.pump.all(reader, luci.http.write) + luci.sys.process.exec({ "/sbin/sysupgrade", "--create-backup", "-" }, luci.http.write) end function action_backupmtdblock() - local http = require "luci.http" - local mv = http.formvalue("mtdblockname") - local m, s, n = mv:match('^([^%s]+)/([^%s]+)/([^%s]+)') + local mv = luci.http.formvalue("mtdblockname") or "" + local m, n = mv:match('^([^%s%./"]+)/%d+/(%d+)$') - local reader = ltn12_popen("dd if=/dev/mtd%s conv=fsync,notrunc 2>/dev/null" % n) + if not m and n then + luci.http.status(400, "Bad Request") + return + end - luci.http.header( - 'Content-Disposition', 'attachment; filename="backup-%s-%s-%s.bin"' %{ - luci.sys.hostname(), m, - os.date("%Y-%m-%d") - }) + luci.http.header('Content-Disposition', 'attachment; filename="backup-%s-%s-%s.bin"' + %{ luci.sys.hostname(), m, os.date("%Y-%m-%d") }) luci.http.prepare_content("application/octet-stream") - luci.ltn12.pump.all(reader, luci.http.write) + luci.sys.process.exec({ "/bin/dd", "if=/dev/mtd%s" % n, "conv=fsync,notrunc" }, luci.http.write) end function action_restore() @@ -387,83 +266,74 @@ function action_reset() addr = "192.168.1.1" }) - fork_exec("sleep 1; killall dropbear uhttpd; sleep 1; jffs2reset -y && reboot") + luci.sys.process.exec({ "/bin/sh", "-c", "sleep 1; killall dropbear uhttpd; sleep 1; jffs2reset -y && reboot" }, nil, nil, true) return end http.redirect(luci.dispatcher.build_url('admin/system/flashops')) end -function action_passwd() - local p1 = luci.http.formvalue("pwd1") - local p2 = luci.http.formvalue("pwd2") - local stat = nil - - if p1 or p2 then - if p1 == p2 then - stat = luci.sys.user.setpasswd("root", p1) - else - stat = 10 - end +function action_password() + local password = luci.http.formvalue("password") + if not password then + luci.http.status(400, "Bad Request") + return end - luci.template.render("admin_system/passwd", {stat=stat}) + luci.http.prepare_content("application/json") + luci.http.write_json({ code = luci.sys.user.setpasswd("root", password) }) end -function action_reboot() - luci.sys.reboot() -end +function action_sshkeys() + local keys = luci.http.formvalue("keys") + if keys then + keys = luci.jsonc.parse(keys) + if not keys or type(keys) ~= "table" then + luci.http.status(400, "Bad Request") + return + end -function fork_exec(command) - local pid = nixio.fork() - if pid > 0 then - return - elseif pid == 0 then - -- change to root dir - nixio.chdir("/") - - -- patch stdin, out, err to /dev/null - local null = nixio.open("/dev/null", "w+") - if null then - nixio.dup(null, nixio.stderr) - nixio.dup(null, nixio.stdout) - nixio.dup(null, nixio.stdin) - if null:fileno() > 2 then - null:close() + local fd, err = io.open("/etc/dropbear/authorized_keys", "w") + if not fd then + luci.http.status(503, err) + return + end + + local _, k + for _, k in ipairs(keys) do + if type(k) == "string" and k:match("^%w+%-") then + fd:write(k) + fd:write("\n") end end - -- replace with target command - nixio.exec("/bin/sh", "-c", command) + fd:close() end -end - -function ltn12_popen(command) - - local fdi, fdo = nixio.pipe() - local pid = nixio.fork() - if pid > 0 then - fdo:close() - local close - return function() - local buffer = fdi:read(2048) - local wpid, stat = nixio.waitpid(pid, "nohang") - if not close and wpid and stat == "exited" then - close = true - end + local fd, err = io.open("/etc/dropbear/authorized_keys", "r") + if not fd then + luci.http.status(503, err) + return + end - if buffer and #buffer > 0 then - return buffer - elseif close then - fdi:close() - return nil - end + local rv = {} + while true do + local ln = fd:read("*l") + if not ln then + break + elseif ln:match("^[%w%-]+%s+[A-Za-z0-9+/=]+$") or + ln:match("^[%w%-]+%s+[A-Za-z0-9+/=]+%s") + then + rv[#rv+1] = ln end - elseif pid == 0 then - nixio.dup(fdo, nixio.stdout) - fdi:close() - fdo:close() - nixio.exec("/bin/sh", "-c", command) end + + fd:close() + + luci.http.prepare_content("application/json") + luci.http.write_json(rv) +end + +function action_reboot() + luci.sys.reboot() end diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/admin.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/admin.lua deleted file mode 100644 index 34289533bf..0000000000 --- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/admin.lua +++ /dev/null @@ -1,124 +0,0 @@ --- Copyright 2008 Steven Barth <steven@midlink.org> --- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org> --- Licensed to the public under the Apache License 2.0. - -local fs = require "nixio.fs" - -m = Map("system", translate("Router Password"), - translate("Changes the administrator password for accessing the device")) -m.apply_on_parse = true - -s = m:section(TypedSection, "_dummy", "") -s.addremove = false -s.anonymous = true - -pw1 = s:option(Value, "pw1", translate("Password")) -pw1.password = true - -pw2 = s:option(Value, "pw2", translate("Confirmation")) -pw2.password = true - -function s.cfgsections() - return { "_pass" } -end - -function m.parse(map) - local v1 = pw1:formvalue("_pass") - local v2 = pw2:formvalue("_pass") - - if v1 and v2 and #v1 > 0 and #v2 > 0 then - if v1 == v2 then - if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then - m.message = translate("Password successfully changed!") - else - m.message = translate("Unknown Error, password not changed!") - end - else - m.message = translate("Given password confirmation did not match, password not changed!") - end - end - - Map.parse(map) -end - - -if fs.access("/etc/config/dropbear") then - -m2 = Map("dropbear", translate("SSH Access"), - translate("Dropbear offers <abbr title=\"Secure Shell\">SSH</abbr> network shell access and an integrated <abbr title=\"Secure Copy\">SCP</abbr> server")) -m2.apply_on_parse = true - -s = m2:section(TypedSection, "dropbear", translate("Dropbear Instance")) -s.anonymous = true -s.addremove = true - - -ni = s:option(Value, "Interface", translate("Interface"), - translate("Listen only on the given interface or, if unspecified, on all")) - -ni.template = "cbi/network_netlist" -ni.nocreate = true -ni.unspecified = true - - -pt = s:option(Value, "Port", translate("Port"), - translate("Specifies the listening port of this <em>Dropbear</em> instance")) - -pt.datatype = "port" -pt.default = 22 - - -pa = s:option(Flag, "PasswordAuth", translate("Password authentication"), - translate("Allow <abbr title=\"Secure Shell\">SSH</abbr> password authentication")) - -pa.enabled = "on" -pa.disabled = "off" -pa.default = pa.enabled -pa.rmempty = false - - -ra = s:option(Flag, "RootPasswordAuth", translate("Allow root logins with password"), - translate("Allow the <em>root</em> user to login with password")) - -ra.enabled = "on" -ra.disabled = "off" -ra.default = ra.enabled - - -gp = s:option(Flag, "GatewayPorts", translate("Gateway ports"), - translate("Allow remote hosts to connect to local SSH forwarded ports")) - -gp.enabled = "on" -gp.disabled = "off" -gp.default = gp.disabled - - -s2 = m2:section(TypedSection, "_dummy", translate("SSH-Keys"), - translate("Here you can paste public SSH-Keys (one per line) for SSH public-key authentication.")) -s2.addremove = false -s2.anonymous = true -s2.template = "cbi/tblsection" - -function s2.cfgsections() - return { "_keys" } -end - -keys = s2:option(TextValue, "_data", "") -keys.wrap = "off" -keys.rows = 3 - -function keys.cfgvalue() - return fs.readfile("/etc/dropbear/authorized_keys") or "" -end - -function keys.write(self, section, value) - 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 - -return m, m2 diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/dropbear.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/dropbear.lua new file mode 100644 index 0000000000..1a1695d2be --- /dev/null +++ b/modules/luci-mod-system/luasrc/model/cbi/admin_system/dropbear.lua @@ -0,0 +1,53 @@ +-- Copyright 2008 Steven Barth <steven@midlink.org> +-- Copyright 2011-2018 Jo-Philipp Wich <jo@mein.io> +-- Licensed to the public under the Apache License 2.0. + +m = Map("dropbear", translate("SSH Access"), + translate("Dropbear offers <abbr title=\"Secure Shell\">SSH</abbr> network shell access and an integrated <abbr title=\"Secure Copy\">SCP</abbr> server")) +m.apply_on_parse = true + +s = m:section(TypedSection, "dropbear", translate("Dropbear Instance")) +s.anonymous = true +s.addremove = true + + +ni = s:option(Value, "Interface", translate("Interface"), + translate("Listen only on the given interface or, if unspecified, on all")) + +ni.template = "cbi/network_netlist" +ni.nocreate = true +ni.unspecified = true + + +pt = s:option(Value, "Port", translate("Port"), + translate("Specifies the listening port of this <em>Dropbear</em> instance")) + +pt.datatype = "port" +pt.default = 22 + + +pa = s:option(Flag, "PasswordAuth", translate("Password authentication"), + translate("Allow <abbr title=\"Secure Shell\">SSH</abbr> password authentication")) + +pa.enabled = "on" +pa.disabled = "off" +pa.default = pa.enabled +pa.rmempty = false + + +ra = s:option(Flag, "RootPasswordAuth", translate("Allow root logins with password"), + translate("Allow the <em>root</em> user to login with password")) + +ra.enabled = "on" +ra.disabled = "off" +ra.default = ra.enabled + + +gp = s:option(Flag, "GatewayPorts", translate("Gateway ports"), + translate("Allow remote hosts to connect to local SSH forwarded ports")) + +gp.enabled = "on" +gp.disabled = "off" +gp.default = gp.disabled + +return m diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/fstab.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/fstab.lua index 6f0921fdcf..4a31146a03 100644 --- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/fstab.lua +++ b/modules/luci-mod-system/luasrc/model/cbi/admin_system/fstab.lua @@ -117,14 +117,14 @@ function used.cfgvalue(self, section) end unmount = v:option(Button, "unmount", translate("Unmount")) +function unmount.cfgvalue(self, section) + return non_system_mounts[section].umount +end + unmount.render = function(self, section, scope) - if non_system_mounts[section].umount then - self.title = translate("Unmount") - self.inputstyle = "remove" - Button.render(self, section, scope) - else - luci.http.write(" ") - end + self.title = translate("Unmount") + self.inputstyle = "remove" + Button.render(self, section, scope) end unmount.write = function(self, section) diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/ipkg.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/ipkg.lua deleted file mode 100644 index 7c6d7e1c66..0000000000 --- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/ipkg.lua +++ /dev/null @@ -1,64 +0,0 @@ --- Copyright 2008 Steven Barth <steven@midlink.org> --- Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org> --- Licensed to the public under the Apache License 2.0. - -local ipkgfile = "/etc/opkg.conf" -local distfeeds = "/etc/opkg/distfeeds.conf" -local customfeeds = "/etc/opkg/customfeeds.conf" - -f = SimpleForm("ipkgconf", translate("OPKG-Configuration"), translate("General options for opkg")) - -f:append(Template("admin_system/ipkg")) - -t = f:field(TextValue, "lines") -t.wrap = "off" -t.rows = 10 -function t.cfgvalue() - return nixio.fs.readfile(ipkgfile) or "" -end - -function t.write(self, section, data) - return nixio.fs.writefile(ipkgfile, data:gsub("\r\n", "\n")) -end - -function f.handle(self, state, data) - return true -end - -g = SimpleForm("distfeedconf", translate("Distribution feeds"), - translate("Build/distribution specific feed definitions. This file will NOT be preserved in any sysupgrade.")) - -d = g:field(TextValue, "lines2") -d.wrap = "off" -d.rows = 10 -function d.cfgvalue() - return nixio.fs.readfile(distfeeds) or "" -end - -function d.write(self, section, data) - return nixio.fs.writefile(distfeeds, data:gsub("\r\n", "\n")) -end - -function g.handle(self, state, data) - return true -end - -h = SimpleForm("customfeedconf", translate("Custom feeds"), - translate("Custom feed definitions, e.g. private feeds. This file can be preserved in a sysupgrade.")) - -c = h:field(TextValue, "lines3") -c.wrap = "off" -c.rows = 10 -function c.cfgvalue() - return nixio.fs.readfile(customfeeds) or "" -end - -function c.write(self, section, data) - return nixio.fs.writefile(customfeeds, data:gsub("\r\n", "\n")) -end - -function h.handle(self, state, data) - return true -end - -return f, g, h diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/system.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/system.lua index 7558d42161..c26fd475a4 100644 --- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/system.lua +++ b/modules/luci-mod-system/luasrc/model/cbi/admin_system/system.lua @@ -153,7 +153,7 @@ function o.write(self, section, value) end -o = s:taboption("language", ListValue, "_mediaurlbase", translate("Design")) +o = s:taboption("language", ListValue, "_mediaurlbase", translate("Theme")) for k, v in pairs(conf.themes) do if k:sub(1, 1) ~= "." then o:value(v, k) diff --git a/modules/luci-mod-system/luasrc/view/admin_system/ipkg.htm b/modules/luci-mod-system/luasrc/view/admin_system/ipkg.htm deleted file mode 100644 index a7ff4e50bd..0000000000 --- a/modules/luci-mod-system/luasrc/view/admin_system/ipkg.htm +++ /dev/null @@ -1,10 +0,0 @@ -<%# - Copyright 2008 Steven Barth <steven@midlink.org> - Copyright 2008 Jo-Philipp Wich <jow@openwrt.org> - Licensed to the public under the Apache License 2.0. --%> - -<ul class="cbi-tabmenu"> - <li class="cbi-tab-disabled"><a href="<%=url("admin/system/packages")%>"><%:Actions%></a></li> - <li class="cbi-tab"><a href="#"><%:Configuration%></a></li> -</ul> diff --git a/modules/luci-mod-system/luasrc/view/admin_system/packages.htm b/modules/luci-mod-system/luasrc/view/admin_system/packages.htm deleted file mode 100644 index 9e364d69ae..0000000000 --- a/modules/luci-mod-system/luasrc/view/admin_system/packages.htm +++ /dev/null @@ -1,213 +0,0 @@ -<%# - Copyright 2008 Steven Barth <steven@midlink.org> - Copyright 2008-2010 Jo-Philipp Wich <jow@openwrt.org> - Licensed to the public under the Apache License 2.0. --%> - -<%- -local opkg = require "luci.model.ipkg" -local fs = require "nixio.fs" -local wa = require "luci.tools.webadmin" -local rowcnt = 1 - -function rowstyle() - rowcnt = rowcnt + 1 - return (rowcnt % 2) + 1 -end - -local fstat = fs.statvfs(opkg.overlay_root()) -local space_total = fstat and fstat.blocks or 0 -local space_free = fstat and fstat.bfree or 0 -local space_used = space_total - space_free - -local used_perc = math.floor(0.5 + ((space_total > 0) and ((100 / space_total) * space_used) or 100)) -local free_byte = space_free * fstat.frsize - -local filter = { } - - -local opkg_list = luci.model.ipkg.list_all -local querypat -if query and #query > 0 then - querypat = '*%s*' % query - opkg_list = luci.model.ipkg.find -end - -local letterpat -if letter == 35 then - letterpat = "[^a-z]*" -else - letterpat = string.char(letter, 42) -- 'A' '*' -end - --%> - -<%+header%> - - -<h2 name="content"><%:Software%></h2> - -<div class="cbi-map"> - - <ul class="cbi-tabmenu"> - <li class="cbi-tab"><a href="#"><%:Actions%></a></li> - <li class="cbi-tab-disabled"><a href="<%=REQUEST_URI%>/ipkg"><%:Configuration%></a></li> - </ul> - - <form method="post" action="<%=REQUEST_URI%>"> - <input type="hidden" name="exec" value="1" /> - <input type="hidden" name="token" value="<%=token%>" /> - - <div class="cbi-section"> - <div class="cbi-section-node"> - <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %> - <div class="cbi-value"> - <% if #stdout > 0 then %><pre><%=pcdata(stdout)%></pre><% end %> - <% if #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %> - </div> - <% end %> - - <% if querypat then %> - <div class="cbi-value"> - <%:Displaying only packages containing%> <strong>"<%=pcdata(query)%>"</strong> - <input type="button" onclick="location.href='?display=<%=luci.http.urlencode(display)%>'" href="#" class="cbi-button cbi-button-reset" style="margin-left:1em" value="<%:Reset%>" /> - <br style="clear:both" /> - </div> - <% end %> - - <% if no_lists or old_lists then %> - <div class="cbi-value"> - <% if old_lists then %> - <%:Package lists are older than 24 hours%> - <% else %> - <%:No package lists available%> - <% end %> - <input type="submit" name="update" href="#" class="cbi-button cbi-button-apply" style="margin-left:3em" value="<%:Update lists%>" /> - </div> - <% end %> - - <div class="cbi-value cbi-value-last"> - <%:Free space%>: <strong><%=(100-used_perc)%>%</strong> (<strong><%=wa.byte_format(free_byte)%></strong>) - <div style="margin:3px 0; width:300px; height:10px; border:1px solid #000000; background-color:#80C080" id="swfreespace"> - <div style="background-color:#F08080; border-right:1px solid #000000; height:100%; width:<%=used_perc%>%"> </div> - </div> - </div> - </div> - - <br /> - - <div class="cbi-section-node"> - <input type="hidden" name="display" value="<%=pcdata(display)%>" /> - - <div class="cbi-value"> - <label class="cbi-value-title"><%:Download and install package%>:</label> - <div class="cbi-value-field"> - <span><input type="text" name="url" size="30" <% if no_lists then %>disabled="disabled" placeholder="<%:Please update package lists first%>"<% end %> value="" /></span> - <input class="cbi-button cbi-button-save" type="submit" name="go" <% if no_lists then %>disabled="disabled"<% end %> value="<%:OK%>" /> - </div> - </div> - - <div class="cbi-value cbi-value-last"> - <label class="cbi-value-title"><%:Filter%>:</label> - <div class="cbi-value-field"> - <span><input type="text" name="query" size="20" <% if no_lists then %>disabled="disabled" placeholder="<%:Please update package lists first%>"<% else %>value="<%=pcdata(query)%>"<% end %> /></span> - <input type="submit" class="cbi-button cbi-button-action" name="search" <% if no_lists then %>disabled="disabled"<% end %> value="<%:Find package%>" /> - </div> - </div> - </div> - </div> - </form> - - - <h3><%:Status%></h3> - - - <ul class="cbi-tabmenu"> - <li class="cbi-tab<% if display ~= "available" then %>-disabled<% end %>"><a href="?display=available&query=<%=pcdata(query)%>"><%:Available packages%><% if query then %> (<%=pcdata(query)%>)<% end %></a></li> - <li class="cbi-tab<% if display ~= "installed" then %>-disabled<% end %>"><a href="?display=installed&query=<%=pcdata(query)%>"><%:Installed packages%><% if query then %> (<%=pcdata(query)%>)<% end %></a></li> - </ul> - - <% if display ~= "available" then %> - <div class="cbi-section"> - <div class="cbi-section-node"> - <div class="table"> - <div class="tr cbi-section-table-titles"> - <div class="th left"><%:Package name%></div> - <div class="th left"><%:Version%></div> - <div class="th cbi-section-actions"> </div> - </div> - <% local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, s, d) empty = false; filter[n] = true %> - <div class="tr cbi-rowstyle-<%=rowstyle()%>"> - <div class="td left"><%=luci.util.pcdata(n)%></div> - <div class="td left"><%=luci.util.pcdata(v)%></div> - <div class="td cbi-section-actions"> - <form method="post" class="inline" action="<%=REQUEST_URI%>"> - <input type="hidden" name="exec" value="1" /> - <input type="hidden" name="token" value="<%=token%>" /> - <input type="hidden" name="remove" value="<%=pcdata(n)%>" /> - <input class="cbi-button cbi-button-remove" type="submit" onclick="window.confirm('<%:Remove%> "<%=luci.util.pcdata(n)%>" ?') && this.parentNode.submit(); return false" value="<%:Remove%>" /> - </form> - </div> - </div> - <% end) %> - <% if empty then %> - <div class="tr cbi-section-table-row"> - <div class="td left"> </div> - <div class="td left"><em><%:none%></em></div> - <div class="td left"><em><%:none%></em></div> - </div> - <% end %> - </div> - </div> - </div> - <% else %> - <div class="cbi-section"> - <% if not querypat then %> - <ul class="cbi-tabmenu" style="flex-wrap:wrap"> - <% local i; for i = 65, 90 do %> - <li class="cbi-tab<% if letter ~= i then %>-disabled<% end %>"><a href="?display=available&letter=<%=string.char(i)%>"><%=string.char(i)%></a></li> - <% end %> - <li class="cbi-tab<% if letter ~= 35 then %>-disabled<% end %>"><a href="?display=available&letter=%23">#</a></li> - </ul> - <% end %> - <div class="cbi-section-node cbi-section-node-tabbed"> - <div class="table"> - <div class="tr cbi-section-table-titles"> - <div class="th col-2 left"><%:Package name%></div> - <div class="th col-2 left"><%:Version%></div> - <div class="th col-1 center"><%:Size (.ipk)%></div> - <div class="th col-10 left"><%:Description%></div> - <div class="th cbi-section-actions"> </div> - </div> - <% local empty = true; opkg_list(querypat or letterpat, function(n, v, s, d) if filter[n] then return end; empty = false %> - <div class="tr cbi-rowstyle-<%=rowstyle()%>"> - <div class="td col-2 left"><%=luci.util.pcdata(n)%></div> - <div class="td col-2 left"><%=luci.util.pcdata(v)%></div> - <div class="td col-1 center"><%=luci.util.pcdata(s)%></div> - <div class="td col-10 left"><%=luci.util.pcdata(d)%></div> - <div class="td cbi-section-actions"> - <form method="post" class="inline" action="<%=REQUEST_URI%>"> - <input type="hidden" name="exec" value="1" /> - <input type="hidden" name="token" value="<%=token%>" /> - <input type="hidden" name="install" value="<%=pcdata(n)%>" /> - <input class="cbi-button cbi-button-apply" type="submit" onclick="window.confirm('<%:Install%> "<%=luci.util.pcdata(n)%>" ?') && this.parentNode.submit(); return false" value="<%:Install%>" /> - </form> - </div> - </div> - <% end) %> - <% if empty then %> - <div class="tr"> - <div class="td left"> </div> - <div class="td left"><em><%:none%></em></div> - <div class="td left"><em><%:none%></em></div> - <div class="td right"><em><%:none%></em></div> - <div class="td left"><em><%:none%></em></div> - </div> - <% end %> - </div> - </div> - </div> - <% end %> -</div> - -<%+footer%> diff --git a/modules/luci-mod-system/luasrc/view/admin_system/password.htm b/modules/luci-mod-system/luasrc/view/admin_system/password.htm new file mode 100644 index 0000000000..09cea4f74a --- /dev/null +++ b/modules/luci-mod-system/luasrc/view/admin_system/password.htm @@ -0,0 +1,37 @@ +<%+header%> + +<input type="password" aria-hidden="true" style="position:absolute; left:-10000px" /> + +<div class="cbi-map"> + <h2><%:Router Password%></h2> + + <div class="cbi-section-descr"> + <%:Changes the administrator password for accessing the device%> + </div> + + <div class="cbi-section-node"> + <div class="cbi-value"> + <label class="cbi-value-title" for="image"><%:Password%></label> + <div class="cbi-value-field"> + <input type="password" name="pw1" /><!-- + --><button class="cbi-button cbi-button-neutral" title="<%:Reveal/hide password%>" aria-label="<%:Reveal/hide password%>" onclick="var e = this.previousElementSibling; e.type = (e.type === 'password') ? 'text' : 'password'">∗</button> + </div> + </div> + + <div class="cbi-value"> + <label class="cbi-value-title" for="image"><%:Confirmation%></label> + <div class="cbi-value-field"> + <input type="password" name="pw2" onkeydown="if (event.keyCode === 13) submitPassword(event)" /><!-- + --><button class="cbi-button cbi-button-neutral" title="<%:Reveal/hide password%>" aria-label="<%:Reveal/hide password%>" onclick="var e = this.previousElementSibling; e.type = (e.type === 'password') ? 'text' : 'password'">∗</button> + </div> + </div> + </div> +</div> + +<div class="cbi-page-actions"> + <button class="btn cbi-button-apply" onclick="submitPassword(event)"><%:Save%></button> +</div> + +<script type="application/javascript" src="<%=resource%>/view/system/password.js"></script> + +<%+footer%> diff --git a/modules/luci-mod-system/luasrc/view/admin_system/sshkeys.htm b/modules/luci-mod-system/luasrc/view/admin_system/sshkeys.htm new file mode 100644 index 0000000000..ac453f3f6c --- /dev/null +++ b/modules/luci-mod-system/luasrc/view/admin_system/sshkeys.htm @@ -0,0 +1,46 @@ +<%+header%> + +<style type="text/css"> + .cbi-dynlist { + max-width: 100%; + } + + .cbi-dynlist .item > small { + display: block; + direction: rtl; + overflow: hidden; + text-align: left; + } + + .cbi-dynlist .item > small > code { + direction: ltr; + white-space: nowrap; + unicode-bidi: bidi-override; + } + + @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { + .cbi-dynlist .item > small { direction: ltr } + } +</style> + +<div class="cbi-map"> + <h2><%:SSH-Keys%></h2> + + <div class="cbi-section-descr"> + <%_Public keys allow for the passwordless SSH logins with a higher security compared to the use of plain passwords. In order to upload a new key to the device, paste an OpenSSH compatible public key line or drag a <code>.pub</code> file into the input field.%> + </div> + + <div class="cbi-section-node"> + <div class="cbi-dynlist" name="sshkeys"> + <p class="spinning"><%:Loading SSH keys…%></p> + <div class="add-item" ondragover="dragKey(event)" ondrop="dropKey(event)"> + <input class="cbi-input-text" type="text" placeholder="<%:Paste or drag SSH key file…%>" onkeydown="if (event.keyCode === 13) addKey(event)" /> + <button class="cbi-button" onclick="addKey(event)"><%:Add key%></button> + </div> + </div> + </div> +</div> + +<script type="application/javascript" src="<%=resource%>/view/system/sshkeys.js"></script> + +<%+footer%> |