Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dryrun keyless ignore config #91

Merged
merged 1 commit into from
Jan 13, 2016
Merged

Conversation

gperciva
Copy link
Member

@gperciva gperciva commented Nov 9, 2015

Addresses #89

I went back and forth half a dozen times between handling fromconffile in load_keys() vs. dooption(). In the end, I went with load_keys() since dooption() is already pretty long, and each option isn't very long. But I wimped out on doing everything in load_keys(); I left bsdtar->have_keys = 1 in dooption() since that's where it was originally. I think it might be better to move that into load_keys(); if we did that, load_keys() could go back to being void instead of the int that I changed it to.

Basically: adding the functionality was trivial. Trying to make it match the desired style was not. :|

@@ -374,6 +376,9 @@ keyfile_read(const char * filename, uint64_t * machinenum, int keys)
goto err0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it's begging for a if (errno == ENOENT) goto notfound; ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about

[EACCES]
Search permission is denied for a component of the path prefix.

I mean, should that also count as file-not-found?

@gperciva
Copy link
Member Author

Updated with cleaned-up code. Behaviour is now:

td@gin: ~/src/tarsnap/build (dryrun-keyless-ignore-config)
$ ./tarsnap -c -f a0 --dry-run ~/backup
tarsnap: stat(/home/td/new-machine.keys-bad): No such file or directory
tarsnap: Cannot read key file: /home/td/new-machine.keys-bad
         but continuing anyway with dry-run.
tarsnap: Ignoring cachedir due to missing or invalid keyfile in config file.
tarsnap: Performing dry-run archival without keys
         (sizes may be slightly inaccurate)
tarsnap: Removing leading '/' from member names
td@gin: ~/src/tarsnap/build (dryrun-keyless-ignore-config)
$ ./tarsnap -c -f a0 ~/backup
tarsnap: stat(/home/td/new-machine.keys-bad): No such file or directory
tarsnap: Cannot read key file: /home/td/new-machine.keys-bad
td@gin: ~/src/tarsnap/build (dryrun-keyless-ignore-config)

@gperciva gperciva force-pushed the dryrun-keyless-ignore-config branch 2 times, most recently from f702310 to c3ccde0 Compare January 6, 2016 20:51
tarsnap.conf.sample comes with a default location for the keyfile, but there
is no keyfile there until the user runs tarsnap-keygen, so

    $ tarsnap --dry-run -c ~/backup

fails.  Users could avoid this problem by specifying --no-default-config on
the command-line, but it would be nicer if tarsnap itself could forgive having
an non-existent / non-readable keyfile specified in the config file (but only
the config file, not the command-line!).
@gperciva gperciva force-pushed the dryrun-keyless-ignore-config branch from c3ccde0 to dd4558f Compare January 6, 2016 20:53
@gperciva
Copy link
Member Author

gperciva commented Jan 6, 2016

Updated to continue a dryrun despite any keyfile-reading error.

td@gin: ~/src/tarsnap/build (dryrun-keyless-ignore-config)
$ ./tarsnap -c -f a1 ~/backup
tarsnap: fopen(/home/td/keys-no-filesystem-read.txt): Permission denied
tarsnap: Cannot read key file: /home/td/keys-no-filesystem-read.txt
td@gin: ~/src/tarsnap/build (dryrun-keyless-ignore-config)
$ ./tarsnap -c -f a1 --dry-run ~/backup
tarsnap: fopen(/home/td/keys-no-filesystem-read.txt): Permission denied
tarsnap: Ignoring cachedir due to missing or invalid keyfile in config file.
tarsnap: Performing dry-run archival without keys
         (sizes may be slightly inaccurate)
tarsnap: Removing leading '/' from member names
td@gin: ~/src/tarsnap/build (dryrun-keyless-ignore-config)
$ ./tarsnap -c -f a1 --dry-run --keyfile ~/keys-no-filesystem-read.txt ~/backup
tarsnap: fopen(/home/td/keys-no-filesystem-read.txt): Permission denied
tarsnap: Cannot read key file: /home/td/keys-no-filesystem-read.txt
td@gin: ~/src/tarsnap/build (dryrun-keyless-ignore-config)

@gperciva gperciva mentioned this pull request Jan 6, 2016
cperciva added a commit that referenced this pull request Jan 13, 2016
@cperciva cperciva merged commit 19eb809 into master Jan 13, 2016
@gperciva gperciva deleted the dryrun-keyless-ignore-config branch January 13, 2016 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants