Debian Codegraph @

doc/contrib/mod_sql_odbc.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD module mod_sql_odbc</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr><br>
10 <center>
11 <h2><b>ProFTPD module <code>mod_sql_odbc</code></b></h2>
12 </center>
13 <hr><br>
14
15 <p>
16 ODBC means <b>O</b>pen <b>D</b>ata<b>b</b>ase <b>C</b>onnectivity, and defines
17 a standard way of connecting to a database server such as MySQL, Postgres,
18 SQL Server, Oracle, <i>etc</i>. Many of the these databases also provide
19 their own native APIs for connectivity, in addition to supporting ODBC. Other
20 databases provide ODBC support, but no support for native connectivity.
21
22 <p>
23 The ProFTPD distribution includes the <code>mod_sql_mysql</code> module for
24 talking to a MySQL database using the native MySQL API, and a
25 <code>mod_sql_postgres</code> for connecting to Postgres databases using the
26 native Postgres API. However, there was no support for databases other
27 than these -- until now. The purpose of the <code>mod_sql_odbc</code> module
28 is to allow ProFTPD's <code>mod_sql</code> module to connect to <b>any</b>
29 database that supports ODBC. This module also allows proftpd to work with
30 databases that may already provide APIs for native connectivity, but for
31 which a specific <code>mod_sql</code> has not yet been developed.
32
33 <p>
34 This module is contained in the <code>mod_sql_odbc.c</code> file for
35 ProFTPD 1.3.<i>x</i>, and is not compiled by default. Installation
36 instructions are discussed <a href="#Installation">here</a>.
37
38 <p>
39 The most current version of <code>mod_sql_odbc</code> is distributed with
40 ProFTPD.
41
42 <h2>Author</h2>
43 <p>
44 Please contact TJ Saunders &lt;tj <i>at</i> castaglia.org&gt; with any
45 questions, concerns, or suggestions regarding this module.
46
47 <h2>Directives</h2>
48 <ul>
49 <li><a href="#SQLODBCVersion">SQLODBCVersion</a>
50 </ul>
51
52 <hr>
53 <h3><a name="SQLODBCVersion">SQLODBCVersion</a></h3>
54 <strong>Syntax:</strong> SQLODBCVersion <em>version</em><br>
55 <strong>Default:</strong> SQLODBCVersion ODBCv3<br>
56 <strong>Context:</strong> server config, <code>&lt;VirtualHost&gt;</code>, <code>&lt;Global&gt;</code><br>
57 <strong>Module:</strong> mod_sql_odbc<br>
58 <strong>Compatibility:</strong> 1.3.6rc2 and later
59
60 <p>
61 The <code>SQLODBCVersion</code> directive configures the ODBC API
62 <em>version</em> that the ODBC driver should use/expect. The default is
63 "ODBCv3", <i>i.e.</i> ODBC version 3. Some drivers may have issues with the
64 default version; this can manifest as errors similar to the following in your
65 <code>SQLLogFile</code>:
66 <pre>
67 message: '[unixODBC][Driver Manager]Driver does not support the requested version'
68 </pre>
69 When this happens, you might try using an older version of ODBC, via:
70 <pre>
71 SQLODBCVersion ODBCv2
72 </pre>
73
74 <p>
75 <hr>
76 <h2><a name="Installation">Installation</a></h2>
77 The <code>mod_sql_odbc</code> relies on one of the two following libraries
78 for ODBC support:
79 <pre>
80 <a href="http://www.iodbc.org">http://www.iodbc.org</a>
81 <a href="http://www.unixodbc.org">http://www.unixodbc.org</a>
82 </pre>
83 One of these ODBC libraries must be installed prior to using
84 <code>mod_sql_odbc</code>.
85
86 <p>
87 Follow the usual steps for using contrib modules in ProFTPD, making sure to
88 list <code>mod_sql</code>. Note that you will need to use the
89 <code>LIBS</code> environment variable for indicating which ODBC library
90 to link against.
91
92 <p>
93 For example, if you wish to use the unixODBC library, you would use:
94 <pre>
95 $ ./configure LIBS=-lodbc --with-modules=mod_sql:mod_sql_odbc ...
96 $ make
97 $ make install
98 </pre>
99 On the other hand, for using the iODBC library, the invocation is slightly
100 different, specifying a different library name:
101 <pre>
102 $ ./configure LIBS=-liodbc --with-modules=mod_sql:mod_sql_odbc ...
103 $ make
104 $ make install
105 </pre>
106
107 <p>
108 You may need to specify the location of the ODBC header and library files in
109 your <code>configure</code> command, <i>e.g.</i>:
110 <pre>
111 $ ./configure \
112 LD_LIBRARY_PATH=/usr/local/odbc/lib \
113 LDFLAGS=-L/usr/local/odbc/lib \
114 LIBS=-lodbc \
115 --with-modules=mod_sql:mod_sql_odbc \
116 --with-includes=/usr/local/odbc/include \
117 --with-libraries=/usr/local/odbc/lib
118 </pre>
119
120 <p>
121 <hr>
122 <h2><a name="Usage">Usage</a></h2>
123 <i>Note</i>: some of the following information is taken from:
124 <pre>
125 <a href="http://www.mysql.com/products/myodbc/manual.html#Introduction_to_ODBC">http://www.mysql.com/products/myodbc/manual.html#Introduction_to_ODBC</a>
126 </pre>
127
128 <p>
129 <b>What is ODBC?</b><br>
130 ODBC (<b>O</b>pen <b>D</b>ata <b>B</b>ase <b>C</b>onnectivity) provides a way
131 for client programs to access a wide range of databases or data sources.
132
133 <p>
134 ODBC is a standardized API, developed according to the specifications of the
135 SQL Access Group, that allows one to connect to SQL databases. It defines a
136 set of function calls, error codes and data types that can be used to develop
137 database-independent applications. ODBC is usually used when database
138 independence, or simultaneous access to different data sources, is required.
139
140 <p>
141 For more information about ODBC, refer to:
142 <pre>
143 http://www.microsoft.com/data/odbc/
144 </pre>
145
146 <p>
147 <b>When should <code>mod_sql_odbc</code> be used?</b><br>
148 There are two cases where a site might need to use the <code>mod_sql_odbc</code>
149 module: when the site's database does not provide a native connectivity API
150 (<i>e.g.</i> FrontBase), and when the site's database does not have a
151 corresponding <code>mod_sql_<i>db</i></code> module for it. For example,
152 ProFTPD does not have a <code>mod_sql_oracle</code> module. Using
153 <code>mod_sql_odbc</code> and an Oracle-provided ODBC driver would allow
154 a site to have <code>proftpd</code> communicate with their Oracle database.
155
156 <p>
157 <b>How does ODBC work?</b><br>
158 An ODBC <i>driver</i> is a dynamically loadable library that knows how to
159 talk to a specific database. Many databases come bundled with an ODBC
160 driver. The following lists where to find ODBC drivers for the popular
161 MySQL and Postgres databases:
162 <dl>
163 <dt>MySQL ODBC Driver (MyODBC)</dt>
164 <dd><a href="http://www.mysql.com/products/myodbc/">http://www.mysql.com/products/myodbc/</a></dd>
165
166 <p>
167 <dt>Postgres ODBC Driver (psqlODBC)</dt>
168 <dd><a href="https://odbc.postgresql.org/">https://odbc.postgresql.org/</a></dd>
169 </dl>
170
171 <p>
172 The ODBC <i>driver manager</i> is a library that manages communication between
173 the ODBC-aware application and ODBC drivers. Its main functionality includes:
174 <ul>
175 <li>resolving Data Source Names (DSN)
176 <li>loading and unloading of the drivers
177 <li>processing ODBC function calls or passing them to the driver
178 </ul>
179 The following lists some commonly used driver managers:
180 <dl>
181 <dt>iODBC ODBC Driver Manager for Unix</dt>
182 <dd><a href="http://www.iodbc.org">http://www.iodbc.org</a></dd>
183
184 <p>
185 <dt>unixODBC Driver Manager for Unix</dt>
186 <dd><a href="http://www.unixodbc.org">http://www.unixodbc.org</a></dd>
187
188 <p>
189 <dt>Microsoft Windows ODBC Driver Manager</dt>
190 <dd><a href="http://www.microsoft.com/data/">http://www.microsoft.com/data/</a></dd>
191 </dl>
192
193 <p>
194 <b>Environment Variables</b><br>
195 There are two environment variables that both the iODBC and unixODBC libraries
196 use: <code>LD_LIBRARY_PATH</code> and <code>ODBCINI</code>. The
197 <code>ODBCINI</code> environment variable specifies the configuration file
198 used by the library; this file specifies the driver to use, and any database
199 connection information that driver may need.The <code>LD_LIBRARY_PATH</code>
200 environment variable is used to tell the Driver Manager where it may find
201 the driver libraries. Note that on a Linux system, if the
202 <code>/etc/ld.so.conf</code> contains the directory where the ODBC driver
203 libraries live (and <code>/sbin/ldconfig</code> has been run), use of
204 the <code>LD_LIBRARY_PATH</code> setting may not be necessary.
205
206 <p>
207 <b>Configuring ODBC</b><br>
208 The hard part about using the iODBC or unixODBC Unix driver managers is
209 their configuration. Often in ODBC documentation you will mention of DSNs,
210 or Data Source Names. A data source identifies a path to data that can include
211 a network library, server, database, and other attributes. To connect to a data
212 source, the driver manager checks for specific connection information. This
213 specific connection information is recorded in a file usually called
214 &quot;odbc.ini&quot;.
215
216 <p>
217 Example iODBC <code>odbc.ini</code> file:
218 <pre>
219 [ODBC Data Sources]
220 mysql = MySQL ODBC Connector (MyODBC)
221
222 [mysql]
223 Driver = /usr/local/iodbc/lib/libmyodbc3.so
224 Description = MySQL Driver
225 Server = localhost
226 Database = proftpd
227 Port = 3306
228 Socket = /tmp/mysql.sock
229 </pre>
230
231 <p>
232 Example unixODBC <code>odbc.ini</code> file:
233 <pre>
234 [mysql]
235 Description = MySQL
236 Driver = mysql
237 Server = localhost
238 Database = proftpd
239 Port = 3306
240 Socket = /tmp/mysql.sock
241 </pre>
242
243 More details on the contents of <code>odbc.ini</code> files, and the different
244 meanings of configuration options, can be found in the respective driver
245 manager documentation.
246
247 <p>
248 <b>Configuring <code>mod_sql_odbc</code></b><br>
249 For the most part, <code>mod_sql_odbc</code> requires little configuration.
250 It relies on the ODBC driver managers, which in turn use the above
251 environment variables. This means that <code>ODBCINI</code> and
252 <code>LD_LIBRARY_PATH</code> can be set in the environment, before starting
253 <code>proftpd</code>, and <code>mod_sql_odbc</code> would then work. The
254 one required bit of information is the
255 <a href="mod_sql.html#SQLConnectInfo"><code>SQLConnectInfo</code></a> directive.
256 This directive needs to contain the name of the stanza in your
257 <code>odbc.ini</code> file which holds the configuration. Using the example
258 <code>odbc.ini</code> files above, you would need the following in your
259 <code>proftpd.conf</code>:
260 <pre>
261 # Tells mod_sql to use mod_sql_odbc
262 SQLBackend odbc
263
264 # Tells mod_sql_odbc which odbc.ini stanza to use
265 SQLConnectInfo mysql
266 </pre>
267
268 <p>
269 Starting with proftpd 1.2.10rc1, it is possible to use the <code>SetEnv</code>
270 configuration directives to set the environment variables directly in
271 the <code>proftpd.conf</code> file, which makes configuration more
272 centralized.
273
274 <p>
275 Example configuration using <code>SetEnv</code>:
276 <pre>
277 &lt;IfModule mod_sql_odbc.c&gt;
278 SetEnv LD_LIBRARY_PATH <i>/path/to/odbc/lib</i>
279 SetEnv ODBCINI <i>/path/to/</i><code>odbc.ini</code>
280 &lt;/IfModule&gt;
281 </pre>
282
283 <p>
284 Once you have your ODBC driver configured properly, you can follow the rest
285 of the instructions in the <a href="../../howto/SQL.html">SQL howto</a>
286 for creating the schema for user/group authentication.
287
288 <p>
289 Please contact the author directly with any questions or comments.
290
291 <p>
292 <hr>
293 <font size=2><b><i>
294 &copy; Copyright 2003-2020 TJ Saunders<br>
295 All Rights Reserved<br>
296 </i></b></font>
297 <hr>
298
299 </body>
300 </html>