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 #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 May 31, 2022
1 parent a803a8a commit e51f129
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,11 @@ void do_rcfiles(void)
parse_one_nanorc();

if (custom_nanorc == NULL) {
#ifndef _WIN32
const char *xdgconfdir = getenv("XDG_CONFIG_HOME");
#else
const char *xdgconfdir = getenv("APPDATA");
#endif

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 e51f129

Please sign in to comment.