Installare un server FTP con utenti virtuali su MySQL: differenze tra le versioni

Vai alla navigazione Vai alla ricerca
Riga 117: Riga 117:
Apriamo il file
Apriamo il file
<pre>
<pre>
vi /etc/proftpd/proftpd.conf
# vi /etc/proftpd/proftpd.conf
</pre>
</pre>
e decommentiamo la linea <code>Include /etc/proftpd/sql.conf</code>:
e decommentiamo la linea <code>Include /etc/proftpd/sql.conf</code>:
Riga 132: Riga 132:
Include /etc/proftpd/sql.conf
Include /etc/proftpd/sql.conf
[...]
[...]
</pre>
=== /etc/proftpd/sql.conf ===
Di questo file, in particolare, notiamo la riga <code>SQLConnectInfo</code> (in cui vanno inseriti i parametri di connessione al database)che, se utilizziamo un database MySQL configurato come descritto in precedenza, va scritta così:
<pre>
SQLConnectInfo proftpd@localhost proftpd password
</pre>
Apriamo quindi il file:
<pre>
# vi /etc/proftpd/sql.conf
</pre>
e modifichiamolo come segue:
<pre>
#
# Proftpd sample configuration for SQL-based authentication.
#
# (This is not to be used if you prefer a PAM-based SQL authentication)
#
<IfModule mod_sql.c>
#
# Choose a SQL backend among MySQL or PostgreSQL.
# Both modules are loaded in default configuration, so you have to specify the backend
# or comment out the unused module in /etc/proftpd/modules.conf.
# Use 'mysql' or 'postgres' as possible values.
#
#SQLBackend        mysql
#
#SQLEngine on
#SQLAuthenticate on
#
# Use both a crypted or plaintext password
#SQLAuthTypes Crypt Plaintext
#
# Use a backend-crypted or a crypted password
#SQLAuthTypes Backend Crypt
#
# Connection
#SQLConnectInfo proftpd@sql.example.com proftpd_user proftpd_password
#
# Describes both users/groups tables
#
#SQLUserInfo users userid passwd uid gid homedir shell
#SQLGroupInfo groups groupname gid members
#
DefaultRoot ~
SQLBackend              mysql
# The passwords in MySQL are encrypted using CRYPT
SQLAuthTypes            Plaintext Crypt
SQLAuthenticate        users groups
# used to connect to the database
# databasename@host database_user user_password
#SQLConnectInfo  ftp@localhost proftpd password
SQLConnectInfo proftpd@localhost proftpd password
# Here we tell ProFTPd the names of the database columns in the "usertable"
# we want it to interact with. Match the names with those in the db
SQLUserInfo    ftpuser userid passwd uid gid homedir shell
# Here we tell ProFTPd the names of the database columns in the "grouptable"
# we want it to interact with. Again the names match with those in the db
SQLGroupInfo    ftpgroup groupname gid members
# set min UID and GID - otherwise these are 999 each
SQLMinID        500
# create a user's home directory on demand if it doesn't exist
CreateHome on
# Update count every time user logs in
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHERE userid='%u'" ftpuser
# Update modified everytime user uploads or deletes a file
SQLLog  STOR,DELE modified
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser
# User quotas
# ===========
QuotaEngine on
QuotaDirectoryTally on
QuotaDisplayUnits Mb
QuotaShowQuotas on
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 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-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
RootLogin off
RequireValidShell off
</IfModule>
</pre>
</pre>

Menu di navigazione