CREATE TABLE users( username varchar(20) NOT NULL primary key, passwd varchar(80) NOT NULL, uid integer NOT NULL, gid integer NOT NULL, homedir varchar(255) NOT NULL default '', shell varchar(255) NOT NULL default '/bin/false', count integer NOT NULL default '0', host varchar(30) NOT NULL, accessed timestamp NOT NULL default now(), modified timestamp NOT NULL default now() )
INSERT INTO users(username,passwd,uid,gid,homedir,host) VALUES ('feifan', 'hades', 1000, 1000, '/export/home/feifan', 'chen'); INSERT INTO users(username,passwd,uid,gid,homedir,host) VALUES ('mdc', 'down', 1001, 1000, '/export/home/mdcshare', 'chen');
注:數據中的UID和GID分別表示映射為系統中的用戶ID和組ID.
二.安裝proftpd 1.編譯安裝proftpd 我這裡有的sun cc,你也可以使用gcc
CC=cc;export CC ./configure --prefix=/usr/local/proftpd \ --with-modules=mod_sql:mod_sql_postgres \ --with-includes=/export/home/postgres/pgsql/include \ --with-libraries=/export/home/postgres/pgsql/lib make make install
2.把postgres的lib文件加入系統變數
#crle -u -l /export/home/postgres/pgsql/lib
3.配製proftpd bash-3.00# more proftpd.conf
# This is a basic ProFTPD configuration file (rename it to # 'proftpd.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 "MDC FTP server" ServerType standalone DefaultServer on
# 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 nogroup
# To cause every FTP user to be "jailed" (chrooted) into their home # directory, uncomment this line. DefaultRoot ~
# Normally, we want files to be overwriteable. AllowOverwrite on
# Sets how many password attempts are allowed before disconnection MaxLoginAttempts 5
# Users needs a valid shell # RequireValidShell off
# Performance: skip DNS resolution when we process the logs... UseReverseDNS off
# Restart session support # AllowStoreRestart on AllowRetrieveRestart on
# Client config MaxClientsPerHost 3 "Sorry, the maximum number clients (%m) from your host are already connected." MaxClientsPerUser 5 "Sorry, the maximum number of clients (%m) for this user already connected."
# Bar use of SITE CHMOD by default <Limit SITE_CHMOD> DenyAll </Limit>
#Logfile Systemlog /var/log/proftpd.log TransferLog /var/log/proftpd.xferlog # Record all logins ExtendedLog /var/log/proftpd.auth_log AUTH ExtendedLog /var/log/proftpd.log ALL
# A basic anonymous configuration, no upload directories. If you do not # want anonymous users, simply delete this entire <Anonymous> section. #<Anonymous ~mdcftp> # User mdcftp # Group staff # # # We want clients to be able to login with "anonymous" as well as "ftp" # UserAlias anonymous mdcftp # # # Limit 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 # DisplayChdir .message # # # Limit WRITE everywhere in the anonymous chroot # <Limit WRITE> # DenyAll # </Limit> #</Anonymous>
# databasename@host database_user user_password SQLConnectInfo ftp@localhost ftp mdcftp SQLUserInfo users username passwd uid gid homedir shell host SQLGroupInfo groups groupname gid members #SQLHomedirOnDemand如果用戶主目錄不存在,則系統會根據此用戶在用戶數據表中的homedir欄位的值新建一個目錄 CreateHome on SQLNegativeCache on SQLLogFile /var/log/proftpd.sql.log
# Update count every time user logs in SQLLog PASS updatecount SQLNamedQuery updatecount UPDATE "count=count+1,accessed=now() WHERE username='%u'" users # Update modified everytime user uploads or deletes a file SQLLog STOR,DELE modified SQLNamedQuery modified UPDATE "modified=now() WHERE username='%u'" users
SQLNamedQuery getcount SELECT "count from users where username='%u'"
4.把proftpd加入SMF vi /var/svc/manifest/network/proftpd.xml
<?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> <!-- ident "@(#)proftpd.xml 1.3.3d 11/02/15 SMI" By Feifan@CU -->
<!-- Because we may have multiple instances of network/proftpd provided by different implementations, we keep dependencies and methods within the instance. -->
<instance name='default' enabled='false'> <!-- Wait for network interfaces to be initialized. --> <dependency name='network' grouping='require_all' restart_on='error' type='service'> <service_fmri value='svc:/milestone/network:default' /> </dependency>
<!-- Wait for all local filesystems to be mounted. --> <dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/system/filesystem/local:default' /> </dependency>
<!-- Wait for automounting to be available, as we may be serving data from home directories or other remote filesystems. --> <dependency name='autofs' grouping='optional_all' restart_on='error' type='service'> <service_fmri value='svc:/system/filesystem/autofs:default' /> </dependency>