Skip to content

Commit

Permalink
Tarsnap 1.0.20
Browse files Browse the repository at this point in the history
**WARNING**: a serious bug exists in this version; see the 1.0.21 change
list for details.

**WARNING**: Due to changes in cache directory and archive formats,
pre-1.0.20 versions of Tarsnap should not be used to create archives
after 1.0.20 or later versions of Tarsnap are used by the same machine.

Changes since 1.0.19:
* Add --checkpoint-bytes <bytespercheckpoint> option to Tarsnap and
  associated configuration file option. This instructs tarsnap -c to
  store a checkpoint every <bytespercheckpoint> bytes; if Tarsnap (or
  the system on which Tarsnap is running) crashes, or the system's
  internet connection fails, in the middle of creating an archive, it
  will now be truncated at the last checkpoint instead of being lost
  entirely.
* Add Debian package-building metadata and Arch Linux PKGBUILD file.
  Thanks to Mads Sülau Jørgensen and Aaron Schaefer for their help with
  these.
* Minor bug fixes to autoconf build.
  • Loading branch information
cperciva authored and gperciva committed Feb 3, 2009
1 parent 924a516 commit 5dcba89
Show file tree
Hide file tree
Showing 49 changed files with 1,287 additions and 274 deletions.
2 changes: 1 addition & 1 deletion COPYING
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Unless specified otherwise in individual files, the contents of this
package is covered by the following copyright, license, and disclaimer:

Copyright 2006, 2007, 2008 Colin Percival
Copyright 2006, 2007, 2008, 2009 Colin Percival
All rights reserved.

Redistribution and use in source and binary forms, without modification,
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ distclean-local:

noinst_LIBRARIES= libarchive.a
bin_PROGRAMS= tarsnap tarsnap-keygen tarsnap-keymgmt
dist_man_MANS=$(tarsnap_dist_man_MANS) $(tarsnap_keygen_dist_man_MANS)
dist_man_MANS=$(tarsnap_dist_man_MANS) $(tarsnap_keygen_dist_man_MANS) $(tarsnap_keymgmt_dist_man_MANS)

#
# Libarchive headers, source, etc.
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ AC_CHECK_HEADER(inttypes.h,
[AC_SUBST(ARCHIVE_H_INCLUDE_INTTYPES_H,['#include <inttypes.h> /* For int64_t */'])],
[AC_SUBST(ARCHIVE_H_INCLUDE_INTTYPES_H,[''])])
AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h stdarg.h])
AC_CHECK_HEADERS([stdint.h stdlib.h string.h sys/acl.h sys/ioctl.h])
AC_CHECK_HEADERS([stdint.h stdlib.h string.h sys/acl.h sys/endian.h sys/ioctl.h])
AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h])
AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h])

Expand Down
11 changes: 11 additions & 0 deletions lib/netpacket/netpacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ typedef int handlepacket_callback(void *, NETPACKET_CONNECTION *,
#define NETPACKET_TRANSACTION_START_RESPONSE 0x91
#define NETPACKET_TRANSACTION_COMMIT 0x12
#define NETPACKET_TRANSACTION_COMMIT_RESPONSE 0x92
#define NETPACKET_TRANSACTION_CHECKPOINT 0x13
#define NETPACKET_TRANSACTION_CHECKPOINT_RESPONSE 0x93
#define NETPACKET_WRITE_FEXIST 0x20
#define NETPACKET_WRITE_FEXIST_RESPONSE 0xa0
#define NETPACKET_WRITE_FILE 0x21
Expand Down Expand Up @@ -99,6 +101,15 @@ int netpacket_transaction_start(NETPACKET_CONNECTION *, uint64_t,
int netpacket_transaction_commit(NETPACKET_CONNECTION *, uint64_t,
uint8_t, const uint8_t[32], handlepacket_callback *);

/**
* netpacket_transaction_checkpoint(NPC, machinenum, whichkey, ckptnonce,
* nonce, callback):
* Construct and send a NETPACKET_TRANSACTION_CHECKPOINT packet asking to
* create a checkpoint in a write transaction.
*/
int netpacket_transaction_checkpoint(NETPACKET_CONNECTION *, uint64_t,
uint8_t, const uint8_t[32], const uint8_t[32], handlepacket_callback *);

/**
* netpacket_write_fexist(NPC, machinenum, class, name, nonce, callback):
* Construct and send a NETPACKET_WRITE_FEXIST packet asking if the
Expand Down
4 changes: 4 additions & 0 deletions lib/netpacket/netpacket_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ callback_getbuf(void * cookie, uint8_t type, uint8_t ** buf,
if (buflen != 32)
status = NETPROTO_STATUS_PROTERR;
break;
case NETPACKET_TRANSACTION_CHECKPOINT_RESPONSE:
if (buflen != 65)
status = NETPROTO_STATUS_PROTERR;
break;
case NETPACKET_WRITE_FEXIST_RESPONSE:
case NETPACKET_WRITE_FILE_RESPONSE:
case NETPACKET_DELETE_FILE_RESPONSE:
Expand Down
55 changes: 55 additions & 0 deletions lib/netpacket/netpacket_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,58 @@ netpacket_transaction_commit(NETPACKET_CONNECTION * NPC,
/* Failure! */
return (-1);
}

/**
* netpacket_transaction_checkpoint(NPC, machinenum, whichkey, ckptnonce,
* nonce, callback):
* Construct and send a NETPACKET_TRANSACTION_CHECKPOINT packet asking to
* create a checkpoint in a write transaction.
*/
int
netpacket_transaction_checkpoint(NETPACKET_CONNECTION * NPC,
uint64_t machinenum, uint8_t whichkey, const uint8_t ckptnonce[32],
const uint8_t nonce[32], handlepacket_callback * callback)
{
uint8_t packetbuf[105];
int key;

/* Look up the key which is used to sign this packet. */
switch (whichkey) {
case 0:
key = CRYPTO_KEY_AUTH_PUT;
break;
case 1:
key = CRYPTO_KEY_AUTH_DELETE;
break;
default:
warn0("Programmer error: "
"Invalid operation in netpacket_transaction_commit");
goto err0;
}

/* Construct the packet. */
be64enc(&packetbuf[0], machinenum);
packetbuf[8] = whichkey;
memcpy(&packetbuf[9], ckptnonce, 32);
memcpy(&packetbuf[41], nonce, 32);

/* Append hmac. */
if (netpacket_hmac_append(NETPACKET_TRANSACTION_CHECKPOINT,
packetbuf, 73, key))
goto err0;

/* Send the packet. */
if (netproto_writepacket(NPC->NC, NETPACKET_TRANSACTION_CHECKPOINT,
packetbuf, 105, netpacket_op_packetsent, NPC))
goto err0;

/* Set callback for handling a response. */
NPC->pending_current->handlepacket = callback;

/* Success! */
return (0);

err0:
/* Failure! */
return (-1);
}
46 changes: 46 additions & 0 deletions lib/netpacket/packets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,52 @@ Note that this packet does not indicate that the requested transaction was
committed; only that IF the requested transaction was the most recent
non-committed transaction, THEN it has been committed.

NETPACKET_TRANSACTION_CHECKPOINT (0x13)
---------------------------------------

Mark a "checkpoint" in a write transaction. When committing a write
transaction, files are omitted from the transaction if (a) they were uploaded
after the last checkpoint, or (b) they were uploaded prior to the penultimate
checkpoint and have class 'i' or 'm'.

Packet contents:
uint64_t machinenum
uint8_t whichkey
uint8_t ckptnonce[32]
uint8_t nonce[32]
uint8_t hmac[32]

The value whichkey is
0 key = write access key
1 key = delete access key.
Note that while checkpoints only exist in write transactions, a checkpoint
request can be signed with a delete access key in the "log checkpoint
creation; crash; run tarsnap -d" case.

The value ckptnonce is a random nonce; if a checkpoint request is replayed,
the ckptnonce value must be identical.

The value nonce is the transaction nonce of the current write transaction.

The value hmac is HMAC(0x13 || [packet minute final hmac]).

NETPACKET_TRANSACTION_CHECKPOINT_RESPONSE (0x93)
------------------------------------------------

Packet contents:
uint8_t status
uint8_t ckptnonce[32]
uint8_t hmac[32]

The value status means:
0 Success
1 Transaction nonce is incorrect.

The value hmac is HMAC(key, 0x93 || nonce || [packet minus final hmac]),
where nonce is the nonce provided by the client (which may not be the nonce
of the current transaction, if status == 1), and key is the write or delete
key as in NETPACKET_TRANSACTION_CHECKPOINT.

NETPACKET_WRITE_FEXIST (0x20)
-----------------------------

Expand Down
19 changes: 17 additions & 2 deletions lib/network/network_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
struct network_connect_cookie {
int s;
int failed;
int errnum;
network_callback * callback;
void * cookie;
};
Expand All @@ -38,10 +39,23 @@ callback_connect(void * cookie, int status)
* second timeout used to postpone handling of a connect() failure.
*/
if (status == NETWORK_STATUS_TIMEOUT) {
if (C->failed)
if (C->failed) {
/*
* The connect() call returned an error; restore the
* errno value from that point so that when we invoke
* our callback we have the right value there.
*/
status = NETWORK_STATUS_CONNERR;
else
errno = C->errnum;
} else {
/*
* There was a connection timeout; set errno to zero
* here since any value in errno at this point is
* just left over from a previous failed syscall.
*/
status = NETWORK_STATUS_CTIMEOUT;
errno = 0;
}
}

if (status != NETWORK_STATUS_OK)
Expand Down Expand Up @@ -134,6 +148,7 @@ network_connect(int s, const struct sockaddr * addr, socklen_t addrlen,
* to perform the callback right now.
*/
C->failed = 1;
C->errnum = errno;
timeo.tv_sec = timeo.tv_usec = 0;
if (network_sleep(&timeo, callback_connect, C))
goto err1;
Expand Down
30 changes: 30 additions & 0 deletions pkg/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
OS-specific packaging bits for tarsnap
======================================

This directory contains bits to allow tarsnap to fit into operating system
package management systems. I don't have access to all of these systems,
so please email me (at <cperciva@tarsnap.com>) if there are any problems
with these bits or if you can provide packaging bits for another OS.

Debian
------

To build a Debian package:
# ln -s pkg/debian .
# dpkg-buildpackage

Then to install it:
# dpkg -i tarsnap-<version>_<arch>.deb

Arch Linux
----------

There is a PKGBUILD file for an earlier version of tarsnap in pkg/archlinux.
I can't include a PKGBUILD for the current version of tarsnap because the
PKGBUILD file contains the hash of the tarball which contains the PKGBUILD
file. If you're running Arch Linux, you should know what to do with the
PKGBUILD file; but you may wish to change the pkgver=, md5sums=, and
sha256sums= lines so that you get the latest version of tarsnap.

There may be a newer version of the PKGBUILD file at
http://aur.archlinux.org/packages.php?ID=22963
23 changes: 23 additions & 0 deletions pkg/archlinux/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Contributor: Aaron Schaefer <aaron@elasticdog.com>
pkgname=tarsnap
pkgver=1.0.19
pkgrel=1
pkgdesc="An online encrypted snapshotted backup service"
arch=('i686' 'x86_64')
url='http://www.tarsnap.com/'
license=('custom')
depends=('bzip2' 'openssl')
makedepends=('e2fsprogs')
source=("https://beta.tarsnap.com/download/$pkgname-autoconf-$pkgver.tgz")
md5sums=('bf9a3a57ad997462dd71ad9f07ffb66c')
sha256sums=('7cd94c5238b992a5f2fdbe8e5a555fd745bcd6b47c312632482f4de32d183fd6')

build() {
cd "$srcdir/$pkgname-autoconf-$pkgver"

./configure --prefix=/usr --sysconfdir="/etc/$pkgname"
make || return 1
make DESTDIR="$pkgdir/" install

install -D -m644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
}
20 changes: 20 additions & 0 deletions pkg/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
tarsnap (1.0.20) unstable; urgency=low

* Fixed typo in sed code for changing default cachedir.
* Removed unnecessary dependency on autotools-dev.
* Added dependency on libbz2-dev (not required, but tarsnap will take
advantage of libbz2 if it is present).
* Removed unnecessary CONFIGDIR= from ./configure invocation (the
autoconf logic handles this already).

-- Colin Percival <cperciva@tarsnap.com> Sat, 31 Jan 2009 22:54:01 +0000
tarsnap (1.0.19-1) unstable; urgency=low

* Fixed default config file location and cachedir.

-- Mads Sulau Joergensen <mads@sulau.dk> Sun, 18 Jan 2009 19:48:41 +0100
tarsnap (1.0.19) unstable; urgency=low

* Initial Release.

-- Mads Sulau Joergensen <mads@sulau.dk> Sun, 18 Jan 2009 14:25:54 +0100
1 change: 1 addition & 0 deletions pkg/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
13 changes: 13 additions & 0 deletions pkg/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Source: tarsnap
Section: net
Priority: extra
Maintainer: Mads Sulau Joergensen <mads@sulau.dk>
Build-Depends: debhelper (>= 5), e2fslibs-dev, zlib1g-dev, libssl-dev, libbz2-dev
Standards-Version: 3.7.2

Package: tarsnap
Architecture: any
Depends: ${shlibs:Depends}, zlib1g
Description: tarsnap is an online encrypted snapshotted backup service
Tarsnap is an encrypted snapshotted online backup service for BSD,
Linux, OpenSolaris, and OS X.
31 changes: 31 additions & 0 deletions pkg/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
This is tarsnap, written and maintained by Colin Percival
on Sat, 31 Jan 2009 22:54:01 +0000.

The original source can always be found at:
https://beta.tarsnap.com/download.html

Copyright Holder: Colin Percival

License:

Unless specified otherwise in individual files, the contents of this
package is covered by the following copyright, license, and disclaimer:

Copyright 2006, 2007, 2008, 2009 Colin Percival
All rights reserved.

Redistribution and use in source and binary forms, without modification,
is permitted for the sole purpose of using the "tarsnap" backup service
provided by Colin Percival.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
4 changes: 4 additions & 0 deletions pkg/debian/dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
usr/bin
usr/sbin
etc
var/lib/tarsnap/cache
1 change: 1 addition & 0 deletions pkg/debian/files
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tarsnap_1.0.20_i386.deb net extra

0 comments on commit 5dcba89

Please sign in to comment.