ProFTPD module mod_rename



This module is contained in the mod_rename.c file for ProFTPD 1.2, and is not compiled by default. Comments on the usage of this module follow. Installation instructions are discussed here.

The most current version of mod_rename can be found at:

  http://www.castaglia.org/proftpd/

Author

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

Thanks

2001-12-22: Thanks to Terry Davis <tdavis at birddog.com> for all his help in developing this module

Directives


RenameEngine

Syntax: RenameEngine on|off
Default: None
Context: server config, <VirtualHost>, <Global>
Module: mod_rename
Compatibility: 1.2.2 and later

The RenameEngine directive turns on or off mod_rename's renaming engine. Use this directive to disable the module, rather than commenting all mod_rewrite directives.


RenameFilter

Syntax: RenameFilter regex|"duplicate"|"none" [filter-opts]
Default: None
Context: <Directory>, .ftpaccess
Module: mod_rename
Compatibility: 1.2.2 and later

The RenameFilter directive is used to configure a regular expression that the name of a file being uploaded must match in order to qualify for renaming. If no RenameFilter is given, all uploaded files are eligible to be renamed.

If the special filter "duplicate" is used, it means to apply the renaming rules to the uploaded file only if that filename is a duplicate of an already existing filename in that directory.

If the special filter "none" is used, it means that no filter must be matched for the renaming rules to apply to uploaded files. This is used to remove any RenameFilters inherited from parent directories.

The optional filter-opts parameter can be used to configure the following filter options:

See Also: RenameTarget


RenameLog

Syntax: RenameLog file|"none"
Default: None
Context: server config, <VirtualHost>, <Global>
Module: mod_rename
Compatibility: 1.2.2 and later

The RenameLog directive is used to specify a log file for mod_rename's reporting on a per-server basis. The file parameter given must be the full path to the file to use for logging.

If no log file is given, the module will log messages at debug level 3. If the file given is "none", no logging will be done at all; this setting can be used to override a RenameLog inherited from a <Global> context.


RenamePrefix

Syntax: RenamePrefix text|"none"
Default: None
Context: <Directory>, .ftpaccess
Module: mod_rename
Compatibility: 1.2.2 and later

The RenamePrefix directive is used to specify some text that will be prepended to the name to which an eligible file is renamed (e.g. "/home/bob/tmpfile" would become "/home/bob/new.tmpfile" if "RenamePrefix new." was configured).

The special character ~ may be used in text. It will be expanded to the current username when files are renamed.

The special character # may be used in text. It will be expanded to a number when file are renamed. This number is determined as follows: if a file of the name that mod_rename wants to use already exists, # will be set to "1". For example, with RenamePrefix #., if file "foo" is uploaded (and already exists in the destination directory), the module will attempt to rename the file to "1.foo". The next time file "foo" is uploaded, it will be renamed to "2.foo" (assuming that file "1.foo" has not been deleted in the meantime).


RenameSuffix

Syntax: RenameSuffix text|"none"
Default: None
Context: <Directory>, .ftpaccess
Module: mod_rename
Compatibility: 1.2.2 and later

The RenameSuffix directive is used to specify some text that will be apppended to the name of the file to which an eligible file is renamed (e.g. "/home/bob/tmpfile" would become "/home/bob/tmpfile.renamed" if "RenameSuffix .renamed" was configured).

The special character ~ may be used in text. It will be expanded to the current username when files are renamed.

The special character # may be used in text. It will be expanded to a number when the file is renamed. This number is determined as follows: if a file of the name that mod_rename wants to use already exists, # will be set to "1". For example, with RenameSuffix .#, if file "foo" is uploaded (and already exists in the destination directory), the module will attempt to rename the file to name "foo.1". The next time file "foo" is uploaded, it will be renamed to "foo.2" (assuming that file "foo.1" has not been deleted in the meantime).


RenameTarget

Syntax: RenameTarget "user"|"group"|"class" expression
Default: None
Context: <Directory>, .ftpaccess
Module: mod_rename
Compatibility: 1.2.2 and later

The RenameTarget directive is used to restrict the application of the renaming rules only to specific users. If the "user" restriction is given, then expression is a user-expression specifying which users' files will be renamed. Similarly for the "group" restriction. For the "class" restriction, the expression is simply the (single) name of the connection Class on which renaming will be used.

In the case of multiple RenameTarget directives for a single directory, each with a different restriction, the restrictions will be applied in the following order of precedence: "user", then "group", then "class". If no restriction was used, renaming will apply to everyone. If this sort of functionality is desired, it is best to write directives in this order (see example).

Example:

  # These renaming rules are only to apply to MP3 files.
  RenameFilter \.mp3$

  # Rename files for everyone but user bob
  RenameTarget user !bob

  # Add a suffix to all files being renamed
  RenameSuffix .untrusted

See Also: RenameFilter, RenamePrefix, RenameSuffix



Usage

This module has absolutely no connection to the RNFR or RNTO FTP commands. It works by adjusting the name of the file being STORed by the client behind the scenes, before the transfer of the content of the file has started. One of the consequences is that the renamed path may run afoul of any configured AllowFilter, DenyFilter, PathAllowFilter, or PathDenyFilter directives, causing unexpected or unwanted problems. Please keep this in mind when configuring prefices and suffices.

In the case where both RenamePrefix and RenameSuffix are configured, and both configured strings contain the special # character, and a file of the name to use exists, both occurrences of # will be incremented.



Installation

To install mod_rename, copy the mod_rename.c file into
  proftpd-dir/contrib/
after unpacking the latest proftpd-1.2 source code. Then follow the usual steps for using third-party modules in proftpd:
  ./configure --with-modules=mod_rename
  make
  make install



Author: $Author: tj $
Last Updated: $Date: 2002/07/16 18:18:11 $


© Copyright 2000-2002 TJ Saunders
All Rights Reserved