diff --git a/simple_backup/simple_backup.py b/simple_backup/simple_backup.py index 750e5bc..6b2f5f2 100755 --- a/simple_backup/simple_backup.py +++ b/simple_backup/simple_backup.py @@ -679,7 +679,10 @@ def _read_config(config_file, user=None): 'numeric_ids': False} if not os.path.isfile(config_file): - logger.warning('Config file %s does not exist', 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') - homedir = os.path.expanduser(f'~{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')