RH8+proftp1.2.8+mod_sql+mod_Quota的问题

由 npk 在 03-30-2003 15:06 发表:

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&gt; 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&gt; 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&gt; 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  
311  
312  
313proftpd.conf   
314  
315  
316  
317Umask 022   
318  
319  
320  
321# To prevent DoS attacks, set the maximum number of child processes   
322  
323# to 30. If you need to allow more than 30 concurrent connections   
324  
325# at once, simply increase this value. Note that this ONLY works   
326  
327# in standalone mode, in inetd mode you should use an inetd server   
328  
329# that allows you to limit maximum number of processes per service   
330  
331# (such as xinetd).   
332  
333MaxInstances 30   
334  
335  
336  
337  
338  
339QuotaDirectoryTally on   
340  
341QuotaDisplayUnits Mb   
342  
343QuotaEngine on   
344  
345QuotaShowQuotas on   
346  
347  
348  
349<global>   
350  
351  
352  
353SQLConnectInfo ftp@localhost:3306 root s_search   
354  
355SQLAuthTypes Backend Plaintext   
356  
357SQLUserInfo ftpusers userid passwd uid gid home shell   
358  
359#SQLGroupInfo ftpgrps groupname gid members   
360  
361  
362  
363RequireValidShell off   
364  
365  
366  
367#SQLAuthenticate users groups usersetfast groupsetfast   
368  
369SQLAuthenticate users   
370  
371SQLHomedirOnDemand on   
372  
373  
374  
375#..........SQL..........................   
376  
377  
378  
379SQLNamedQuery 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}'"   
380  
381  
382  
383SQLNamedQuery 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}'"   
384  
385  
386  
387SQLNamedQuery 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   
388  
389  
390  
391SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" quotatallies   
392  
393  
394  
395QuotaLimitTable sql:/get-quota-limit   
396  
397QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally   
398  
399  
400  
401  
402  
403</global>   
404  
405  
406  
407# Set the user and group under which the server will run.   
408  
409User ftpusr   
410  
411Group ftpgrp 
412
413  
414
415
416* * *
417
418  
419_由 npk 在 03-30-2003 15:07 发表:_   
420  
421
422
423****
424
425  
426  
427
428
429只用时mod_sql_mysql是没有问题的,但是一旦使用quota就出错,客户端输出如下   
430  
431Connected to 202.xxx.xxx.xxx (202.xxx.xxx.xxx)   
432  
433220 ProFTPD 1.2.8 Server (ProFTPD Mysql+Quota TEST) [m1.xxx.xxx.xxx]   
434  
435Name (202.xxx.xxx.xxx:root): user1   
436  
437331 Password required for user1.   
438  
439Password:   
440  
441421 Service not available, remote server has closed connection   
442  
443Login failed.   
444  
445No control connection for</mysql>
Published At
Categories with 服务器类
Tagged with
comments powered by Disqus