#============================================================================# # vHost - one-step solution for all virtual hosting needs # # V15wu-ftpd - wu-ftpd virtualization module # # # # Copyright(c) Chaogic Systems, LLC. http://chaogic.com # # Author: Jake Fan # # # # This is Free Software; permission to use, copy, modify, and distribute # # this software and its documentation for any purpose - with or without fee # # - is hereby granted, provided that the above copyright information and # # this permission notice appear in all copies and documentations. This # # software is provided "as is" without express or implied warranty. For # # more details, see GNU General Public License as published by the Free # # Software Foundation. # # # #============================================================================# $X eq "configuration" && do { ################################################ ### EDITABLE CONFIGURATIONS ################################################## ### ftp directory name on virtual hosts. home directory for anonymous ftp. # will be created under "var/". # $ftpDir = "ftp"; $ftpDir = "ftp"; ### the user which wu-ftpd runs as. # $ftpUser = "ftp"; $ftpUser = "ftp"; ### wu-ftpd configuration file. # $wu_ftpdCf = "/etc/ftpaccess"; $wu_ftpdCf = "/etc/ftpaccess"; ### wu-ftpd reload command sequence. separate multiple commands with shell # meta characters such as "|", ";", "||", "&&", etc. leave blank if invoked # by inetd. # $wu_ftpdRc = ""; $wu_ftpdRc = ""; ### $wu_ftpdCf virtual host configuration. vhost will replace "[HOST_NAME]", # "[OWNER_NAME]", and "[IP_ADDRESS]" with actual values. variables found # in "./V00hostconf" will also be expanded. # $wu_ftpdC = <<"---eoc---eoc---eoc---"; $wu_ftpdC = <<"---eoc---eoc---eoc---"; virtual [HOST_NAME] allow * virtual [HOST_NAME] root $VHOME/[HOST_NAME]/var/$ftpDir virtual [HOST_NAME] logfile $VHOME/[HOST_NAME]/var/log/xferlog virtual [HOST_NAME] passwd /etc/vdata/passwd.[HOST_NAME] virtual [HOST_NAME] shadow /etc/vdata/shadow.[HOST_NAME] ---eoc---eoc---eoc--- ### DO NOT TOUCH ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!! ### SanityChecking ########################################################### $ERR = 1, Error "$MOD: \$ftpDir = '$ftpDir'" if !CheckN $ftpDir; $ERR = 1, Error "$MOD: \$ftpUser = '$ftpUser'" if !getpwnam $ftpUser; $ERR = 1, Error "$MOD: \$wu_ftpdCf = '$wu_ftpdCf'" if !-f $wu_ftpdCf; $ERR = 1, Error "$MOD: \$wu_ftpdRc = '$wu_ftpdRc'" if $wu_ftpdRc && ($wu_ftpdRc !~ /^\// || !-x (split /[\s|&;]+/, $wu_ftpdRc)[0]); }; $X eq "initialization" && do { ############################################### if ($ONCFG) { `chown 0:$GHID $wu_ftpdCf $NERR` if !-o $wu_ftpdCf; `chmod 0600 $wu_ftpdCf $NERR` if ((stat $wu_ftpdCf)[2] & 07777) != 0600; #`cp -Rp $ftpRoot/bin $VHOME $NERR` if !-e "$VHOME/bin"; #`cp -Rp $ftpRoot/etc $VHOME $NERR` if !-e "$VHOME/etc"; #`cp -Rp $ftpRoot/lib $VHOME $NERR` if !-e "$VHOME/lib"; #GroupAdd $ftpUser; GroupAdd "ftp"; my $cmd = "(chmod|delete|overwrite|rename|umask)"; Flock $wu_ftpdCf, "+<", 0 if !grep /^\s*$FOOT/, Cat $wu_ftpdCf; BackupCf $wu_ftpdCf; s/^(\s*$cmd\s+no\s+.*)\bguest\b,*/$1/i for @FILE; print FILE @FILE; print FILE "\n$FOOT\n"; print FILE "guestgroup vuser\n" if !grep /^\s*guestgroup\s+vuser\s*$/i, @FILE; print FILE "class vuser guest *\n" if !grep /^\s*class\s+vuser\s+guest\s+\*\s*$/i, @FILE; print FILE "log transfers guest inbound,outbound\n" if !grep /^\s*log\s+transfers\s+guest\s+inbound,outbound\s*$/i, @FILE; Flock 0; } Error5 "'$U' is a system user" if $ARGV[0] eq "deluser" && $U eq $ftpDir && $VPWD{$U}; }; $X eq "addhost" && do { ###################################################### `touch $VHOME/$H/var/log/xferlog $NERR`; #`cp -Rp $ftpRoot/bin $VHOME/$H $NERR`; #`cp -Rp $ftpRoot/etc $VHOME/$H $NERR`; #`cp -Rp $ftpRoot/lib $VHOME/$H $NERR`; `mkdir $VHOME/$H/var/$ftpDir $NERR`; `mkdir $VHOME/$H/var/$ftpDir/pub $NERR`; #`cp -Rp $ftpRoot/bin $VHOME/$H/var/$ftpDir $NERR`; #`cp -Rp $ftpRoot/etc $VHOME/$H/var/$ftpDir $NERR`; #`cp -Rp $ftpRoot/lib $VHOME/$H/var/$ftpDir $NERR`; `cp -Rp $VHOME/$H/home/$ftpDir/. $VHOME/$H/var/$ftpDir $NERR`; `rm -r $VHOME/$H/home/$ftpDir $NERR`; `ln -s ../var/$ftpDir $VHOME/$H/home/$ftpDir $NERR`; AddConf $wu_ftpdCf, $wu_ftpdC; ReloadRc 0; }; $X eq "delhost" && do { ###################################################### DelConf $wu_ftpdCf, $wu_ftpdC if $_d; ReloadRc 0 if $_d; }; $X eq "adduser" && do { ###################################################### #`cp -Rp $ftpRoot/bin $VHOME/$H/home/$U $NERR` if !$LOH; #`cp -Rp $ftpRoot/etc $VHOME/$H/home/$U $NERR` if !$LOH; #`cp -Rp $ftpRoot/lib $VHOME/$H/home/$U $NERR` if !$LOH; }; $X eq "reload" && do { ####################################################### ReloadRc 0 if $_f && $USER eq "root"; ReloadRc $wu_ftpdRc; }; $X eq "finalization" && do { ################################################# if ($ARGV[0] eq "addhost" || $ARGV[0] eq "adduser" && $U eq $ftpDir) { `chown -h $O[2]:$GUID $VHOME/$H/home/$ftpDir $NERR`; } ReloadRc $wu_ftpdRc if !$_q && $ARGV[0] =~ /^(addhost|delhost)$/; }; 1;