From ada2dfdd40032fbbfc1f8cd00c2f7e27374febe7 Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Jan 16 2019 10:26:48 +0000 Subject: Issue 50152 - Replace os.getenv('HOME') with os.path.expanduser Description: When HOME env var is not set, the call will fail with an exception. Instead of HOME we can use expanduser method. The expanduser will do the right thing and get home directory on all platforms from either env vars or password database. https://pagure.io/389-ds-base/issue/50152 Reviewed by: mreynolds, wibrown (Thanks!) --- diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index 0b08ef2..bd5e86a 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -778,7 +778,7 @@ class DirSrv(SimpleLDAPObject, object): # first identify the directories we will scan sysconfig_head = self.ds_paths.initconfig_dir - privconfig_head = os.path.join(os.getenv('HOME'), ENV_LOCAL_DIR) + privconfig_head = os.path.expanduser(os.path.join('~', ENV_LOCAL_DIR)) if not os.path.isdir(sysconfig_head): privconfig_head = None self.log.debug("dir (sys) : %s", sysconfig_head)