mod_counter
mod_counter
module is designed to allow a sort of
"locking" to be enforced when the same file is being uploaded
or downloaded by multiple clients at the same time.
The mod_counter
works by creating a SysV semaphore for a file
being read/written, and placing a number of reader or writer "counters" in that
semaphore. When the configured maximum number of counters is reached, the
FTP command which seeks to add another reader/writer counter will be denied.
This allows site to configure the maximum number of clients which can be
reading/writing any file at one time.
This module is contained in the mod_counter.c
file for
ProFTPD 1.2.x/1.3.x, and is not compiled by default.
Installation instructions are discussed here.
Example configurations and further details are discussed in the
usage section.
The most current version of mod_counter
can be found at:
http://www.castaglia.org/proftpd/
Please contact TJ Saunders <tj at castaglia.org> with any questions, concerns, or suggestions regarding this module.
<VirtualHost>
, <Global>
The CounterEngine
directive enables or disables the module's
runtime counter engine. If it is set to off this module does no
"locking". Use this directive to disable the module instead of
commenting out all mod_counter
directives.
<VirtualHost>
, <Global>
, <Anonymous>
, <Directory>
The CounterFile
directive configures a file that
mod_counter
uses for tracking the semaphores it creates. This
directive is required for mod_counter
, if enabled,
to function.
<VirtualHost>
, <Global>
The CounterLog
directive is used to a specify a log file for
mod_counter
reporting and debugging, and can be done a per-server
basis. The path parameter must be the full path to the file to use for
logging. Note that this path must not be to a world-writeable
directory and, unless AllowLogSymlinks
is explicitly set to
on (generally a bad idea), the path must not be a symbolic
link.
If path is "none", no logging will be done at all; this
setting can be used to override a CounterLog
setting inherited from
a <Global>
context.
<VirtualHost>
, <Global>
, <Anonymous>
, <Directory>
The CounterMaxReaders
directive specifies the maximum number
of clients allowed to be reading to the same file at the same time. By
default, all clients are allowed to read the same file at one time
by mod_counter
.
<VirtualHost>
, <Global>
, <Anonymous>
, <Directory>
The CounterMaxWriters
directive specifies the maximum number
of clients allowed to be writing to the same file at the same time. By
default, only one client is allowed to write to the same file at one time
by mod_counter
.
mod_counter
, copy the mod_counter.c
file
into
proftpd-dir/contrib/after unpacking the latest proftpd-1.3.x source code. Then follow the usual steps for using third-party modules in proftpd:
./configure --with-modules=mod_counterTo build
mod_counter
as a DSO module:
./configure --enable-dso --with-shared=mod_counterThen follow the usual steps:
make make install
For those with an existing ProFTPD installation, you can use the
prxs
tool to add mod_counter
, as a DSO module, to
your existing server:
# prxs -c -i -d mod_counter.c
mod_counter
module pays attention to the following FTP
commands:
APPE
DELE
RETR
RNFR
RNTO
STOR
mod_counter
to prevent
an uploaded file from being deleted or renamed before the uploading client
has finished the upload by using:
<IfModule mod_counter.c> CounterEngine on CounterFile /var/proftpd/counter.txt # Allow only one client at a time to be writing (including deletes and renames) to a given file. CounterMaxWriters 1 </IfModule>
Likewise, if for some reason you need to limit the number of clients which
can be downloading a given file at the same time, you would use the
CounterMaxReaders
directive:
<IfModule mod_counter.c> CounterEngine on CounterFile /var/proftpd/counter.txt # Allow only three clients at a time to be reading the same file CounterMaxReaders 3 </IfModule>