diff options
author | Konstantin Ryabitsev <mricon@kernel.org> | 2012-02-10 13:26:47 -0500 |
---|---|---|
committer | Konstantin Ryabitsev <mricon@kernel.org> | 2012-02-10 13:26:47 -0500 |
commit | fd25e9dc7df615442d1e7b316798c99efe0281f0 (patch) | |
tree | 4961fdaf34c66b62ecc4153c9cf8929fecf6d688 | |
parent | 714871084f1ce0bd646b2298d15c0a7db9f0b0a4 (diff) | |
download | kup-fd25e9dc7df615442d1e7b316798c99efe0281f0.tar.gz |
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.
-rwxr-xr-x | kup-server | 28 | ||||
-rw-r--r-- | kup-server.1 | 23 | ||||
-rw-r--r-- | kup-server.cfg | 12 |
3 files changed, 56 insertions, 7 deletions
@@ -127,13 +127,27 @@ my $timeout_compress_cpu = int($cfg->param('limits.timeout_compress_cpu')); # 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 @@ Uncompressing tarballs must take at most this long. .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 @@ timeout_compress = 900 ; ; 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 |