mirror of
https://github.com/kepler155c/opus
synced 2025-04-07 08:06:54 +00:00
Sanitize label in samba.lua
Prevent labels from having .., /, *, control characters, or quotes (this generally messes things up) and limit them to a reasonable length. We might possibly also want to do this in snmp.lua, I'm not sure if that will break things though
This commit is contained in:
parent
f7ba900930
commit
8fbcc7b8bc
@ -59,6 +59,10 @@ local function sambaConnection(socket)
|
||||
print('samba: Connection closed')
|
||||
end
|
||||
|
||||
local function sanitizeLabel(computer)
|
||||
return (computer.id.."_"..computer.label:gsub("[%c%.\"'/%*]", "")):sub(64)
|
||||
end
|
||||
|
||||
Event.addRoutine(function()
|
||||
print('samba: listening on port 139')
|
||||
|
||||
@ -79,10 +83,10 @@ Event.addRoutine(function()
|
||||
end)
|
||||
|
||||
Event.on('network_attach', function(_, computer)
|
||||
fs.mount(fs.combine('network', computer.label), 'netfs', computer.id)
|
||||
fs.mount(fs.combine('network', sanitizeLabel(computer)), 'netfs', computer.id)
|
||||
end)
|
||||
|
||||
Event.on('network_detach', function(_, computer)
|
||||
print('samba: detaching ' .. computer.label)
|
||||
fs.unmount(fs.combine('network', computer.label))
|
||||
print('samba: detaching ' .. sanitizeLabel(computer))
|
||||
fs.unmount(fs.combine('network', sanitizeLabel(computer)))
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user