jix
19/12/2004, 18h11
La suite
quelques explications :
================================================== ================================================== ====================================
Notes:
* The group table lists the members of each group. This does not need any records for a simple setup.
* The user table lists each of your ftp users and records their stats and is used for authentication and pointing proftpd to the correct home directory. Using the directive 'asdfasf' we make proftpd create the home directory if one does not already exist.
* The quotalimits table is used to se the current quota for the user matching its entry.
* The quotatallies table is used by proftpd to keep track of the user's quotas and will be filled if there is a matching userfield 'name' when a user logs in.
* We have added a user test account just called "testaccount" to check things are working ok.
Field Explanations:
quotalimits
name - username
quota_type - user, group, class, all (we use user)
per_session - true or false (we use true)
limit_type - quota limit type - hard or soft (we use hard)
bytes_in_avail - upload limit in bytes - allowed bytes on disk (eg diskquota)
bytes_out_avail - download limit in bytes - allowed bytes a user can download
bytes_xfer_avail - allowed bytes a user can transfer in/out
files_in_avail - upload limit in files - allowed number of uploaded files
files_out_avail - allowed number of downloaded files
files_xfer_avail - allowed number of files a user can transfer in/out
quotatallies
name
quota_type
bytes_in_used - upload tally in bytes
bytes_out_used - download tally in bytes
bytes_xfer_used - transfer tally in bytes
files_in_used - upload tally in files
files_out_used - download tally in files
files_xfer_used - transfer tally in files
If a value of any limit field is set to '0' it is unlimited.
You can read the documentation that comes with mod_quotatab for mysql here.
Author's Note:
You can test a 15MB quota limit on 'testaccount' by inserting this record into 'quotalimits':
INSERT INTO quotalimits VALUES('testaccount','user','true','hard','1572864 0','0','0','0','0','0');
I think you have to log in with this record in place before it works. It also will allow you to upload, but then deletes the file if you are over the limit. This is a bit irritating because on normal user disk quotas, you get a message as you try to upload, not after. So you might get some unhappy users who don't know why they can't upload. Also the message that you have exceeded the limit appears in the ftp client transcript and your users will miss this if they don't show transcripts.
On a related note, I can seem to get any joy out of the quotatallies stuff. When I get more time, I may investigate this. In the meantime, if any of you find out what is going on there, it would be cool if you leave a note in the forum here - then everyone can benefit.
================================================== ================================================== ====================================
Aller dans /etc/init.d/
# cd /etc/init.d/
Créer le fichier proftpd
# vi proftpd
copier coller ça :
================================================== ================================================== ====================================
#!/bin/sh
#
# Startup script for ProFTPd
#
# chkconfig: 345 85 15
# description: ProFTPD is an enhanced FTP server with \
# a focus toward simplicity, security, and ease of configuration. \
# It features a very Apache-like configuration syntax, \
# and a highly customizable server infrastructure, \
# including support for multiple 'virtual' FTP servers, \
# anonymous FTP, and permission-based directory visibility.
# processname: proftpd
# config: /etc/proftpd.conf
#
# By: Osman Elliyasa
# $Id: proftpd.init.d,v 1.2 2001/01/26 23:10:55 flood Exp $
# modified by vdanen@mandrakesoft.com
# Source function library.
. /etc/rc.d/init.d/functions
# Get config.
. /etc/sysconfig/network
# Check that networking is up.
if [ ${NETWORKING} = "no" ]
then
exit 0
fi
[ -x /usr/sbin/proftpd ] || exit 0
FTPSHUT=/usr/sbin/ftpshut
RETVAL=0
# See how we were called.
case "$1" in
start)
printf "Starting proftpd: "
daemon proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/proftpd
;;
stop)
printf "Shutting down proftpd: "
killproc proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/proftpd
;;
status)
status proftpd
RETVAL=$?
;;
restart)
$0 stop
$0 start
RETVAL=$?
;;
reload)
printf "Re-reading proftpd config: "
killproc proftpd -HUP
RETVAL=$?
echo
;;
suspend)
if [ -f $FTPSHUT ]; then
if [ $# -gt 1 ]; then
shift
printf "Suspending proftpd with '$*' "
$FTPSHUT $*
else
printf "Suspending proftpd NOW "
$FTPSHUT now "Maintanance in progress"
fi
else
printf "No way to suspend, shutting down instead "
fi
killproc proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/proftpd
;;
resume)
if [ -f /etc/shutmsg ]; then
printf "Allowing proftpd sessions again "
rm -f /etc/shutmsg
else
printf "Starting proftpd; was not suspended "
fi
daemon proftpd
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/proftpd
;;
*)
printf "Usage: %s {start|stop|status|restart|reload|resume" "$0"
if [ "$FTPSHUT" = "" ]; then
printf "}\n"
else
printf "|suspend}\n"
printf "suspend accepts additional arguments which are passed to ftpshut(8)\n"
fi
exit 1
esac
if [ $# -gt 1 ]; then
shift
$0 $*
fi
exit $RETVAL
================================================== ================================================== ====================================
ensuite rendre proftpd exécutable :
# chmod +x proftpd
Ajouter un user dans PHPMyadmin :
INSERT INTO `ftpuser` VALUES (1, 'login', 'passwd', 517, 100, '/chemin vers le rep', '/sbin/nologin',0,'','');
(avec 517 pour l'uid et 100 pour le gid par exemple)
Aller dans phpmyadmin dans la base ftpdb
Puis dans ftpuser
J’ai rajouté un user dans sql :
INSERT INTO `ftpuser` VALUES (1, 'tutu', 'tralala', 517, 100, '/chemin vers le rep', '/sbin/nologin',0,'','');
Par contre j’incrémente à la main le premier chiffre (ici 1), ça doit pouvoir se faire en auto je suppose ?
Ça crée donc l’user tutu pour proftpd avec le mot de passe tralala, j’ai mis 517 et 100 qui sont l’uid / gid de l’user du répertoire,
étant donné que le chemin est "/chemin vers le rep" et qu’il appartient à l’user, ça permets d’avoir les bons droits pour modif, créer, etc
Pour savoir quel est l’uid/gid d’un user (ex tutu), suffit de faire un
# less /etc/passwd
De chercher l’user tutu :
tutu:x:514:100:tutu:/home/tutu:/bin/false
l’uid est donc 514 et son gid est 100
(merci à Géraud \o/)
quelques explications :
================================================== ================================================== ====================================
Notes:
* The group table lists the members of each group. This does not need any records for a simple setup.
* The user table lists each of your ftp users and records their stats and is used for authentication and pointing proftpd to the correct home directory. Using the directive 'asdfasf' we make proftpd create the home directory if one does not already exist.
* The quotalimits table is used to se the current quota for the user matching its entry.
* The quotatallies table is used by proftpd to keep track of the user's quotas and will be filled if there is a matching userfield 'name' when a user logs in.
* We have added a user test account just called "testaccount" to check things are working ok.
Field Explanations:
quotalimits
name - username
quota_type - user, group, class, all (we use user)
per_session - true or false (we use true)
limit_type - quota limit type - hard or soft (we use hard)
bytes_in_avail - upload limit in bytes - allowed bytes on disk (eg diskquota)
bytes_out_avail - download limit in bytes - allowed bytes a user can download
bytes_xfer_avail - allowed bytes a user can transfer in/out
files_in_avail - upload limit in files - allowed number of uploaded files
files_out_avail - allowed number of downloaded files
files_xfer_avail - allowed number of files a user can transfer in/out
quotatallies
name
quota_type
bytes_in_used - upload tally in bytes
bytes_out_used - download tally in bytes
bytes_xfer_used - transfer tally in bytes
files_in_used - upload tally in files
files_out_used - download tally in files
files_xfer_used - transfer tally in files
If a value of any limit field is set to '0' it is unlimited.
You can read the documentation that comes with mod_quotatab for mysql here.
Author's Note:
You can test a 15MB quota limit on 'testaccount' by inserting this record into 'quotalimits':
INSERT INTO quotalimits VALUES('testaccount','user','true','hard','1572864 0','0','0','0','0','0');
I think you have to log in with this record in place before it works. It also will allow you to upload, but then deletes the file if you are over the limit. This is a bit irritating because on normal user disk quotas, you get a message as you try to upload, not after. So you might get some unhappy users who don't know why they can't upload. Also the message that you have exceeded the limit appears in the ftp client transcript and your users will miss this if they don't show transcripts.
On a related note, I can seem to get any joy out of the quotatallies stuff. When I get more time, I may investigate this. In the meantime, if any of you find out what is going on there, it would be cool if you leave a note in the forum here - then everyone can benefit.
================================================== ================================================== ====================================
Aller dans /etc/init.d/
# cd /etc/init.d/
Créer le fichier proftpd
# vi proftpd
copier coller ça :
================================================== ================================================== ====================================
#!/bin/sh
#
# Startup script for ProFTPd
#
# chkconfig: 345 85 15
# description: ProFTPD is an enhanced FTP server with \
# a focus toward simplicity, security, and ease of configuration. \
# It features a very Apache-like configuration syntax, \
# and a highly customizable server infrastructure, \
# including support for multiple 'virtual' FTP servers, \
# anonymous FTP, and permission-based directory visibility.
# processname: proftpd
# config: /etc/proftpd.conf
#
# By: Osman Elliyasa
# $Id: proftpd.init.d,v 1.2 2001/01/26 23:10:55 flood Exp $
# modified by vdanen@mandrakesoft.com
# Source function library.
. /etc/rc.d/init.d/functions
# Get config.
. /etc/sysconfig/network
# Check that networking is up.
if [ ${NETWORKING} = "no" ]
then
exit 0
fi
[ -x /usr/sbin/proftpd ] || exit 0
FTPSHUT=/usr/sbin/ftpshut
RETVAL=0
# See how we were called.
case "$1" in
start)
printf "Starting proftpd: "
daemon proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/proftpd
;;
stop)
printf "Shutting down proftpd: "
killproc proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/proftpd
;;
status)
status proftpd
RETVAL=$?
;;
restart)
$0 stop
$0 start
RETVAL=$?
;;
reload)
printf "Re-reading proftpd config: "
killproc proftpd -HUP
RETVAL=$?
echo
;;
suspend)
if [ -f $FTPSHUT ]; then
if [ $# -gt 1 ]; then
shift
printf "Suspending proftpd with '$*' "
$FTPSHUT $*
else
printf "Suspending proftpd NOW "
$FTPSHUT now "Maintanance in progress"
fi
else
printf "No way to suspend, shutting down instead "
fi
killproc proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/proftpd
;;
resume)
if [ -f /etc/shutmsg ]; then
printf "Allowing proftpd sessions again "
rm -f /etc/shutmsg
else
printf "Starting proftpd; was not suspended "
fi
daemon proftpd
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/proftpd
;;
*)
printf "Usage: %s {start|stop|status|restart|reload|resume" "$0"
if [ "$FTPSHUT" = "" ]; then
printf "}\n"
else
printf "|suspend}\n"
printf "suspend accepts additional arguments which are passed to ftpshut(8)\n"
fi
exit 1
esac
if [ $# -gt 1 ]; then
shift
$0 $*
fi
exit $RETVAL
================================================== ================================================== ====================================
ensuite rendre proftpd exécutable :
# chmod +x proftpd
Ajouter un user dans PHPMyadmin :
INSERT INTO `ftpuser` VALUES (1, 'login', 'passwd', 517, 100, '/chemin vers le rep', '/sbin/nologin',0,'','');
(avec 517 pour l'uid et 100 pour le gid par exemple)
Aller dans phpmyadmin dans la base ftpdb
Puis dans ftpuser
J’ai rajouté un user dans sql :
INSERT INTO `ftpuser` VALUES (1, 'tutu', 'tralala', 517, 100, '/chemin vers le rep', '/sbin/nologin',0,'','');
Par contre j’incrémente à la main le premier chiffre (ici 1), ça doit pouvoir se faire en auto je suppose ?
Ça crée donc l’user tutu pour proftpd avec le mot de passe tralala, j’ai mis 517 et 100 qui sont l’uid / gid de l’user du répertoire,
étant donné que le chemin est "/chemin vers le rep" et qu’il appartient à l’user, ça permets d’avoir les bons droits pour modif, créer, etc
Pour savoir quel est l’uid/gid d’un user (ex tutu), suffit de faire un
# less /etc/passwd
De chercher l’user tutu :
tutu:x:514:100:tutu:/home/tutu:/bin/false
l’uid est donc 514 et son gid est 100
(merci à Géraud \o/)