• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/tcl-105/tcl_ext/tcllib/tcllib/modules/ftpd/

Lines Matching defs:ftpd

0 # ftpd.tcl --
12 # RCS: @(#) $Id: ftpd.tcl,v 1.30 2010/01/20 18:22:42 andreas_kupries Exp $
15 # Define the ftpd package version 1.2.5
18 namespace eval ::ftpd {
47 authUsrCmd {::ftpd::anonAuth} \
48 authFileCmd {::ftpd::fileAuth} \
49 logCmd {::ftpd::logStderr} \
50 fsCmd {::ftpd::fsFile::fs} \
114 # ::ftpd::config --
124 # login. Defaults to ::ftpd::anonAuth
128 # ::ftpd::userAuth
131 # ::ftpd::logStderr
134 # Default is ::ftpd::fsFile::fs
142 proc ::ftpd::config {args} {
166 # ::ftpd::hasCallback --
181 proc ::ftpd::hasCallback {callbackType} {
189 # ::ftpd::logStderr --
205 proc ::ftpd::logStderr {severity text} {
215 # ::ftpd::Log --
217 # Used for all ftpd logging.
228 # The ftpd logCmd callback is called with the specified severity and
231 proc ::ftpd::Log {severity text} {
247 # ::ftpd::fileAuth --
254 # connect to the ftpd.
265 proc ::ftpd::fileAuth {user path operation} {
286 # ::ftpd::anonAuth --
289 # attempted login. This is the default ftpd authUsrCmd callback. By
296 # connect to the ftpd.
298 # connect to the ftpd.
306 proc ::ftpd::anonAuth {user pass} {
330 # ::ftpd::unixAuth --
333 # attempted login. This is an alternative to the default ftpd
340 # connect to the ftpd.
342 # connect to the ftpd.
350 proc ::ftpd::unixAuth {user pass} {
381 ::ftpd::Log debug $passwords
410 # ::ftpd::server --
418 # attempting to connect to the ftpd.
425 # ::ftpd::accept when it is connected to.
427 proc ::ftpd::server {{myaddr {}}} {
430 set f [socket -server ::ftpd::accept -myaddr $myaddr $port]
432 set f [socket -server ::ftpd::accept $port]
438 # ::ftpd::accept --
442 # printed out, and a ftpd::Read filevent is placed on the socket.
445 # sock - The channel for this connection to the ftpd.
453 # Sets up a ftpd::Read fileevent to trigger whenever the channel is
457 proc ::ftpd::accept {sock ipaddr client_port} {
458 upvar #0 ::ftpd::$sock data
508 fileevent $sock readable [list ::ftpd::Read $sock]
515 # ::ftpd::Read --
519 # ftpd::command::* where '*' is the all upper case name of the command,
524 # sock - The channel for this connection to the ftpd.
533 proc ::ftpd::Read {sock} {
534 upvar #0 ::ftpd::$sock data
554 auto_load ::ftpd::command::$cmd
566 } elseif {[info command ::ftpd::command::$cmd] != ""} {
568 ::ftpd::command::$cmd $sock $argument
582 # ::ftpd::Finish --
584 # Closes the socket connection between the ftpd and client.
587 # sock - The channel for this connection to the ftpd.
595 proc ::ftpd::Finish {sock} {
596 upvar #0 ::ftpd::$sock data
612 # ::ftpd::FinishData --
618 # sock - The channel for this connection to the ftpd.
626 proc ::ftpd::FinishData {sock} {
627 upvar #0 ::ftpd::$sock data
633 # ::ftpd::Fs --
637 # ::ftpd::Fs command will call out to the fsCmd callback with the
681 # callback configured for the ftpd.
683 proc ::ftpd::Fs {command path args} {
699 namespace eval ::ftpd::command {
703 # ::ftpd::command::ABOR --
709 # sock - The channel for this connection to the ftpd.
719 proc ::ftpd::command::ABOR {sock list} {
721 ::ftpd::FinishData $sock
727 # ::ftpd::command::APPE --
730 # specified from ::ftpd::Fs and copies the data from data(sock2) to
735 # sock - The channel for this connection to the ftpd.
745 proc ::ftpd::command::APPE {sock filename} {
746 upvar #0 ::ftpd::$sock data
749 if {[::ftpd::hasCallback authFileCmd]} {
750 set cmd $::ftpd::cfg(authFileCmd)
761 if {![catch {::ftpd::Fs append $path $data(mode)} f]} {
763 fcopy $data(sock2) $f -command [list ::ftpd::GetDone $sock $data(sock2) $f ""]
766 ::ftpd::FinishData $sock
771 # ::ftpd::command::CDUP --
777 # sock - The channel for this connection to the ftpd.
786 proc ::ftpd::command::CDUP {sock list} {
787 upvar #0 ::ftpd::$sock data
794 # ::ftpd::command::CWD --
799 # sock - The channel for this connection to the ftpd.
808 proc ::ftpd::command::CWD {sock relativepath} {
809 upvar #0 ::ftpd::$sock data
827 # ::ftpd::command::DELE --
832 # sock - The channel for this connection to the ftpd.
841 proc ::ftpd::command::DELE {sock filename} {
842 upvar #0 ::ftpd::$sock data
845 if {[::ftpd::hasCallback authFileCmd]} {
846 set cmd $::ftpd::cfg(authFileCmd)
854 if {[catch {::ftpd::Fs delete $path $sock} msg]} {
860 # ::ftpd::command::HELP --
866 # sock - The channel for this connection to the ftpd.
875 proc ::ftpd::command::HELP {sock command} {
876 upvar #0 ::ftpd::$sock data
880 if {![info exists ::ftpd::commands($command)]} {
882 } elseif {[info commands ::ftpd::command::$command] == ""} {
883 puts $sock "214 $command\t$::ftpd::commands($command)"
885 puts $sock "214 Syntax: $::ftpd::commands($command)"
888 set commandList [lsort [array names ::ftpd::commands]]
892 if {[info commands ::ftpd::command::$commandName] == ""} {
906 puts $sock "214 Direct comments to $::ftpd::contact."
912 # ::ftpd::command::LIST --
918 # sock - The channel for this connection to the ftpd.
927 proc ::ftpd::command::LIST {sock filename} {
928 ::ftpd::List $sock $filename list
932 # ::ftpd::command::MDTM --
938 # sock - The channel for this connection to the ftpd.
947 proc ::ftpd::command::MDTM {sock filename} {
948 upvar #0 ::ftpd::$sock data
951 if {[catch {::ftpd::Fs mtime $path $sock} msg]} {
953 ::ftpd::FinishData $sock
958 # ::ftpd::command::MKD --
963 # sock - The channel for this connection to the ftpd.
972 proc ::ftpd::command::MKD {sock filename} {
973 upvar #0 ::ftpd::$sock data
977 if {[::ftpd::hasCallback authFileCmd]} {
978 set cmd $::ftpd::cfg(authFileCmd)
986 if {[catch {::ftpd::Fs mkdir $path $sock} f]} {
992 # ::ftpd::command::NOOP --
997 # sock - The channel for this connection to the ftpd.
1006 proc ::ftpd::command::NOOP {sock list} {
1012 # ::ftpd::command::NLST --
1018 # sock - The channel for this connection to the ftpd.
1027 proc ::ftpd::command::NLST {sock filename} {
1028 ::ftpd::List $sock $filename nlst
1032 # ::ftpd::command::PASS --
1037 # not ::ftpd::Log is used to log and error, and an "Access Denied"
1041 # sock - The channel for this connection to the ftpd.
1051 proc ::ftpd::command::PASS {sock password} {
1052 upvar #0 ::ftpd::$sock data
1060 ::ftpd::Log debug "pass <$data(pass)>"
1062 if {![::ftpd::hasCallback authUsrCmd]} {
1070 set cmd $::ftpd::cfg(authUsrCmd)
1076 ::ftpd::Log error "AuthUsr error: $res"
1079 ::ftpd::Log note "AuthUsr: Access denied to <$data(user)> <$data(pass)>."
1090 # ::ftpd::command::PORT --
1096 # sock - The channel for this connection to the ftpd.
1105 proc ::ftpd::command::PORT {sock numbers} {
1106 upvar #0 ::ftpd::$sock data
1109 ::ftpd::FinishData $sock
1118 # ::ftpd::command::PWD --
1124 # sock - The channel for this connection to the ftpd.
1133 proc ::ftpd::command::PWD {sock list} {
1134 upvar #0 ::ftpd::$sock data
1135 ::ftpd::Log debug $data(cwd)
1140 # ::ftpd::command::QUIT --
1145 # sock - The channel for this connection to the ftpd.
1154 proc ::ftpd::command::QUIT {sock list} {
1155 ::ftpd::Log note "Closed $sock"
1157 ::ftpd::Finish $sock
1159 #unset ::ftpd::$sock
1163 # ::ftpd::command::REIN --
1171 # sock - The channel for this connection to the ftpd.
1181 proc ::ftpd::command::REIN {sock list} {
1182 upvar #0 ::ftpd::$sock data
1184 ::ftpd::FinishData $sock
1193 cwd "$::ftpd::cwd" \
1201 # ::ftpd::command::RETR --
1204 # specified from ::ftpd::Fs and copies the file to second socket
1208 # sock - The channel for this connection to the ftpd.
1218 proc ::ftpd::command::RETR {sock filename} {
1219 upvar #0 ::ftpd::$sock data
1223 if {[::ftpd::hasCallback authFileCmd]} {
1224 set cmd $::ftpd::cfg(authFileCmd)
1235 if {![catch {::ftpd::Fs retr $path $data(mode)} f]} {
1237 fcopy $f $data(sock2) -command [list ::ftpd::GetDone $sock $data(sock2) $f ""]
1240 ::ftpd::FinishData $sock
1245 # ::ftpd::command::RMD --
1250 # sock - The channel for this connection to the ftpd.
1259 proc ::ftpd::command::RMD {sock filename} {
1260 upvar #0 ::ftpd::$sock data
1264 if {[::ftpd::hasCallback authFileCmd]} {
1265 set cmd $::ftpd::cfg(authFileCmd)
1272 if {[catch {::ftpd::Fs rmdir $path $sock} f]} {
1278 # ::ftpd::command::RNFR --
1284 # sock - The channel for this connection to the ftpd.
1294 proc ::ftpd::command::RNFR {sock filename} {
1295 upvar #0 ::ftpd::$sock data
1300 if {[::ftpd::hasCallback authFileCmd]} {
1301 set cmd $::ftpd::cfg(authFileCmd)
1317 # ::ftpd::command::RNTO --
1323 # sock - The channel for this connection to the ftpd.
1332 proc ::ftpd::command::RNTO {sock filename} {
1333 upvar #0 ::ftpd::$sock data
1346 if {[::ftpd::hasCallback authFileCmd]} {
1347 set cmd $::ftpd::cfg(authFileCmd)
1356 if {![catch {::ftpd::Fs rename $data(renameFrom) $path} msg]} {
1365 # ::ftpd::command::SIZE --
1371 # sock - The channel for this connection to the ftpd.
1380 proc ::ftpd::command::SIZE {sock filename} {
1381 upvar #0 ::ftpd::$sock data
1384 if {[catch {::ftpd::Fs size $path $sock} msg]} {
1386 ::ftpd::FinishData $sock
1391 # ::ftpd::command::STOR --
1394 # specified from ::ftpd::Fs and copies the data from data(sock2) to
1398 # sock - The channel for this connection to the ftpd.
1408 proc ::ftpd::command::STOR {sock filename} {
1409 upvar #0 ::ftpd::$sock data
1412 if {[::ftpd::hasCallback authFileCmd]} {
1413 set cmd $::ftpd::cfg(authFileCmd)
1424 if {![catch {::ftpd::Fs store $path $data(mode)} f]} {
1426 fcopy $data(sock2) $f -command [list ::ftpd::GetDone $sock $data(sock2) $f ""]
1429 ::ftpd::FinishData $sock
1434 # ::ftpd::command::STOU --
1437 # specified from ::ftpd::Fs and copies the data from data(sock2) to
1441 # sock - The channel for this connection to the ftpd.
1451 proc ::ftpd::command::STOU {sock filename} {
1452 upvar #0 ::ftpd::$sock data
1455 if {[::ftpd::hasCallback authFileCmd]} {
1456 set cmd $::ftpd::cfg(authFileCmd)
1466 while {[::ftpd::Fs exists $file]} {
1474 if {![catch {::ftpd::Fs store $file $data(mode)} f]} {
1476 fcopy $data(sock2) $f -command [list ::ftpd::GetDone $sock $data(sock2) $f $file]
1479 ::ftpd::FinishData $sock
1484 # ::ftpd::command::SYST --
1489 # sock - The channel for this connection to the ftpd.
1498 proc ::ftpd::command::SYST {sock list} {
1499 upvar #0 ::ftpd::$sock data
1518 # ::ftpd::command::TYPE --
1524 # sock - The channel for this connection to the ftpd.
1534 proc ::ftpd::command::TYPE {sock type} {
1535 upvar #0 ::ftpd::$sock data
1550 # ::ftpd::command::USER --
1556 # sock - The channel for this connection to the ftpd.
1565 proc ::ftpd::command::USER {sock username} {
1566 upvar #0 ::ftpd::$sock data
1575 ::ftpd::Log debug "user <$data(user)>"
1579 # ::ftpd::GetDone --
1585 # sock - The channel for this connection to the ftpd.
1601 proc ::ftpd::GetDone {sock sock2 f filename bytes {err {}}} {
1602 upvar #0 ::ftpd::$sock data
1622 # ::ftpd::List --
1628 # sock - The channel for this connection to the ftpd.
1638 proc ::ftpd::List {sock filename style} {
1639 upvar #0 ::ftpd::$sock data
1653 # ftpd.
1655 namespace eval ::ftpd::fsFile {
1666 # ::ftpd::fsFile::docRoot --
1668 # Set or query the root of the ftpd file system. If no 'dir' argument
1685 proc ::ftpd::fsFile::docRoot {{dir {}}} {
1695 # ::ftpd::fsFile::fs --
1725 # callback configured for the ftpd.
1727 proc ::ftpd::fsFile::fs {command path args} {
1780 ::ftpd::Log debug "at dlist {$style} {$outchan} {$path}"
1782 #::ftpd::Log debug "at dlist2 {$style} {$outchan} {$path}"
1799 ::ftpd::Log debug "File list is {$fileList}"
1803 ::ftpd::Log debug "In nlist"
1810 ::ftpd::Log debug [file tail $f]
1933 # ::ftpd::fsFile::PermBits --
1946 proc ::ftpd::fsFile::PermBits {file mode} {
1965 # ::ftpd::fsFile::FormDate --
1978 proc ::ftpd::fsFile::FormDate {seconds} {
1998 package provide ftpd 1.2.5
2005 proc ::ftpd::command::PASV {sock argument} {
2006 upvar #0 ::ftpd::$sock data
2008 set data(sock2a) [socket -server [list ::ftpd::PasvAccept $sock] 0]
2013 ::ftpd::Log debug "PASV on {$list1} {$list2} $ip $port"
2023 proc ::ftpd::PasvAccept {sock sock2 ip port} {
2024 upvar #0 ::ftpd::$sock data
2026 ::ftpd::Log debug "In Pasv Accept with {$sock} {$sock2} {$ip} {$port}"
2037 ::ftpd::FinishData $sock