Proftpd + mysql + quota

xiaoxiao2021-03-06  40

Download software

PrOFTPD-1.2.9.tar.gz

PrOFTPD-Mod-QuotataB-1.2.11.tar.gz

Note: If proFTPD-1.2.10, you don't need proftpd-modquotata steps as follows: [Root @ localhost] vi /etc/ld.so.conf Add: / usr / local / mysql / lib [root @ localhost] TAR ZVXF Proftpd-1.2.9.tar.gz [root @ localhost] tar zvxf proFTPD-mod-quotataab-1.2.11.tar.gz [root @ localhost] cp mode_quotatab / *. c proFTPD-1.2.9 / contrib / [root @localhost] cp MOD_QUTATAB / *. h ProftPD-1.2.9 / Contrib / [root @ localhost] vi proFTPD-1.2.9 / contrib / mod_sql_mysql.c #include Modify Mysql.h's actual path [root @ localhost] CD proFTPD-1.2.9 [root @ localhost] ./configure / - prefix = / usr / local / proFTPD / - with-modules = mod_sql: mod_sql_mysql: MOD_QUTATAB /: MOD_QUTATAB_SQL: MOD_TATAB_SQL: MOD_RATIO / - WITH-ISQL / INCLUDE / - with-Libraries = / usr / local / mysql / lib [root @ localhost] make (if it is a dual CPU recommended Make -J3) [root @ localhost] make install [root @ localhost] cp proFTPD-1.2.9 / contrib / dist / rpm / proFTPD.init.d /etc/rc.d/init.d/proftpd [root @ localhost] Vi /etc/rc.d/init.d/proftpd modification: path = "$ path: / usr / local / proFTPD / sbin" [root @ localhost] chmod 755 /etc/rc.d/ Init.d / proFTPD [root @ localhost] chkconfig --level 3 proftpd on [root @ localhost] chkconfig --add Porftpd [root @ localhost] groupadd -g 5500 ftpgroup [root @ localhost] adduser -u 5500 -s / bin / false -d / bin / null -c "proFTPD user" -g ftpgroup ftpuser then configures your proFTPD.conf, and finally start. [root @ localhost] / usr / local / proFTPD / SBIN / PrOFTPD ------------------------------ Proftpd.conf- ---------------------------------

Code: # this is a Basic Protepd Configuration File (rename it to # 'protepd.conf' for actual use. It establishes a single server # and a single anonymous login. It assumes That You Have a user / group # "Nobody" and "ftp" for normal operation and anon. ServerName "ltsnet" ServerType standalone DefaultServer on # Port 21 is the standard FTP port. Port 21 # Umask 022 is a good standard umask to prevent new dirs and files # from being group and world writable. Umask 022 # to prevent DoS attacks, set the maximum number of child processes # to 30. If you need to allow more than 30 concurrent connections # at once, simply increase this value. Note that this ONLY works # in standalone mode, in inetd mode you should use an inetd server # that allows you to limit maximum number of processes per service # (such as xinetd). MaxInstances 30 # Set the user and group under which the server will run. User nobody Group nobody # To cause every FTP user to be "jailed" (chrooted) into their home # directory, uncomment this line. ServerIdent off DisplayLogin welcome.msg DefaultRoot ~ # Normally, we want files to be overwriteable. AllowOverwrite on # A basic anonymous configuration, no upload directories. If you do not # want anonymous users, simply delete this entire section. User ftp Group ftp # We want clients to be able to login with "Anonymous" As Well AS "ftp" Useralias Anonymous ftp # limited The maximum number of anonymous logins maxclients 10 # we want '

welcome.msg 'displayed at login, and' .message 'displayed # in each newly chdired directory. DisplayLogin welcome.msg DisplayFirstChdir .message # Limit WRITE everywhere in the anonymous chroot DenyAll SQLAuthTypes Backend Plaintext SQLAuthenticate users * groups * SQLConnectInfo proftpd @ localhost root 123456 SQLUserInfo ftpuser userid passwd uid gid homedir shell SQLGroupInfo ftpgroup groupname gid members SQLHomedirOnDemand on SQLLog PASS updatecount SQLNamedQuery updatecount UPDATE "count = count 1, accessed = now () WHERE userid = ' % u ' "ftpuser SQLLog STOR, DELE modified SQLNamedQuery modified UPDATE" modified = now () WHERE userid ='% u ' "ftpuser QuotaEngine on QuotaDirectoryTally on QuotaDisplayUnits Mb QuotaShowQuotas on QuotaLog" / var / log / quota "SQLNamedQuery get-quota- Limit Select "Name, quota_type, per_session, limited_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail from ftpquotalimits WHERE name = '% {0}' AND quota_type = '% {1}' "SQLNamedQuery 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 ftpquotatallies WHERE name = '% {0} 'AND quota_type ='% {1} ' "SQLNamedQuery 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}' "ftpquotatallies sqlnamedquery insert-quota-Tally Insert"% {0},% {1},% {2},% {3},% {4},% {5},% {6},% {7} "ftpquotatallies quotalimittable sql: / get-quota-limited quotatallytable sql: / get-quota-tally / update-quota-tally / Insert-quota-tally built the PrOFTPD library, import ftpdb.sql in phpmyadmin. ------------------------------- ------- ftpdb.sql ---------------------------------

Code: # Table structure` # Create Table `ftpgroup` (` Groupname` Varchar (16) Not null default ', `Gid` Smallint (6) Not null default' 5500 ',` Members` VARCHAR (16) NOT NULL Default '', Key `Groupname` (` Groupname`)) type = myisam comment = 'proftp group table'; # # Export table in the table in the table` # Insert Into `ftpGroup` Values ​​('ftpgroup', 5500 , 'ftpuser'); # ------------------------------------------ ------------- # Table Structure `ftpquotalimits` # Create Table` ftpquotalimits` (`Name` VARCHAR (30) Default Null,` Quota_Type` Enum ('user', 'Group' , 'class', 'all') Not null default 'user', `per_session` Enum ('false', 'true') Not null default 'false',` limit_type` enum ('Soft', 'Hard') Not NULL default 'soft', `bytes_in_avail` float NOT NULL default '0',` bytes_out_avail` float NOT NULL default '0', `bytes_xfer_avail` float NOT NULL default '0',` files_in_avail` int (10) unsigned NOT NULL default '0', `files_out_avail` int (10) unsigned not null default '0',` files_xfer_avail` int (10) unsigned n Ot NULL Default '0') Type = Myisam; # # Export Table Data `ftpquotalimits` # Insert Into` ftpquotalimits` Values ​​('Test', 'User', 'True', 'Hard', '9e 06' , '2000', '9e 09', 2000, 2000, 2000); # ------------------------------- ------------------------- # Table Structure `ftpquotatallies` # CREATE TABLE`

Ftpquotatallies` (`Name` VARCHAR (30) Not null default ' default '0', `bytes_out_used` float NOT NULL default '0',` bytes_xfer_used` float NOT NULL default '0', `files_in_used` int (10) unsigned NOT NULL default '0',` files_out_used` int (10) unsigned NOT NULL Default '0', `files_xfer_used` int (10) Unsigned Not Null Default '0') Type = Myisam; # # 导 导 的 数据 的 数据 中` `` `` `````` ',' 2000 ',' 2000 ',' 2000 ', 2000, 2000, 2000); # ---------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------- # Create Table `ftpuser` # Create Table` ftpuser` # Create Table `ftpuser` # Create Table` ftpuser`( 10) Unsigned not null auto_increment, `userid` VARCHAR (32) Not null default ',` passwd` Varchar (32) Not null default', `uid` smallint (6) Not null default '5500',` gid` smallint 6) Not null default '5500', `Homedir` VARCHAR (255) Not null default ',` shell` VARCHAR (16) Not Nu Ll default '/ sbin / nologin', `count` int (11) Not null default '0',` Accessed` DateTime Not Null Default '0000-00-00 00:00:00', `Modified` DateTime Not Null Default` DEFA '0000-00-00 00:00:00', primary key (`ID`)) type = myisam comment = 'proftp user table' auto_increment = 3; # # exported the data in the table` # Insert Into`

FTPUSER` VALUES (1, 'Test', '123456', 5500, 5500, '/ home / test', '/ sbin / nologin', 36, '2004-09-28 13:07:41', '2004- 09-28 13:07:42 '); Quotalimits Table Code: Name: - User Account Quota Type: - User, Group, Class, All (We Use User) Per_Session: - True Or False (We Use true) Limit_Type: - Hard limiting OR soft restrictions (we generally use hard limit) BYTES_IN_AVAIL: - Allow uploaded bytes Bytes_out_avail: - Allow downloaded bytes_xfer_avail: - Allow transmission of bytes (including upload / download) FILES_IN_AVAIL: - Allow upload File file_out_avail: - Allow downloaded files files_xfer_avail: - Allows the number of files (including upload / download) to install, there should be no problem. Honestly use the MySQL and Quota modules to verify the user and set disk limit, but I always feel that it is not perfect, because in this method, there is no field of permissions in the database table, so I say that the authority of the corresponding user is actually used. The user is Mysql corresponding to the UID and GID to control the permissions. If the mysql database can completely control the permissions. ======================================================================================================================================================= ========================= # Set MySQL certification: # 数据 数据 联接 信息 信息, DatabaseName is the database name, Hostname is the host name, #port is port No., username is the username connected to the database, and Password is a password. SqlConnectInfo DatabaseName @ Hostname: Port UserName Password # Type of Database Certification: SQLAUTHTYPES BACKEND PLAINTEXT # Specifies information about the table for user authentication.

( "FTPUSERS" and "FTPGRPS" is the data table name, but later on in the following establishment) SQLUserInfo FTPUSERS userid passwd uid gid homedir shell SQLGroupInfo FTPGRPS groupname gid members # settings allow users to log on if the shell is empty: RequireValidShell off # database Identify SQLAUTHENTICATEERS Groups UserSetFast GroupSetFast # If the Home directory does not exist, the system will create a directory for its Home item: SQLHomedirondemand on # disk limited part quotadirectoryTALLY ON # disk limited unit B "|" KB "|" MB "|" GB "QuotadisplayUnits" KB "QuotaEngine On # disk limited log Record Quotalog" Your Log Path "" opens disk limit information, after logging in to the FTP account, use the command "Quote Site Quota" to display the current user's disk limit Quotashowquotas On # These are the SQL call statement without modification directly copy the past SQLNamedQuery 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} ' "SQLNamedQuery 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}' "SQLNAMED Query 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 sqlnamedquery insert-quota-tally insert"% {0},% { 1},% {2},% {3},% {4},% {5},% {6},% {7} "

转载请注明原文地址:https://www.9cbs.com/read-86136.html

New Post(0)