lua: Fix kennslur location path, sanitize input

This commit is contained in:
Jonatan Nilsson 2024-02-07 21:19:37 +00:00
parent c8774ded51
commit 8334dc2924
4 changed files with 11 additions and 20 deletions

View file

@ -1,16 +0,0 @@
[supervisord]
loglevel=info
nodaemon=true
user=root
[program:nginx]
command=/usr/local/nginx/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
priority=10
stdout_events_enabled=true
stderr_events_enabled=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

View file

@ -4,7 +4,7 @@ local function ends_with(str, ending)
return ending == "" or str:sub(-#ending) == ending return ending == "" or str:sub(-#ending) == ending
end end
local p = io.popen('ls -a "/content/kennslur"') local p = io.popen('ls -a "/srv/filo_web/kennslur"')
for file in p:lines() do for file in p:lines() do
if ends_with(file, '.mp4') and not ends_with(file, 'klippt.mp4') then if ends_with(file, '.mp4') and not ends_with(file, 'klippt.mp4') then
table.insert(files, file) table.insert(files, file)

View file

@ -21,7 +21,7 @@ local function ends_with(str, ending)
return ending == "" or str:sub(-#ending) == ending return ending == "" or str:sub(-#ending) == ending
end end
local p = io.popen('ls -a "/content/kennslur"') local p = io.popen('ls -a "/srv/filo_web/kennslur"')
for file in p:lines() do for file in p:lines() do
if ends_with(file, '.mp4') and not ends_with(file, 'klippt.mp4') then if ends_with(file, '.mp4') and not ends_with(file, 'klippt.mp4') then
table.insert(files, file) table.insert(files, file)

View file

@ -1,9 +1,16 @@
if not ngx.var.arg_output then local arg_output = ngx.var.arg_output
if not arg_output then
ngx.say("Missing query 'output'") ngx.say("Missing query 'output'")
return return
end end
assert(io.popen("/usr/bin/ffmpeg -y -i 'rtmp://192.168.93.59:1935/live/ljosbrot live=1' -vcodec copy -acodec copy /content/kennslur/".. ngx.var.arg_output ..".mp4 </dev/null >/dev/null 2>/dev/null &")) if not (arg_output:gsub("[A-Za-z0-9_.]","")=="") then
ngx.say("Invalid query 'output'")
return
end
assert(io.popen("/usr/bin/ffmpeg -y -i 'rtmp://192.168.93.58:1935/live/ljosbrot live=1' -vcodec copy -acodec copy /srv/filo_web/kennslur/".. arg_output ..".mp4 </dev/null >/dev/null 2>/dev/null &"))
ngx.say([[ ngx.say([[
<br> <br>
<input type="button" value="Stodva upptoku" onclick="window.location='stop_recording.php';return false;"> <input type="button" value="Stodva upptoku" onclick="window.location='stop_recording.php';return false;">