由 npk 在 04-04-2003 20:51 发表:
RH8+proftp1.2.8+mod_sql+mod_Quota的问题
经过测试mod_mysql使用proftpd1.2.8自己的modules就可以,不需要使用mod_sql-4.08.tar.gz,使用的话在1.2.8编译的时候会报错,只要修改contrib/mod_sql_mysql.c文件#include
1<mysql mysql.h=""> 把他该为你实际路径
2
3
4
5./configure --prefix=/usr/local/proftpd --with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql --with-includes=/usr/include/mysql --with-libraries=/usr/lib/mysql
6
7
8
9进行编译:
10
11make
12
13安装:
14
15make install
16
17
18
19按照精华贴中见表修改proftpd.conf文件auth_mod_mysql是有效的
20
21
22
23use ftp;
24
25create table ftpusers (
26
27userid TEXT NOT NULL,
28
29passwd TEXT NOT NULL,
30
31uid INT NOT NULL,
32
33gid INT NOT NULL,
34
35home TEXT,
36
37shell TEXT
38
39);
40
41
42
43
44
45create table ftpgrps (
46
47grpname TEXT NOT NULL,
48
49gid INT NOT NULL,
50
51members TEXT NOT NULL
52
53);
54
55
56
57
58
59create table quotalimits (
60
61name VARCHAR(30),
62
63quota_type ENUM("user", "group", "class", "all") NOT NULL,
64
65per_session ENUM("false", "true") NOT NULL,
66
67limit_type ENUM("soft", "hard") NOT NULL,
68
69bytes_in_avail FLOAT NOT NULL,
70
71bytes_out_avail FLOAT NOT NULL,
72
73bytes_xfer_avail FLOAT NOT NULL,
74
75files_in_avail INT UNSIGNED NOT NULL,
76
77files_out_avail INT UNSIGNED NOT NULL,
78
79files_xfer_avail INT UNSIGNED NOT NULL
80
81);
82
83
84
85INSERT INTO ftpusers (userid, passwd, uid, gid, home, shell) values ('user1', '999999', '1000', '1000', '/home/ftp/user1', '');
86
87
88
89INSERT INTO quotalimits (name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail) values ('user1', 'user', 'false', 'soft', '10240000', '0', '2048000', '500', '0', '10');
90
91
92
93建立好的表如下
94
95
96
97mysql> desc ftpusers;
98
99+--------+---------+------+-----+---------+-------+
100
101| Field | Type | Null | Key | Default | Extra |
102
103+--------+---------+------+-----+---------+-------+
104
105| userid | text | | | | |
106
107| passwd | text | | | | |
108
109| uid | int(11) | | | 0 | |
110
111| gid | int(11) | | | 0 | |
112
113| home | text | YES | | NULL | |
114
115| shell | text | YES | | NULL | |
116
117+--------+---------+------+-----+---------+-------+
118
119
120
121
122
123mysql> desc ftpgrps;
124
125+---------+---------+------+-----+---------+-------+
126
127| Field | Type | Null | Key | Default | Extra |
128
129+---------+---------+------+-----+---------+-------+
130
131| grpname | text | | | | |
132
133| gid | int(11) | | | 0 | |
134
135| members | text | | | | |
136
137+---------+---------+------+-----+---------+-------+
138
139
140
141
142
143mysql> desc quotalimits;
144
145+------------------+------------------------------------+------+-----+---------+-------+
146
147| Field | Type | Null | Key | Default | Extra |
148
149+------------------+------------------------------------+------+-----+---------+-------+
150
151| name | varchar(30) | YES | | NULL | |
152
153| quota_type | enum('user','group','class','all') | | | user | |
154
155| per_session | enum('false','true') | | | false | |
156
157| limit_type | enum('soft','hard') | | | soft | |
158
159| bytes_in_avail | float | | | 0 | |
160
161| bytes_out_avail | float | | | 0 | |
162
163| bytes_xfer_avail | float | | | 0 | |
164
165| files_in_avail | int(10) unsigned | | | 0 | |
166
167| files_out_avail | int(10) unsigned | | | 0 | |
168
169| files_xfer_avail | int(10) unsigned | | | 0 | |
170
171+------------------+------------------------------------+------+-----+---------+-------+
172
173
174
175使用-n -d5 来看ftpd服务有如下输出:
176
177
178
179[root@m1 sbin]# ./proftpd -n -d5
180
181\- parsing '/usr/local/proftpd/etc/proftpd.conf' configuration
182
183\- <directory></directory>: adding section for resolved path '/'
184
185m1.xxxx.com.cn -
186
187m1.xxxx.com.cn - Config for ProFTPD Mysql+Quota TEST:
188
189m1.xxxx.com.cn- ~ftp/
190
191m1.xxxx.com.cn - Limit
192
193m1.xxxx.com.cn - DenyAll
194
195m1.xxxx.com.cn - UserName
196
197m1.xxxx.com.cn - GroupName
198
199m1.xxxx.com.cn - UserAlias
200
201m1.xxxx.com.cn- MaxClients
202
203m1.xxxx.com.cn - DisplayLogin
204
205m1.xxxx.com.cn - DisplayFirstChdir
206
207m1.xxxx.com.cn - Umask
208
209m1.xxxx.com.cn - SQLConnectInfo
210
211m1.xxxx.com.cn - SQLAuthTypes
212
213m1.xxxx.com.cn - RequireValidShell
214
215m1.xxxx.com.cn - SQLAuthenticate
216
217m1.xxxx.com.cn - SQLHomedirOnDemand
218
219m1.xxxx.com.cn - SQLNamedQuery_get-quota-limit
220
221m1.xxxx.com.cn - SQLNamedQuery_get-quota-tally
222
223m1.xxxx.com.cn - SQLNamedQuery_update-quota-tally
224
225m1.xxxx.com.cn - SQLNamedQuery_insert-quota-tally
226
227m1.xxxx.com.cn - /
228
229m1.xxxx.com.cn - AllowOverwrite
230
231m1.xxxx.com.cn - Umask
232
233m1.xxxx.com.cn - SQLConnectInfo
234
235m1.xxxx.com.cn - SQLAuthTypes
236
237m1.xxxx.com.cn - RequireValidShell
238
239m1.xxxx.com.cn - SQLAuthenticate
240
241m1.xxxx.com.cn - SQLHomedirOnDemand
242
243m1.xxxx.com.cn - SQLNamedQuery_get-quota-limit
244
245m1.xxxx.com.cn - SQLNamedQuery_get-quota-tally
246
247m1.xxxx.com.cn - SQLNamedQuery_update-quota-tally
248
249m1.xxxx.com.cn - SQLNamedQuery_insert-quota-tally
250
251m1.xxxx.com.cn - DefaultServer
252
253m1.xxxx.com.cn - Umask
254
255m1.xxxx.com.cn - QuotaDirectoryTally
256
257m1.xxxx.com.cn - QuotaDisplayUnits
258
259m1.xxxx.com.cn - QuotaEngine
260
261m1.xxxx.com.cn - QuotaShowQuotas
262
263m1.xxxx.com.cn - UserID
264
265m1.xxxx.com.cn - UserName
266
267m1.xxxx.com.cn - GroupID
268
269m1.xxxx.com.cn - GroupName
270
271m1.xxxx.com.cn - SQLConnectInfo
272
273m1.xxxx.com.cn - SQLAuthTypes
274
275m1.xxxx.com.cn - SQLUserTable
276
277m1.xxxx.com.cn - SQLUsernameField
278
279m1.xxxx.com.cn - SQLPasswordField
280
281m1.xxxx.com.cn - SQLUidField
282
283m1.xxxx.com.cn - SQLGidField
284
285m1.xxxx.com.cn - SQLHomedirField
286
287m1.xxxx.com.cn - SQLShellField
288
289m1.xxxx.com.cn - RequireValidShell
290
291m1.xxxx.com.cn - SQLAuthenticate
292
293m1.xxxx.com.cn - SQLHomedirOnDemand
294
295m1.xxxx.com.cn - SQLNamedQuery_get-quota-limit
296
297m1.xxxx.com.cn - SQLNamedQuery_get-quota-tally
298
299m1.xxxx.com.cn - SQLNamedQuery_update-quota-tally
300
301m1.xxxx.com.cn - SQLNamedQuery_insert-quota-tally
302
303m1.xxxx.com.cn - QuotaLimitTable
304
305m1.xxxx.com.cn - QuotaTallyTable
306
307m1.xxxx.com.cn - ProFTPD 1.2.8 (stable) (built 日 3月 30 14:34:22 CST 2003) standalone mode STARTUP
308
309
310
311proftpd.conf
312
313
314
315Umask 022
316
317
318
319# To prevent DoS attacks, set the maximum number of child processes
320
321# to 30. If you need to allow more than 30 concurrent connections
322
323# at once, simply increase this value. Note that this ONLY works
324
325# in standalone mode, in inetd mode you should use an inetd server
326
327# that allows you to limit maximum number of processes per service
328
329# (such as xinetd).
330
331MaxInstances 30
332
333
334
335
336
337QuotaDirectoryTally on
338
339QuotaDisplayUnits Mb
340
341QuotaEngine on
342
343QuotaShowQuotas on
344
345
346
347<global>
348
349
350
351SQLConnectInfo ftp@localhost:3306 root 123456
352
353SQLAuthTypes Backend Plaintext
354
355SQLUserInfo ftpusers userid passwd uid gid home shell
356
357#SQLGroupInfo ftpgrps groupname gid members
358
359
360
361RequireValidShell off
362
363
364
365#SQLAuthenticate users groups usersetfast groupsetfast
366
367SQLAuthenticate users
368
369SQLHomedirOnDemand on
370
371
372
373#..........SQL..........................
374
375
376
377SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM quotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"
378
379
380
381SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM quotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"
382
383
384
385SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" quotatallies
386
387
388
389SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" quotatallies
390
391
392
393QuotaLimitTable sql:/get-quota-limit
394
395QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
396
397
398
399
400
401</global>
402
403
404
405# Set the user and group under which the server will run.
406
407User ftpusr
408
409Group ftpgrp
410
411
412
413只用时mod_sql_mysql是没有问题的,但是一旦使用quota就出错,客户端输出如下
414
415Connected to 202.xxx.xxx.xxx (202.xxx.xxx.xxx)
416
417220 ProFTPD 1.2.8 Server (ProFTPD Mysql+Quota TEST) [m1.xxx.xxx.xxx]
418
419Name (202.xxx.xxx.xxx:root): user1
420
421331 Password required for user1.
422
423Password:
424
425421 Service not available, remote server has closed connection
426
427Login failed.
428
429No control connection for command: No such file or directory
430
431ftp>
432
433
434
435服</mysql>