diff --git a/src/config.cpp b/src/config.cpp index fd88760..04f2489 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -20,7 +20,7 @@ using namespace std::literals; #define PRIVATE_KEY_FILE CA_DIR "/cakey.pem" #define CERTIFICATE_FILE CA_DIR "/cacert.pem" -#define APPS_JSON_PATH platf::appdata().string() + "/apps.json" +#define APPS_JSON_PATH "apps.json" namespace config { namespace nv { @@ -292,7 +292,7 @@ sunshine_t sunshine { {}, // Username {}, // Password {}, // Password Salt - platf::appdata().string() + "/sunshine.conf", // config file + "sunshine.conf", // config file {}, // cmd args 47989, }; @@ -703,6 +703,7 @@ int apply_flags(const char *line) { void apply_config(std::unordered_map &&vars) { if(!fs::exists(stream.file_apps.c_str())) { fs::copy_file(SUNSHINE_CONFIG_DIR "/apps.json", stream.file_apps); + fs::permissions(stream.file_apps, fs::perms::owner_write, fs::perm_options::add); } for(auto &[name, val] : vars) { @@ -910,11 +911,16 @@ int parse(int argc, char *argv[]) { } } + std::unordered_map vars; + path_f(vars, "config_file", sunshine.config_file); + path_f(vars, "file_apps", stream.file_apps); + if(!fs::exists(sunshine.config_file)) { fs::copy_file(SUNSHINE_CONFIG_DIR "/sunshine.conf", sunshine.config_file); + fs::permissions(sunshine.config_file, fs::perms::owner_write, fs::perm_options::add); } - auto vars = parse_config(read_file(sunshine.config_file.c_str())); + vars = parse_config(read_file(sunshine.config_file.c_str())); for(auto &[name, value] : cmd_vars) { vars.insert_or_assign(std::move(name), std::move(value));