Skip to content

Commit

Permalink
Fix admin profile config and support APPDATA.
Browse files Browse the repository at this point in the history
Only use ALLUSERPROFILE for home dir when USERPROFILE is not set, even
for admin users.
Fix lhmouse#34.

Also on Windows when looking for the rc, look in getenv("APPDATA")
instead of getenv("XDG_CONFIG_HOME"), which is mostly equivalent.

Signed-off-by: Rafael Kitover <[email protected]>
  • Loading branch information
rkitover committed Jun 6, 2022
1 parent a803a8a commit 92d45d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ void do_rcfiles(void)
parse_one_nanorc();

if (custom_nanorc == NULL) {
const char *xdgconfdir = getenv("XDG_CONFIG_HOME");
const char *xdgconfdir = getenv("APPDATA");

get_homedir();

Expand Down
4 changes: 1 addition & 3 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ void get_homedir(void)
if (homedir == NULL) {
const char *homenv = getenv("USERPROFILE");

/* When HOME isn't set, or when we're root, get the home directory
* from the password file instead. */
if (homenv == NULL || IsUserAnAdmin())
if (homenv == NULL)
homenv = getenv("ALLUSERSPROFILE");

/* Only set homedir if some home directory could be determined,
Expand Down

0 comments on commit 92d45d2

Please sign in to comment.