mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-04 00:36:01 +00:00
Get home directory from password db in case the HOME env doesn't exist
This commit is contained in:
parent
0238a22004
commit
82b956a1e8
22
src/config.c
22
src/config.c
@ -27,6 +27,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#define MOONLIGHT_PATH "/moonlight"
|
#define MOONLIGHT_PATH "/moonlight"
|
||||||
#define USER_PATHS "."
|
#define USER_PATHS "."
|
||||||
@ -76,6 +78,11 @@ char* get_path(char* name, char* extra_data_dirs) {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!home_dir) {
|
||||||
|
struct passwd *pw = getpwuid(getuid());
|
||||||
|
home_dir = pw->pw_dir;
|
||||||
|
}
|
||||||
|
|
||||||
if (!extra_data_dirs)
|
if (!extra_data_dirs)
|
||||||
extra_data_dirs = "/usr/share:/usr/local/share";
|
extra_data_dirs = "/usr/share:/usr/local/share";
|
||||||
if (!xdg_config_dir)
|
if (!xdg_config_dir)
|
||||||
@ -335,13 +342,14 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
|
|||||||
config_save(config->config_file, config);
|
config_save(config->config_file, config);
|
||||||
|
|
||||||
if (config->key_dir[0] == 0x0) {
|
if (config->key_dir[0] == 0x0) {
|
||||||
const char *xdg_cache_dir = getenv("XDG_CACHE_DIR");
|
struct passwd *pw = getpwuid(getuid());
|
||||||
if (xdg_cache_dir != NULL)
|
const char *dir;
|
||||||
sprintf(config->key_dir, "%s" MOONLIGHT_PATH, xdg_cache_dir);
|
if ((dir = getenv("XDG_CACHE_DIR")) != NULL)
|
||||||
else {
|
sprintf(config->key_dir, "%s" MOONLIGHT_PATH, dir);
|
||||||
const char *home_dir = getenv("HOME");
|
else if ((dir = getenv("HOME")) != NULL)
|
||||||
sprintf(config->key_dir, "%s" DEFAULT_CACHE_DIR MOONLIGHT_PATH, home_dir);
|
sprintf(config->key_dir, "%s" DEFAULT_CACHE_DIR MOONLIGHT_PATH, dir);
|
||||||
}
|
else
|
||||||
|
sprintf(config->key_dir, "%s" DEFAULT_CACHE_DIR MOONLIGHT_PATH, pw->pw_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->stream.fps == -1)
|
if (config->stream.fps == -1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user