josephernest / nfreezer

nFreezer is an encrypted-at-rest backup tool.
Other
302 stars 21 forks source link

NFreezer fails if a symbolic link is unresolved #3

Open vgivanovic opened 3 years ago

vgivanovic commented 3 years ago

I chose to test NFreezer on my collection of source files pulled (mostly) from GitHub. A lot of them have dangling symlinks which NFreezer doesn't like:

  File "/home/vladimir/anaconda3/bin/nfreezer", line 8, in <module>
    sys.exit(console_script())
  File "/home/vladimir/anaconda3/lib/python3.8/site-packages/nfreezer.py", line 262, in console_script
    backup(src=sys.argv[2], dest=sys.argv[3])
  File "/home/vladimir/anaconda3/lib/python3.8/site-packages/nfreezer.py", line 175, in backup
    mtime = os.stat(fn).st_mtime_ns
FileNotFoundError: [Errno 2] No such file or directory: 'cryptominisat/scripts/xor_to_cnf_class.py'

Restarting NFreezer doesn't help; it fails again at the same place.

josephernest commented 3 years ago

Thank you for testing and auditing nFreezer @vgivanovic, this is helpful!

I'll try this too. In your opinion, what should be the expected behaviour when a symlink is unresolved? Skip (with a precise logging) or stop the whole process?

vgivanovic commented 3 years ago

You bring up a good question: How should NFreezer deal with symbolic links?  Does it follow the link? What about dangling links? Or any link which generates an error (e.g. a link which points to a file that is inaccessible to the current user).

Right now, if NFreezer skips the link, a restore will not restore the original directory tree. On the other hand, not skipping means that NFreezer can never backup beyond the first dangling symbolic link.

So, I suggest that NFreezer skip the dangling link but make a note of it. I also suggest that NFreezer follow the Unix philosophy of being silent unless a error occurs or the use specifically asks for verbose output. That way the errors stand out. Both cp and rsync generate a non-fatal error when dealing with a dangling symbolic link, but can be told to copy the link nonetheless.

I'd copy exactly what one or the other of cp or rsync does or can do and note the behavior in the documentation. BTW do non-fatal errors get written to stderr?

— Vladimir

Vladimir G. Ivanović email vladimir@acm.org mailto:vladimir@acm.org mobile +1 650 450 4101

On 28/11/2020 10.23, josephernest wrote:

Thank you for testing and auditing nFreezer @vgivanovic https://github.com/vgivanovic, this is helpful!

I'll try this too. In your opinion, what should be the expected behaviour when a symlink is unresolved? Skip (with a precise logging) or stop the whole process?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/josephernest/nfreezer/issues/3#issuecomment-735272794, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABJM242TE2ORN7PYA3PXXTSSE52TANCNFSM4UF566EQ.