harden runtime config and docs
This commit is contained in:
+22
-5
@@ -876,7 +876,6 @@ String shell_exec(String cmd)
|
||||
|
||||
String shell_escape(String raw)
|
||||
{
|
||||
// FIXME
|
||||
String result = "";
|
||||
for(auto c : raw)
|
||||
{
|
||||
@@ -971,8 +970,12 @@ bool path_is_within(String path, String root)
|
||||
|
||||
bool mkdir(String path)
|
||||
{
|
||||
shell_exec(String("mkdir -p ")+" "+shell_escape(path));
|
||||
return(true);
|
||||
if(path == "")
|
||||
return(false);
|
||||
std::error_code ec;
|
||||
if(std::filesystem::exists(path, ec))
|
||||
return(std::filesystem::is_directory(path, ec));
|
||||
return(std::filesystem::create_directories(path, ec) || std::filesystem::is_directory(path, ec));
|
||||
}
|
||||
|
||||
bool file_exists(String path)
|
||||
@@ -1605,7 +1608,18 @@ void on_child_exit(int sig)
|
||||
|
||||
StringList ls(String dir)
|
||||
{
|
||||
return(split(trim(shell_exec("ls -1 "+shell_escape(dir))), "\n"));
|
||||
StringList entries;
|
||||
std::error_code ec;
|
||||
if(!std::filesystem::is_directory(dir, ec))
|
||||
return(entries);
|
||||
for(auto const& entry : std::filesystem::directory_iterator(dir, ec))
|
||||
{
|
||||
if(ec)
|
||||
break;
|
||||
entries.push_back(entry.path().filename().string());
|
||||
}
|
||||
std::sort(entries.begin(), entries.end());
|
||||
return(entries);
|
||||
}
|
||||
|
||||
StringMap make_server_settings()
|
||||
@@ -1622,8 +1636,10 @@ StringMap make_server_settings()
|
||||
cfg["SETUP_TEMPLATE"] = "scripts/setup.h.template";
|
||||
cfg["LIT_ESC"] = "3d5b5_1";
|
||||
cfg["CONTENT_TYPE"] = "text/html; charset=utf-8";
|
||||
cfg["FCGI_SOCKET_PATH"] = "/run/uce.sock";
|
||||
cfg["FCGI_SOCKET_PATH"] = "/run/uce/fastcgi.sock";
|
||||
cfg["FCGI_SOCKET_MODE"] = "0666";
|
||||
cfg["CLI_SOCKET_PATH"] = "/run/uce/cli.sock";
|
||||
cfg["CLI_SOCKET_MODE"] = "0600";
|
||||
// Command socket the WS broker listens on; workers flush ws_* dispatch
|
||||
// command batches here at workspace teardown.
|
||||
cfg["WS_BROKER_SOCKET_PATH"] = "/run/uce/ws-broker.sock";
|
||||
@@ -1632,6 +1648,7 @@ StringMap make_server_settings()
|
||||
cfg["UCE_HOSTCALL_BLOCKLIST"] = "";
|
||||
cfg["TMP_UPLOAD_PATH"] = "/tmp/uce/uploads";
|
||||
cfg["SESSION_PATH"] = "/tmp/uce/sessions";
|
||||
cfg["SESSION_COOKIE_SECURE"] = "0";
|
||||
cfg["COMPILER_SYS_PATH"] = ".";
|
||||
cfg["PRECOMPILE_FILES_IN"] = "";
|
||||
cfg["SITE_DIRECTORY"] = "site";
|
||||
|
||||
Reference in New Issue
Block a user