Browse Source

chg: common: Stop creating gnupg home by default

gns
juga 1 year ago
parent
commit
83ddf8e519
1 changed files with 20 additions and 3 deletions
  1. +20
    -3
      mixnet/common.py

+ 20
- 3
mixnet/common.py View File

@ -16,20 +16,37 @@ logger = logging.getLogger(__name__)
def guess_home():
user = "~" + getpass.getuser()
"""Return the home of the user that is running the script."""
user = os.path.join("~", getpass.getuser())
home = os.environ.get("HOME", os.path.expanduser(user))
# When this is run by postfix pipe, the output has to be in stderr, to be
# shown in the log.
print("User home", home, file=sys.stderr)
logger.debug("User home: {}".format(home))
return home
def set_gnupg_home(gnupg_home):
"""Create gnupg directory and set GNUPGHOME env variable.
To be able to have different keyrings for the tests.
Since pEp-2.1.0rc2, it does not use gnupg and it's enough to set the home,
to have different keys.db per test.
"""
os.makedirs(gnupg_home, mode=0o0700, exist_ok=True)
os.environ["GNUPGHOME"] = gnupg_home
print("GNUPGHOME: %s", gnupg_home)
def set_env(home=None, create_dir=False, create_gnupg_dir=True):
"""Set HOME environment variable to set where pEp database will live."""
def set_env(home=None, create_dir=False, create_gnupg_dir=False):
"""Set HOME environment variable to set where pEp database will live.
And optionally the GNUPGPHOME. Since pEp-2.1.0rc2, gnupg is not used
anymore.
"""
if not home:
home = guess_home()
if create_dir:


Loading…
Cancel
Save