From bc7214cd885f08306f2fa833af2b5c72a6cc88c4 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 24 May 2022 18:18:15 +0200 Subject: config: use $HOME instead of getpwuid() to retrieve users’s home dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When searching for foot.ini, use $HOME instead of getpwuid() to retrieve the user’s home directory. --- config.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index c5fad01a..cb05319a 100644 --- a/config.c +++ b/config.c @@ -311,15 +311,6 @@ struct config_file { int fd; /* FD of file, O_RDONLY */ }; -static const char * -get_user_home_dir(void) -{ - const struct passwd *passwd = getpwuid(getuid()); - if (passwd == NULL) - return NULL; - return passwd->pw_dir; -} - static struct config_file open_config(void) { @@ -328,7 +319,7 @@ open_config(void) const char *xdg_config_home = getenv("XDG_CONFIG_HOME"); const char *xdg_config_dirs = getenv("XDG_CONFIG_DIRS"); - const char *home_dir = get_user_home_dir(); + const char *home_dir = getenv("HOME"); char *xdg_config_dirs_copy = NULL; /* First, check XDG_CONFIG_HOME (or .config, if unset) */ @@ -756,7 +747,7 @@ parse_section_main(struct context *ctx) const char *include_path = NULL; if (value[0] == '~' && value[1] == '/') { - const char *home_dir = get_user_home_dir(); + const char *home_dir = getenv("HOME"); if (home_dir == NULL) { LOG_CONTEXTUAL_ERRNO("failed to expand '~'"); -- cgit v1.3