File: mod_counter.html

package info (click to toggle)
proftpd-mod-counter 0.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 224 kB
  • sloc: perl: 3,012; ansic: 885; makefile: 15
file content (218 lines) | stat: -rw-r--r-- 7,409 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<html>
<head>
<title>ProFTPD module mod_counter</title>
</head>

<body bgcolor=white>

<hr><br>
<center>
<h2><b>ProFTPD module <code>mod_counter</code></b></h2>
</center>
<hr><br>

The <code>mod_counter</code> module is designed to allow a sort of
&quot;locking&quot; to be enforced when the same file is being uploaded
or downloaded by multiple clients at the same time.

<p>
The <code>mod_counter</code> 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.  

<p>
This module is contained in the <code>mod_counter.c</code> file for
ProFTPD 1.2.<i>x</i>/1.3.<i>x</i>, and is not compiled by default.
Installation instructions are discussed <a href="#Installation">here</a>.
Example configurations and further details are discussed in the
<a href="#Usage">usage</a> section.

<p>
The most current version of <code>mod_counter</code> can be found at:
<pre>
  <a href="http://www.castaglia.org/proftpd/">http://www.castaglia.org/proftpd/</a>
</pre>

<h2>Author</h2>
<p>
Please contact TJ Saunders &lt;tj <i>at</i> castaglia.org&gt; with any
questions, concerns, or suggestions regarding this module.

<h2>Directives</h2>
<ul>
  <li><a href="#CounterEngine">CounterEngine</a>
  <li><a href="#CounterFile">CounterFile</a>
  <li><a href="#CounterLog">CounterLog</a>
  <li><a href="#CounterMaxReaders">CounterMaxReaders</a>
  <li><a href="#CounterMaxWriters">CounterMaxWriters</a>
</ul>

<hr>
<h2><a name="CounterEngine">CounterEngine</a></h2>
<strong>Syntax:</strong> CounterEngine <em>on|off</em><br>
<strong>Default:</strong> off<br>
<strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
<strong>Module:</strong> mod_counter<br>
<strong>Compatibility:</strong> 1.2.10rc1 and later

<p>
The <code>CounterEngine</code> directive enables or disables the module's
runtime counter engine.  If it is set to <em>off</em> this module does no
&quot;locking&quot;.  Use this directive to disable the module instead of
commenting out all <code>mod_counter</code> directives.

<p>
<hr>
<h2><a name="CounterFile">CounterFile</a></h2>
<strong>Syntax:</strong> CounterFile <em>path</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code>, <code>&lt;Anonymous&gt;</code>, <code>&lt;Directory&gt;</code><br>
<strong>Module:</strong> mod_counter<br>
<strong>Compatibility:</strong> 1.3.2rc1 and later

<p>
The <code>CounterFile</code> directive configures a file that
<code>mod_counter</code> uses for tracking the semaphores it creates.  This
directive is <b>required</b> for <code>mod_counter</code>, if enabled,
to function.

<p>
<hr>
<h2><a name="CounterLog">CounterLog</a></h2>
<strong>Syntax:</strong> CounterLog <em>path|&quot;none&quot;</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
<strong>Module:</strong> mod_counter<br>
<strong>Compatibility:</strong> 1.2.10rc1 and later

<p>
The <code>CounterLog</code> directive is used to a specify a log file for
<code>mod_counter</code> reporting and debugging, and can be done a per-server
basis.  The <em>path</em> parameter must be the full path to the file to use for
logging.  Note that this path must <b>not</b> be to a world-writeable
directory and, unless <code>AllowLogSymlinks</code> is explicitly set to
<em>on</em> (generally a bad idea), the path must <b>not</b> be a symbolic
link.

<p>
If <em>path</em> is &quot;none&quot;, no logging will be done at all; this
setting can be used to override a <code>CounterLog</code> setting inherited from
a <code>&lt;Global&gt;</code> context.

<p>
<hr>
<h2><a name="CounterMaxReaders">CounterMaxReaders</a></h2>
<strong>Syntax:</strong> CounterMaxReaders <em>max</em><br>
<strong>Default:</strong> 0<br>
<strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code>, <code>&lt;Anonymous&gt;</code>, <code>&lt;Directory&gt;</code><br>
<strong>Module:</strong> mod_counter<br>
<strong>Compatibility:</strong> 1.2.10rc1 and later

<p>
The <code>CounterMaxReaders</code> 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 <code>mod_counter</code>.

<p>
<hr>
<h2><a name="CounterMaxWriters">CounterMaxWriters</a></h2>
<strong>Syntax:</strong> CounterMaxWriters <em>max</em><br>
<strong>Default:</strong> 1<br>
<strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code>, <code>&lt;Anonymous&gt;</code>, <code>&lt;Directory&gt;</code><br>
<strong>Module:</strong> mod_counter<br>
<strong>Compatibility:</strong> 1.2.10rc1 and later

<p>
The <code>CounterMaxWriters</code> 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 <code>mod_counter</code>.

<p>
<hr>
<h2><a name="Installation">Installation</a></h2>
To install <code>mod_counter</code>, copy the <code>mod_counter.c</code> file
into
<pre>
  <i>proftpd-dir</i>/contrib/
</pre>
after unpacking the latest proftpd-1.3.<i>x</i> source code.  Then follow the
usual steps for using third-party modules in proftpd:
<pre>
  ./configure --with-modules=mod_counter
</pre>
To build <code>mod_counter</code> as a DSO module:
<pre>
  ./configure --enable-dso --with-shared=mod_counter
</pre>
Then follow the usual steps:
<pre>
  make
  make install
</pre>

<p>
For those with an existing ProFTPD installation, you can use the
<code>prxs</code> tool to add <code>mod_counter</code>, as a DSO module, to
your existing server:
<pre>
  # prxs -c -i -d mod_counter.c
</pre>

<p>
<hr>
<h2><a name="Usage">Usage</a></h2>
The <code>mod_counter</code> module pays attention to the following FTP
commands:
<ul>
  <li><code>APPE</code>
  <li><code>DELE</code>
  <li><code>RETR</code>
  <li><code>RNFR</code>
  <li><code>RNTO</code>
  <li><code>STOR</code>
</ul>

This means, for example, that you can use <code>mod_counter</code> to prevent
an uploaded file from being deleted or renamed before the uploading client
has finished the upload by using:
<pre>
  &lt;IfModule mod_counter.c&gt;
    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
  &lt;/IfModule&gt;
</pre>

<p>
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
<code>CounterMaxReaders</code> directive:
<pre>
  &lt;IfModule mod_counter.c&gt;
    CounterEngine on
    CounterFile /var/proftpd/counter.txt

    # Allow only three clients at a time to be reading the same file
    CounterMaxReaders 3
  &lt;/IfModule&gt;
</pre>

<p>
<hr><br>

<font size=2><b><i>
&copy; Copyright 2004-2017 TJ Saunders<br>
 All Rights Reserved<br>
</i></b></font>

<hr><br>

</body>
</html>