#50152 Replace os.getenv('HOME') with os.path.expanduser
Closed: wontfix 3 years ago by spichugi. Opened 3 years ago by cheimes.

Issue Description

lib389 uses os.path.join(os.getenv('HOME'), ENV_LOCAL_DIR) to get the path to local conf directory. When HOME env var is not set, the call will fail with an exception. Instead of HOME, please use https://docs.python.org/3/library/os.path.html?highlight=expanduser#os.path.expanduser . The expanduser will do the right thing and get home directory on all platforms from either env vars or password database.

>>> import os
>>> ENV_LOCAL_DIR = '.dirsrv'
>>> os.path.expanduser(os.path.join('~', ENV_LOCAL_DIR))
'/home/heimes/.dirsrv'

Package Version and Platform

389-DS 1.4.0.16-1

Steps to reproduce

  1. unset HOME
  2. install FreeIPA server

Actual results

File "/usr/lib/python3.7/site-packages/ipaserver/install/service.py", line 549, in start_creation
   run_step(full_msg, method)
 File "/usr/lib/python3.7/site-packages/ipaserver/install/service.py", line 535, in run_step
   method()
 File "/usr/lib/python3.7/site-packages/ipaserver/install/dsinstance.py", line 583, in __create_instance
   sds.create_from_args(general, slapd, backends, None)
 File "/usr/lib/python3.7/site-packages/lib389/instance/setup.py", line 563, in create_from_args
   self._prepare_ds(general, slapd, backends)
 File "/usr/lib/python3.7/site-packages/lib389/instance/setup.py", line 497, in _prepare_ds
   insts = ds.list(serverid=slapd['instance_name'])
 File "/usr/lib/python3.7/site-packages/lib389/__init__.py", line 774, in list
   privconfig_head = os.path.join(os.getenv('HOME'), ENV_LOCAL_DIR)
 File "/usr/lib64/python3.7/posixpath.py", line 80, in join
   a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType 

Expected results

389-DS should not use HOME


Metadata Update from @spichugi:
- Issue assigned to spichugi

3 years ago

Metadata Update from @spichugi:
- Custom field component adjusted to None
- Custom field origin adjusted to None
- Custom field reviewstatus adjusted to None
- Custom field type adjusted to None
- Custom field version adjusted to None

3 years ago

Metadata Update from @spichugi:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

3 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/389ds/389-ds-base/issues/3211

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Metadata Update from @spichugi:
- Issue close_status updated to: wontfix (was: fixed)

a year ago

Login to comment on this ticket.

Metadata