1
0
mirror of https://github.com/kepler155c/opus synced 2025-02-09 05:20:04 +00:00

security cleanup

This commit is contained in:
kepler155c@gmail.com 2017-05-13 21:05:05 -04:00
parent 6f62d59108
commit 4cbb2b2257
4 changed files with 17 additions and 16 deletions

View File

@ -22,6 +22,7 @@ local page = UI.Page {
buttons = { buttons = {
{ text = 'Telnet', event = 'telnet' }, { text = 'Telnet', event = 'telnet' },
{ text = 'VNC', event = 'vnc' }, { text = 'VNC', event = 'vnc' },
{ text = 'Trust', event = 'trust' },
{ text = 'Reboot', event = 'reboot' }, { text = 'Reboot', event = 'reboot' },
}, },
}, },
@ -39,7 +40,7 @@ local page = UI.Page {
}, },
} }
function sendCommand(host, command) local function sendCommand(host, command)
if not device.wireless_modem then if not device.wireless_modem then
page.notification:error('Wireless modem not present') page.notification:error('Wireless modem not present')
@ -76,6 +77,8 @@ function page:eventHandler(event)
args = { t.id }, args = { t.id },
title = t.label, title = t.label,
}) })
elseif event.type == 'trust' then
shell.run('trust ' .. t.id)
elseif event.type == 'reboot' then elseif event.type == 'reboot' then
sendCommand(t.id, 'reboot') sendCommand(t.id, 'reboot')
elseif event.type == 'shutdown' then elseif event.type == 'shutdown' then

View File

@ -1,20 +1,10 @@
require = requireInjector(getfenv(1)) require = requireInjector(getfenv(1))
local Config = require('config')
local SHA1 = require('sha1') local SHA1 = require('sha1')
local Terminal = require('terminal') local Terminal = require('terminal')
local config = {
enable = false,
pocketId = 10,
distance = 8,
}
Config.load('os', config)
local password = Terminal.readPassword('Enter new password: ') local password = Terminal.readPassword('Enter new password: ')
if password then if password then
config.password = SHA1.sha1(password) os.updatePassword(SHA1.sha1(password))
Config.update('os', config)
print('Password updated') print('Password updated')
end end

View File

@ -61,10 +61,18 @@ function os.verifyPassword(password)
end end
function os.getSecretKey() function os.getSecretKey()
if not fs.exists('.secret') then Config.load('os', config)
Util.writeFile('.secret', math.random(100000, 999999)) if not os.secretKey then
os.secretKey = math.random(100000, 999999)
Config.update('os', config)
end end
return Util.readFile('.secret') return os.secretKey
end
function os.updatePassword(password)
Config.load('os', config)
config.password = password
Config.update('os', config)
end end
function os.getPassword() function os.getPassword()

View File

@ -24,7 +24,7 @@ process:newThread('trust_server', function()
socket:write('Trust accepted') socket:write('Trust accepted')
else else
socket:write('Invalid password or password is not set') socket:write('Invalid password')
end end
end end
end end