aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-05-24 16:18:15 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-05-25 15:02:41 +0000
commitbc7214cd885f08306f2fa833af2b5c72a6cc88c4 (patch)
treeadd02e9ab9463a72c3d8428a38d4baaf8202a475
parentmain: minor rewording of non-UTF8 locale warnings and errors (diff)
config: use $HOME instead of getpwuid() to retrieve users’s home dir
When searching for foot.ini, use $HOME instead of getpwuid() to retrieve the user’s home directory.
-rw-r--r--CHANGELOG.md5
-rw-r--r--config.c13
-rw-r--r--doc/foot.1.scd6
-rw-r--r--doc/foot.ini.5.scd2
4 files changed, 13 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b03f3f69..4924572a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,6 +50,11 @@
### Changed
+
+* Use `$HOME` instead of `getpwuid()` to retrieve the user’s home
+ directory when searching for `foot.ini`.
+
+
### Deprecated
### Removed
### Fixed
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 '~'");
diff --git a/doc/foot.1.scd b/doc/foot.1.scd
index 837da048..52ccebd1 100644
--- a/doc/foot.1.scd
+++ b/doc/foot.1.scd
@@ -361,7 +361,7 @@ foot will search for a configuration file in the following locations,
in this order:
- *XDG_CONFIG_HOME/foot/foot.ini* (defaulting to
- *~/.config/foot/foot.ini* if unset)
+ *$HOME/.config/foot/foot.ini* if unset)
- *XDG_CONFIG_DIRS/foot/foot.ini* (defaulting to
*/etc/xdg/foot/foot.ini* if unset)
@@ -464,6 +464,10 @@ The following environment variables are used by foot:
The default child process to run, when no _command_ argument is
specified and the *shell* option in *foot.ini*(5) is not set.
+*HOME*
+ Used to determine the location of the configuration file, see
+ *foot.ini*(5) for details.
+
*XDG\_CONFIG\_HOME*
Used to determine the location of the configuration file, see
*foot.ini*(5) for details.
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index 8aa63d2f..9c7ccf29 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -15,7 +15,7 @@ foot will search for a configuration file in the following locations,
in this order:
- *XDG_CONFIG_HOME/foot/foot.ini* (defaulting to
- *~/.config/foot/foot.ini* if unset)
+ *$HOME/.config/foot/foot.ini* if unset)
- *XDG_CONFIG_DIRS/foot/foot.ini* (defaulting to
*/etc/xdg/foot/foot.ini* if unset)