File: ftpd.test

package info (click to toggle)
tcllib 1.14-dfsg-3%2Bdeb7u1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 33,036 kB
  • sloc: tcl: 148,302; ansic: 14,067; sh: 10,320; xml: 1,766; yacc: 753; pascal: 551; makefile: 129; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (44 lines) | stat: -rwxr-xr-x 1,134 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}

# FTP daemon

# This ftpd runs on port 7777, uses /tmp as root dir and does not do
# any authentication at all. IOW, do not run this server for longer
# periods of time or you create a security hole on your machine. This
# server is strictly for short testing the implementation of the ftp
# module over short periods of time.

package require Tcl 8.3
package require ftpd
package require log

proc bgerror {args} {
    global errorInfo
    puts stderr "bgerror: [join $args]"
    puts stderr $errorInfo
}

proc ftplog {level text} {
    if {[string equal $level note]} {set level notice}
    log::log $level $text
}

proc noauth {args} {
    return 1
}

proc fakefs {cmd path args} {
    # Use the standard unix fs, i.e. "::ftpd::fsFile::fs", but rewrite the incoming path
    # to stay in the /tmp directory.

    set path [file join / tmp [file tail $path]]
    eval [linsert $args 0 ::ftpd::fsFile::fs $cmd $path]
}

::ftpd::config -logCmd ftplog -authUsrCmd noauth -authFileCmd noauth -fsCmd fakefs
set ::ftpd::port 7777 ; # Listen on user port

::ftpd::server
vwait forever