chiark / gitweb /
lib/home.c: Introduce functions for building pathmames in home directories.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 4 Jun 2020 19:13:11 +0000 (20:13 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 15 Jun 2020 11:58:53 +0000 (12:58 +0100)
commite1e3ef08ef3419f4aabcfb3f45ab49a78000cdb7
treefe591241fd1524681c266374bcff3c4b32b973b2
parent477b12ff719d3749b8d8f85035bd6384fee9be0d
lib/home.c: Introduce functions for building pathmames in home directories.

Split the home-directory logic of `config_userconf' into its own file.
Arrange to only calculate the home directory once.

Most invasively, use this new functionality in place of looking up
`$HOME' and building pathnames by hand.

This change doesn't add much functionality, but it does add a little.
Most notably,

$ unset HOME; disobedience

doesn't segfault any more.  More subtly, the logic for finding one's
home directory is now consistent.  On Windows, we still use `%APPDATA%';
on Unix, we now /always/ use `$HOME' first, and then fall back to
`getpwuid(getuid)->pw_dir' if that's unset.  Previously, the
configuration reader would ignore `$HOME' and use the password database,
while Disobedience used `$HOME' exclusively and crashed if it was
unset.  This is all obviously silly.
disobedience/disobedience.h
disobedience/rtp.c
disobedience/settings.c
lib/Makefile.am
lib/configuration.c
lib/home.c [new file with mode: 0644]
lib/home.h [new file with mode: 0644]