Configuring Archivers for Use with Sign/Encrypt Files

## Configuring Archivers for Use with Sign/Encrypt Files

Kleopatra allows the administrator (and power-user) to configure the list of archivers that are presented in the Sign/Encrypt Files dialog.

Each archiver is defined in `libkleopatrarc` as a separate `Archive Definition #`n`` group, with the following mandatory keys:

`extensions`

  A comma-separated list of filename extensions that usually indicate this archive format.

`id`

  A unique ID used to identify this archiver internally. If in doubt, use the name of the command.

`Name` (translated)

  The user-visible name of this archiver, as shown in the corresponding drop-down menu of the Sign/Encrypt Files dialog.

`pack-command`

  The actual command to archive files. You can use any command, as long as no shell is required to execute it. The program file is looked up using the `PATH` environment variable, unless you use an absolute file path. Quoting is supported as if a shell was used:

      pack-command="/opt/ZIP v2.32/bin/zip" -r -

### Note

Since backslash (`\`) is an escape character in KDE config files, you need to double them when they appear in path names:

    pack-command=C:\\Programs\\GNU\\tar\\gtar.exe ...

However, for the command itself (as opposed to its arguments), you may just use forward slashes (`/`) as path separators on all platforms:

    pack-command=C:/Programs/GNU/tar/gtar.exe ...

This is not supported in arguments, as most Windows® programs use the forward slash for options. For example, the following will not work, since `C:/myarchivescript.bat` is an argument to cmd.exe, and `/` is not converted to `\` in arguments, only commands:

    pack-command=cmd.exe C:/myarchivescript.bat

This needs, instead, to be written as:

    pack-command=cmd.exe C:\\myarchivescript.bat

### Input Filename Passing for `pack-command`

There are three ways to pass filenames to the pack command. For each of these, `pack-command` provides a particular syntax:

1. As command-line arguments.

   Example (tar):

       pack-command=tar cf -

   Example (zip):

       pack-command=zip -r - %f

   In this case, filenames are passed on the command line, just like you would when using the command prompt. Kleopatra does not use a shell to execute the command. Therefore, this is a safe way of passing filenames, but it might run into command line length restrictions on some platforms. A literal `%f`, if present, is replaced by the names of the files to archive. Otherwise, filenames are appended to the command line. Thus, the zip Example above could equivalently be written like this:

       pack-command=zip -r -

2. Via standard-in, separated by newlines: prepend `|`.

   Example (GNU-tar):

       pack-command=|gtar cf - -T-

   Example (ZIP):

       pack-command=|zip -@ -

   In this case, filenames are passed to the archiver on stdin, one per line. This avoids problems on platforms which place a low limit on the number of command line arguments that are allowed, but fails when filenames, in fact, contain newlines.

   ### Note

   Kleopatra currently only supports LF as a newline separator, not CRLF. This might change in future versions, based on user feedback.

3. Via standard-in, separated by NUL-bytes: prepend `0|`.

   Example (GNU-tar):

       pack-command=0|gtar cf - -T- --null

   This is the same as above, except that NUL bytes are used to separate filenames. Since NUL bytes are forbidden in filenames, this is the most robust way of passing filenames, but not all archivers support it.