Change the working directory of a function or coroutine
#1
Does anyone know how to change the working directory for a function?
The idea is that if inside that function for example the "dofile" or "cFile:Exists" function is used it doesn't direct to "root/<asked file>" but "root/Plugins/MC-Web-Server/www/<asked file>"
Reply
Thanks given by:
#2
I hope this isn't possible. The working directory is process global, so the change would effect other plugins in strange ways.

What are you actually trying to do? It looks like re-implement nginx's ngx_lua module. Why? MCServer's HTTP support is crap, and really should be farmed out to an actual server.
Reply
Thanks given by:
#3
Off topic, but I really don't like the idea of a custom HTTP server. I've looked through your code, and already noticed that it doesn't handle uri encoding, and it has a path traversal vulnerability, as you don't pass a deliminator to StringSplit on host.lua line 25. Make sure you also handle \ for the path to fix problems on windows.
Reply
Thanks given by:
#4
(06-06-2015, 09:37 AM)worktycho Wrote: I hope this isn't possible. The working directory is process global, so the change would effect other plugins in strange ways.
I'm wondering what dofile is doing then. When you use for example: 'dofile("folder1/folder2/file1.lua")' then everything in file1.lua is executed in folder1/folder2.

But it turns out I have to rewrite those functions anyway, because I have to make them parse the file first.

worktycho Wrote:Off topic, but I really don't like the idea of a custom HTTP server. I've looked through your code, and already noticed that it doesn't handle uri encoding, and it has a path traversal vulnerability, as you don't pass a deliminator to StringSplit on host.lua line 25. Make sure you also handle \ for the path to fix problems on windows.
Of course, this is just me having fun with browsers and seeing how they work ^^
Reply
Thanks given by:




Users browsing this thread: 3 Guest(s)