Improve handling of user detection failure
This commit is contained in:
parent
eb889beee7
commit
9fdb959540
@ -679,7 +679,10 @@ def _read_config(config_file, user=None):
|
||||
'numeric_ids': False}
|
||||
|
||||
if not os.path.isfile(config_file):
|
||||
if user is not None:
|
||||
logger.warning('Config file %s does not exist', config_file)
|
||||
else:
|
||||
logger.warning('User not specified. Can\'t read configuration file')
|
||||
|
||||
return config_args
|
||||
|
||||
@ -793,7 +796,12 @@ def simple_backup():
|
||||
|
||||
if euid == 0:
|
||||
user = os.getenv('SUDO_USER')
|
||||
|
||||
if user is not None:
|
||||
homedir = os.path.expanduser(f'~{user}')
|
||||
else:
|
||||
logger.warning('Failed to detect user. You can use -u/--user parameter to manually specify it')
|
||||
homedir = None
|
||||
else:
|
||||
user = os.getenv('USER')
|
||||
homedir = os.getenv('HOME')
|
||||
|
Loading…
x
Reference in New Issue
Block a user