Allow specifying compressors in kup-server.cfg

This lets the admins specify the compressors in the config
file, instead of them being hard-coded to always be gz, bz2
and xz.
diff --git a/kup-server b/kup-server
index f7902df..fbf8874 100755
--- a/kup-server
+++ b/kup-server
@@ -127,13 +127,27 @@
 # Make sure the user can't create insanely large files
 setrlimit(RLIMIT_FSIZE, $max_data, $max_data);
 
-# These programs are expected to accept the option
-# -9 for compression and -cd for decompression to stdout.
-my %zformats = (
-	'.gz'  => '/bin/gzip',
-	'.bz2' => '/usr/bin/bzip2',
-	'.xz'  => '/usr/bin/xz'
-);
+# Do we have a [compressors.use] in the config file?
+my %zformats;
+
+if (defined($cfg->param('compressors.use'))) {
+
+    foreach my $zformat ($cfg->param('compressors.use')) {
+        # Do we have a path defined?
+        if (!defined($cfg->param("compressors.${zformat}"))) {
+            fatal("Compressor ${zformat} requested, but path not specified.");
+        }
+        my $ext = '.' . $zformat;
+        $zformats{$ext} = $cfg->param("compressors.${zformat}");
+    }
+
+} else {
+	%zformats = (
+		'.gz'  => '/bin/gzip',
+		'.bz2' => '/usr/bin/bzip2',
+		'.xz'  => '/usr/bin/xz'
+	);
+}
 
 my $have_data = 0;
 my $have_sign = 0;
diff --git a/kup-server.1 b/kup-server.1
index 24841ee..8888aee 100644
--- a/kup-server.1
+++ b/kup-server.1
@@ -92,6 +92,29 @@
 .TP
 \fBtimeout_compress_cpu\fP = \fI900\fP
 Each compression command must take at most this long in CPU time.
+.PP
+.TP
+\fB[compressors]\fP
+This section allows specifying the compressors to use when creating
+compressed versions of uploaded content.
+.TP
+\fBuse\fP = \fIgz, bz2, xz\fP
+A comma-separated list of file extensions to create (minus the leading dot). 
+For each extension specified, you will need to add an extra entry to this
+section with the path to the matching gzip-compatible utility (i.e. it 
+must accept \fI-9\fP and \fI-cd\fP command-line arguments). E.g., if you 
+specified "\fIgz, bz2, xz\fP" as values in \fBuse\fP, you must add the
+following entries as well:
+.PP
+.RS
+.RS
+.nf
+gz = /bin/gzip
+bz2 = /usr/bin/bzip2
+xz = /usr/bin/xz
+.fi
+.RE
+.RE
 .SH AUTHOR
 Written by H. Peter Anvin <hpa@zytor.com>.
 .SH COPYRIGHT
diff --git a/kup-server.cfg b/kup-server.cfg
index 12cf9b7..17b00e2 100644
--- a/kup-server.cfg
+++ b/kup-server.cfg
@@ -51,3 +51,15 @@
 ;
 ; How much CPU time, per compression command, before it is terminated
 timeout_compress_cpu = 900
+
+[compressors]
+; Specify which compressors to use, separated by comma. These must match the
+; file extensions that will be added to the compressed file (after the dot).
+use = gz, bz2, xz
+;
+; Specify paths to each compressor listed above. Each of these must accept
+; "-9" as commandline parameter for compression and "-cd" for decompression
+; to stdout.
+gz  = /bin/gzip
+bz2 = /usr/bin/bzip2
+xz  = /usr/bin/xz