even more syslogs inserted
This commit is contained in:
parent
e63ed67403
commit
dbebe4e8ef
46
ftpd.scm
46
ftpd.scm
|
@ -296,7 +296,8 @@
|
||||||
(escape 'fick-dich-ins-knie))
|
(escape 'fick-dich-ins-knie))
|
||||||
((ftpd-error? condition)
|
((ftpd-error? condition)
|
||||||
(log (syslog-level notice)
|
(log (syslog-level notice)
|
||||||
"ftpd error occured: ~S -- escaping" ; this may occur more often than you think (??)
|
"ftpd error occured: ~S -- escaping"
|
||||||
|
; must this occur everytime CDUP is called in ftp-root-path?
|
||||||
(condition-stuff condition))
|
(condition-stuff condition))
|
||||||
(escape 'fick-dich-ins-knie))
|
(escape 'fick-dich-ins-knie))
|
||||||
(else
|
(else
|
||||||
|
@ -320,8 +321,13 @@
|
||||||
(cond
|
(cond
|
||||||
((assoc command *command-alist*)
|
((assoc command *command-alist*)
|
||||||
=> (lambda (pair)
|
=> (lambda (pair)
|
||||||
|
(log (syslog-level debug)
|
||||||
|
"command ~S was found in command-list and is executed with argument ~S"
|
||||||
|
(car pair) arg)
|
||||||
((cdr pair) arg)))
|
((cdr pair) arg)))
|
||||||
(else
|
(else
|
||||||
|
(log (syslog-level debug) "rejecting unknown command ~S (500) (argument: ~S)"
|
||||||
|
command arg)
|
||||||
(register-reply! 500
|
(register-reply! 500
|
||||||
(string-append
|
(string-append
|
||||||
(format #f "Unknown command: \"~A\"" command)
|
(format #f "Unknown command: \"~A\"" command)
|
||||||
|
@ -331,18 +337,24 @@
|
||||||
|
|
||||||
|
|
||||||
(define (handle-user name)
|
(define (handle-user name)
|
||||||
|
(log (syslog-level debug) "handling USER-command with name ~S"
|
||||||
|
name)
|
||||||
(cond
|
(cond
|
||||||
((session-logged-in?)
|
((session-logged-in?)
|
||||||
|
(log (syslog-level debug) "user ~S is already logged in (230)"
|
||||||
|
name)
|
||||||
(register-reply! 230
|
(register-reply! 230
|
||||||
"You are already logged in."))
|
"You are already logged in."))
|
||||||
((or (string=? "anonymous" name)
|
((or (string=? "anonymous" name)
|
||||||
(string=? "ftp" name))
|
(string=? "ftp" name))
|
||||||
(handle-user-anonymous))
|
(handle-user-anonymous))
|
||||||
(else
|
(else
|
||||||
|
(log (syslog-level debug) "rejecting non-anonymous login (530)")
|
||||||
(register-reply! 530
|
(register-reply! 530
|
||||||
"Only anonymous logins allowed."))))
|
"Only anonymous logins allowed."))))
|
||||||
|
|
||||||
(define (handle-user-anonymous)
|
(define (handle-user-anonymous)
|
||||||
|
(log (syslog-level debug) "anonymous user login (230)")
|
||||||
(set-session-logged-in? #t)
|
(set-session-logged-in? #t)
|
||||||
(set-session-authenticated? #t)
|
(set-session-authenticated? #t)
|
||||||
(set-session-anonymous? #t)
|
(set-session-anonymous? #t)
|
||||||
|
@ -352,26 +364,38 @@
|
||||||
(register-reply! 230 "Anonymous user logged in."))
|
(register-reply! 230 "Anonymous user logged in."))
|
||||||
|
|
||||||
(define (handle-pass password)
|
(define (handle-pass password)
|
||||||
|
(log (syslog-level debug) "handling PASS-command with password ~S"
|
||||||
|
password)
|
||||||
(cond
|
(cond
|
||||||
((not (session-logged-in?))
|
((not (session-logged-in?))
|
||||||
|
(log (syslog-level debug) "Rejecting password as user is not logged in yet. (530)")
|
||||||
(register-reply! 530 "You have not logged in yet."))
|
(register-reply! 530 "You have not logged in yet."))
|
||||||
((session-anonymous?)
|
((session-anonymous?)
|
||||||
|
(log (syslog-level debug) "Accepting password as user is logged in. (200)")
|
||||||
(register-reply! 200 "Thank you."))
|
(register-reply! 200 "Thank you."))
|
||||||
(else
|
(else
|
||||||
|
(log (syslog-level notice) "Reached unreachable case-branch while handling password! (502)")
|
||||||
(register-reply! 502 "This can't happen."))))
|
(register-reply! 502 "This can't happen."))))
|
||||||
|
|
||||||
(define (handle-quit foo)
|
(define (handle-quit foo)
|
||||||
|
(log (syslog-level debug) "handling QUIT-command (221)")
|
||||||
(register-reply! 221 "Goodbye! Au revoir! Auf Wiedersehen!")
|
(register-reply! 221 "Goodbye! Au revoir! Auf Wiedersehen!")
|
||||||
(signal 'ftpd-quit))
|
(signal 'ftpd-quit))
|
||||||
|
|
||||||
(define (handle-syst foo)
|
(define (handle-syst foo)
|
||||||
|
(log (syslog-level debug) "telling system type (215)")
|
||||||
(register-reply! 215 "UNIX Type: L8"))
|
(register-reply! 215 "UNIX Type: L8"))
|
||||||
|
|
||||||
(define (handle-cwd path)
|
(define (handle-cwd path)
|
||||||
|
(log (syslog-level debug) "handling CWD-command with ~S as path-argument"
|
||||||
|
path)
|
||||||
(ensure-authenticated-login)
|
(ensure-authenticated-login)
|
||||||
(let ((current-directory (assemble-path path)))
|
(let ((current-directory (assemble-path path)))
|
||||||
(with-errno-handler*
|
(with-errno-handler*
|
||||||
(lambda (errno packet)
|
(lambda (errno packet)
|
||||||
|
(log (syslog-level debug)
|
||||||
|
"can't change to directory \"~A\": ~A (550)"
|
||||||
|
path (car packet))
|
||||||
(signal-error! 550
|
(signal-error! 550
|
||||||
(format #f "Can't change directory to \"~A\": ~A."
|
(format #f "Can't change directory to \"~A\": ~A."
|
||||||
path
|
path
|
||||||
|
@ -381,16 +405,23 @@
|
||||||
(file-name-as-directory
|
(file-name-as-directory
|
||||||
(string-append (session-root-directory) current-directory))
|
(string-append (session-root-directory) current-directory))
|
||||||
(lambda () ; I hate gratuitous syntax
|
(lambda () ; I hate gratuitous syntax
|
||||||
|
(log (syslog-level debug)
|
||||||
|
"changing current directory to \"/~A\" (250)"
|
||||||
|
current-directory)
|
||||||
(set-session-current-directory current-directory)
|
(set-session-current-directory current-directory)
|
||||||
(register-reply! 250
|
(register-reply! 250
|
||||||
(format #f "Current directory changed to \"/~A\"."
|
(format #f "Current directory changed to \"/~A\"."
|
||||||
current-directory))))))))
|
current-directory))))))))
|
||||||
|
|
||||||
(define (handle-cdup foo)
|
(define (handle-cdup foo)
|
||||||
|
(log (syslog-level debug) "handling CDUP-command as \"CWD ..\"")
|
||||||
(handle-cwd ".."))
|
(handle-cwd ".."))
|
||||||
|
|
||||||
(define (handle-pwd foo)
|
(define (handle-pwd foo)
|
||||||
|
(log (syslog-level debug) "handling PWD-command")
|
||||||
(ensure-authenticated-login)
|
(ensure-authenticated-login)
|
||||||
|
(log (syslog-level debug) "replying \"/~A\" as current directory (257)"
|
||||||
|
(session-current-directory))
|
||||||
(register-reply! 257
|
(register-reply! 257
|
||||||
(format #f "Current directory is \"/~A\"."
|
(format #f "Current directory is \"/~A\"."
|
||||||
(session-current-directory))))
|
(session-current-directory))))
|
||||||
|
@ -757,6 +788,8 @@
|
||||||
file-port)))))))))))
|
file-port)))))))))))
|
||||||
|
|
||||||
(define (assemble-path path)
|
(define (assemble-path path)
|
||||||
|
(log (syslog-level debug) "assembling path ~S"
|
||||||
|
path)
|
||||||
(let* ((interim-path
|
(let* ((interim-path
|
||||||
(if (not (file-name-rooted? path))
|
(if (not (file-name-rooted? path))
|
||||||
(string-append (file-name-as-directory
|
(string-append (file-name-as-directory
|
||||||
|
@ -766,16 +799,23 @@
|
||||||
(complete-path (if (file-name-rooted? interim-path)
|
(complete-path (if (file-name-rooted? interim-path)
|
||||||
(file-name-sans-rooted interim-path)
|
(file-name-sans-rooted interim-path)
|
||||||
interim-path)))
|
interim-path)))
|
||||||
|
(log (syslog-level debug) "path ~S assembled to ~S"
|
||||||
|
path complete-path)
|
||||||
(cond
|
(cond
|
||||||
((normalize-path complete-path)
|
((normalize-path complete-path)
|
||||||
=> (lambda (assembled-path) assembled-path))
|
=> (lambda (assembled-path) assembled-path))
|
||||||
(else
|
(else
|
||||||
|
(log (syslog-level debug)
|
||||||
|
"invalid pathname -- tried to pass root directory (501)")
|
||||||
(signal-error! 501 "Invalid pathname")))))
|
(signal-error! 501 "Invalid pathname")))))
|
||||||
|
|
||||||
(define (ensure-authenticated-login)
|
(define (ensure-authenticated-login)
|
||||||
(if (or (not (session-logged-in?))
|
(if (or (not (session-logged-in?))
|
||||||
(not (session-authenticated?)))
|
(not (session-authenticated?)))
|
||||||
(signal-error! 530 "You're not logged in yet.")))
|
(begin
|
||||||
|
(log (syslog-level debug) "login authentication failed - user is not logged in (530)")
|
||||||
|
(signal-error! 530 "You're not logged in yet."))
|
||||||
|
(log (syslog-level debug) "authenticated login ensured.")))
|
||||||
|
|
||||||
(define (with-data-connection thunk)
|
(define (with-data-connection thunk)
|
||||||
(dynamic-wind ensure-data-connection
|
(dynamic-wind ensure-data-connection
|
||||||
|
@ -926,7 +966,7 @@
|
||||||
|
|
||||||
; Version
|
; Version
|
||||||
|
|
||||||
(define *ftpd-version* "$Revision: 1.19 $")
|
(define *ftpd-version* "$Revision: 1.20 $")
|
||||||
|
|
||||||
(define (copy-port->port-binary input-port output-port)
|
(define (copy-port->port-binary input-port output-port)
|
||||||
(let ((buffer (make-string *window-size*)))
|
(let ((buffer (make-string *window-size*)))
|
||||||
|
|
Loading…
Reference in New Issue