-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_mime.html
226 lines (194 loc) · 7.31 KB
/
mod_mime.html
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
219
220
221
222
223
224
225
226
<html>
<head>
<title>ProFTPD module mod_mime</title>
</head>
<body bgcolor=white>
<hr>
<center>
<h2><b>ProFTPD module <code>mod_mime</code></b></h2>
</center>
<hr><br>
This module is contained in the <code>mod_mime.c</code> file for
ProFTPD 1.3.<i>x</i>, and is not compiled by default. Installation
instructions are discussed <a href="#Installation">here</a>.
<p>
The purpose of the <code>mod_mime</code> module is to automatically
determine the <a href="https://en.wikipedia.org/wiki/Internet_media_type">MIME type</a> of uploaded files, and possibly to reject the upload if the detected
MIME type has been blacklisted.
<p>
The <code>mod_mime</code> module uses the <code>libmagic</code> library on
which the <a href="https://en.wikipedia.org/wiki/File_%28command%29"><code>file(1)</code></a> command is based, using <a href="https://en.wikipedia.org/wiki/File_format#Magic_number">file format magic numbers</a>.
<p>
The most current version of <code>mod_mime</code> can be found at:
<pre>
<a href="https://github.com/Castaglia/proftpd-mod_mime.git">https://github.com/Castaglia/proftpd-mod_mime</a>
</pre>
<h2>Author</h2>
<p>
Please contact TJ Saunders <tj <i>at</i> castaglia.org> with any
questions, concerns, or suggestions regarding this module.
<h2>Directives</h2>
<ul>
<li><a href="#MIMEAllowType">MIMEAllowType</a>
<li><a href="#MIMEDenyType">MIMEDenyType</a>
<li><a href="#MIMEEngine">MIMEEngine</a>
<li><a href="#MIMELog">MIMELog</a>
<li><a href="#MIMEOptions">MIMEOptions</a>
<li><a href="#MIMETable">MIMETable</a>
</ul>
<p>
<hr>
<h3><a name="MIMEAllowType">MIMEAllowType</a></h3>
<strong>Syntax:</strong> MIMEAllowType <em>type1 ...</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> "server config" <code><VirtualHost></code>, <code><Global></code>, <code><Anonymous></code>, <code><Directory></code>, <code>.ftpaccess</code><br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> 1.3.0rc1 and later
<p>
The <code>MIMEAllowType</code> directive is used to a list of MIME types which
are allowed. If an uploaded file has a MIME type which is <b>not</b> in the
list of allowed types, then the upload will be aborted with a
"Permission denied" error.
<p>
The <code>MIMEAllowType</code> directive can be set for an entire vhost, or
just for specific directories. For example:
<pre>
<IfModule mod_mime.c>
MIMEEngine on
...
<Directory /path/to/images>
# Allow only .png files to be uploaded to this directory
MIMEAllowType image/png
</Directory>
</IfModule>
</pre>
<p>
<hr>
<h3><a name="MIMEDenyType">MIMEDenyType</a></h3>
<strong>Syntax:</strong> MIMEDenyType <em>type1 ...</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> "server config" <code><VirtualHost></code>, <code><Global></code>, <code><Anonymous></code>, <code><Directory></code>, <code>.ftpaccess</code><br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> 1.3.0rc1 and later
<p>
The <code>MIMEDenyType</code> directive is used to a list of MIME types which
are denied. If an uploaded file has a MIME type which appears in the list of
denied types, then the upload will be aborted with a "Permission denied" error.
<p>
The <code>MIMEDenyType</code> directive can be set for an entire vhost, or
just for specific directories. For example:
<pre>
<IfModule mod_mime.c>
MIMEEngine on
...
<Directory /path/to/images>
# Prevent .gif files to be uploaded to this directory
MIMEDenyType image/gif
</Directory>
</IfModule>
</pre>
<p>
<hr>
<h3><a name="MIMEEngine">MIMEEngine</a></h3>
<strong>Syntax:</strong> MIMEEngine <em>on|off</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> 1.3.0rc1 and later
<p>
The <code>MIMEEngine</code> directive enables the MIME detection
implemented by <code>mod_mime</code>.
<p>
<hr>
<h3><a name="MIMELog">MIMELog</a></h3>
<strong>Syntax:</strong> MIMELog <em>file|"none"</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> 1.3.0rc1 and later
<p>
The <code>MIMELog</code> directive is used to specify a log file for
<code>mod_mime</code>'s reporting on a per-server basis. The <em>file</em>
parameter given must be the full path to the file to use for logging.
<p>
<hr>
<h3><a name="MIMEOptions">MIMEOptions</a></h3>
<strong>Syntax:</strong> MIMEOptions <em>opt1 ...</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config, <code><VirtualHost></code>, <code><Global></code><br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> 1.3.6rc2 and later
<p>
The <code>MIMEOptions</code> directive is used to configure various optional
behavior of <code>mod_mime</code>.
<p>
The currently implemented options are:
<ul>
<li><code>NoMLSxFacts</code><br>
<p>
The <code>mod_mime</code> module will automatically
To disable this MIME type discovery for any reason, use this option.
<b>Not recommended.</b>
<p>
<b>Note</b>: The <code>NoMLSxFacts</code> option is
<em>automatically</em> enabled when using ProFTPD versions before
1.3.6rc2, due to bugs/missing support in the older versions.
</li>
</ul>
<p>
<hr>
<h3><a name="MIMETable">MIMETable</a></h3>
<strong>Syntax:</strong> MIMETable <em>table1 ...</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> "server config"
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> 1.3.0rc1 and later
<p>
The <code>MIMETable</code> directive is used to configure the <em>path</em>
to database files which provide <code>magic(5)</code> formatted data/entries.
<p>
This directive is <b>required</b>; the <code>libmagic</code> library does
<b>not</b> know the location of its default database. Note that the default
database can also be set using the <code>MAGIC</code> environment variable.
<p>
<hr>
<h2><a name="Installation">Installation</a></h2>
Note that the <code>libmagic-devel</code> package may be needed on some
systems, for providing the necessary headers/libraries for
<code>libmagic</code>. Otherwise, see the <code>file</code> source code
at <a href="ftp://ftp.astron.com/pub/file/">ftp://ftp.astron.com/pub/file/</a>.
<p>
To install <code>mod_mime</code>, copy the <code>mod_mime.c</code> file into:
<pre>
<i>proftpd-dir</i>/contrib/
</pre>
after unpacking the latest proftpd-1.3.<i>x</i> source code. For including
<code>mod_mime</code> as a staticly linked module:
<pre>
$ ./configure --with-modules=mod_mime
</pre>
To build <code>mod_mime</code> as a DSO module:
<pre>
$ ./configure --enable-dso --with-shared=mod_mime
</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_mime</code>, as a DSO module, to
your existing server:
<pre>
$ prxs -c -i -d mod_mime.c
</pre>
<p>
<hr>
<font size=2><b><i>
© Copyright 2013-2019 TJ Saunders<br>
All Rights Reserved<br>
</i></b></font>
<hr>
</body>
</html>