## ProFTPD module `mod_ifversion`

The `mod_ifversion` module is designed for use in testsuites and production deployments of `proftpd`, which may have to deal with different ProFTPD versions and different configurations. The `<IfVersion>` sections supported by `mod_ifversion` allow flexible version checking, including numeric and regular expression comparisons.

This module is contained in the `mod_ifversion.c` file for ProFTPD 1.3.x, and is not compiled by default. Installation instructions are discussed here; a discussion on usage is also available.

The most current version of `mod_ifversion` is distributed with the `proftpd` source code.

## Author

Please contact TJ Saunders <tj at castaglia.org> with any questions, concerns, or suggestions regarding this module.

## Directives

- <IfVersion>

### <IfVersion>

Syntax: <IfVersion [[!]operator] version>
Default: None
Context: All
Module: mod_ifversion
Compatibility: 1.3.1rc1 and later

The `<IfVersion>` section encloses configuration directives which will be used only if the proftpd version matches the configured criteria. For normal (numeric) comparisons the version argument has the following syntax:

      major[.minor[.revision[suffix]]]

e.g. 1.3.1, 1.3.2a, or 1.3.3rc1. If the minor or revision fields are omitted, they are assumed to be zero. An omitted suffix is assumed to be a stable release, instead of a release candidate (RC) or maintenance release.

The following numerical comparison operators are supported:

operator | Description
`=` or `==` | proftpd version is equal
`>` | proftpd version is greater than
`>=` | proftpd version is greater or equal
`<` | proftpd version is less than
`<=` | proftpd version is less or equal

It is also possible to use regular expressions to match the ProFTPD version. To use a regular expression, the operators are:

operator | Description
`=` or `==` | version has the form `/regex/`
`~` | version has the form `regex`

If you wish to reverse the meaning of the operator, prefix the operator with an exclamation mark (!), e.g.:

      <IfVersion != 1.3.1>
        # Do not use these directives if the version is 1.3.1
      </IfVersion>

If operator is omitted, it is assumed to be `=`.

## Installation

The `mod_ifversion` module is distributed with ProFTPD. For including `mod_ifversion` as a statically linked module:

      $ ./configure --with-modules=mod_ifversion

To build `mod_ifversion` as a DSO module:

      $ ./configure --enable-dso --with-shared=mod_ifversion

Then follow the usual steps:

      $ make
      $ make install

For those with an existing ProFTPD installation, you can use the `prxs` tool to add `mod_ifversion`, as a DSO module, to your existing server:

      $ prxs -c -i -d mod_ifversion.c

## Usage

The following examples demonstrate how the `mod_ifversion` can be used.

Using a simple numeric comparison:

      <IfVersion >= 1.3.1rc1>
        # Only use these directives for versions greater or equal 1.3.1rc1
      </IfVersion>

Using a regular expression:

      <IfVersion = /^rc[[:digit:]]$/>
        # Only use these directives for RC (release candidate) versions
      </IfVersion>

Using a reversed regular expression (i.e. in this case, meaning "proftpd version does not match this pattern"):

      <IfVersion !~ ^1.3.[012]$>
        # These directives are not for those versions
      </IfVersion>

© Copyright 2009-2017 TJ Saunders
All Rights Reserved