I attempted to create a brand new backup here. The process here is:
Read the "backup directory" path from the config file.
Check to see if it contains a git repo -- if not, create it.
Do cool backup things
Profit
My config was set to back up to /home/pwn/shallow-backup.
On this machine, that directory was owned by root, and pwn had read access to /home/pwn/shallow-backup but didn't have write access.
And so we see the following exception:
pwn@strawman:~$ shallow-backup
[graphic removed for readability]
v5.1 by Aaron Lichtman (@alichtman)
Current shallow-backup path: ~/shallow-backup
[?] Would you like to move this somewhere else?: No
> No
Yes
Initializing new git repo...
Traceback (most recent call last):
File "/usr/local/bin/shallow-backup", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/shallow_backup/__main__.py", line 99, in cli
repo, new_git_repo_created = safe_git_init(backup_home_path)
File "/usr/local/lib/python3.9/dist-packages/shallow_backup/git_wrapper.py", line 70, in safe_git_init
repo = git.Repo.init(dir_path)
File "/usr/local/lib/python3.9/dist-packages/git/repo/base.py", line 1046, in init
git.init(**kwargs)
File "/usr/local/lib/python3.9/dist-packages/git/cmd.py", line 639, in <lambda>
return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/git/cmd.py", line 1184, in _call_process
return self.execute(call, **exec_kwargs)
File "/usr/local/lib/python3.9/dist-packages/git/cmd.py", line 984, in execute
raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git init
stderr: '/home/pwn/shallow-backup/.git: Permission denied'
I attempted to create a brand new backup here. The process here is:
My config was set to back up to
/home/pwn/shallow-backup
.On this machine, that directory was owned by
root
, andpwn
had read access to/home/pwn/shallow-backup
but didn't have write access.And so we see the following exception:
This case needs clean exception handling.