forked from KolibriOS/kolibrios
FTPd: allow commands with only LF instead of CR LF, print commands to console, other small improvements.
git-svn-id: svn://kolibrios.org@3819 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
4828326119
commit
685f1172f0
@ -740,12 +740,11 @@ cmdPASV:
|
||||
; 227 Entering Passive Mode (a1,a2,a3,a4,p1,p2)
|
||||
; where a1.a2.a3.a4 is the IP address and p1*256+p2 is the port number.
|
||||
|
||||
; '227 ('
|
||||
; '227 Entering passive mode ('
|
||||
lea edi, [ebp + thread_data.buffer]
|
||||
mov eax, '227 '
|
||||
stosd
|
||||
mov al, '('
|
||||
stosb
|
||||
mov ecx, str_227.length
|
||||
mov esi, str_227
|
||||
rep movsb
|
||||
; ip
|
||||
movzx eax, byte [serverip]
|
||||
call dword_to_ascii
|
||||
@ -771,7 +770,7 @@ cmdPASV:
|
||||
movzx eax, byte [ebp + thread_data.datasock.sin_port+1]
|
||||
call dword_to_ascii
|
||||
; ')', 13, 10, 0
|
||||
mov eax, ')' + 0x000a0d00
|
||||
mov eax, ')' + (0x000a0d shl 8)
|
||||
stosd
|
||||
|
||||
lea esi, [edi - thread_data.buffer]
|
||||
@ -783,6 +782,12 @@ cmdPASV:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
iglobal
|
||||
str_227 db "227 Entering passive mode ("
|
||||
.length = $ - str_227
|
||||
endg
|
||||
|
||||
;------------------------------------------------
|
||||
; "PWD"
|
||||
;
|
||||
|
@ -76,10 +76,11 @@ macro sendFTP str {
|
||||
local string, length
|
||||
xor edi, edi
|
||||
mcall send, [ebp + thread_data.socketnum], string, length
|
||||
invoke con_write_asciiz, string
|
||||
|
||||
iglobal
|
||||
string db str, 13, 10
|
||||
length = $ - string
|
||||
string db str, 13, 10, 0
|
||||
length = $ - string - 1
|
||||
\}
|
||||
}
|
||||
|
||||
@ -87,7 +88,7 @@ include 'commands.inc'
|
||||
|
||||
start:
|
||||
mcall 68, 11 ; init heap
|
||||
mcall 40, 1 shl 7 ; we only want network events
|
||||
mcall 40, EVM_STACK ; we only want network events
|
||||
|
||||
; load libraries
|
||||
stdcall dll.Load, @IMPORT
|
||||
@ -138,7 +139,7 @@ start:
|
||||
add esp, 8
|
||||
|
||||
; open listening socket
|
||||
mcall socket, AF_INET4, SOCK_STREAM, 0
|
||||
mcall socket, AF_INET4, SOCK_STREAM, SO_NONBLOCK ; we dont want to block on accept
|
||||
cmp eax, -1
|
||||
je sock_err
|
||||
mov [socketnum], eax
|
||||
@ -208,7 +209,7 @@ threadstart:
|
||||
lea esp, [eax + thread_data.stack] ; init stack
|
||||
mov ebp, eax
|
||||
|
||||
mcall 40, 1 shl 7 ; we only want network events for this thread
|
||||
mcall 40, EVM_STACK ; we only want network events for this thread
|
||||
|
||||
lea ebx, [ebp + thread_data.buffer] ; get information about the current process
|
||||
or ecx, -1
|
||||
@ -241,15 +242,17 @@ end if
|
||||
|
||||
diff16 "threadloop", 0, $
|
||||
threadloop:
|
||||
; Check if our socket is still connected
|
||||
mcall send, [ebp + thread_data.socketnum], 0, 0 ; Try to send zero bytes, if socket is closed, this will return -1
|
||||
cmp eax, -1
|
||||
je thread_exit
|
||||
;; Check if our socket is still connected
|
||||
; mcall send, [ebp + thread_data.socketnum], 0, 0 ; Try to send zero bytes, if socket is closed, this will return -1
|
||||
; cmp eax, -1
|
||||
; je thread_exit
|
||||
|
||||
cmp [alive], 0 ; Did main thread take a run for it?
|
||||
je thread_exit
|
||||
|
||||
mcall 10 ; Wait for network event
|
||||
mcall 23, 100 ; Wait for network event
|
||||
test eax, eax
|
||||
jz threadloop
|
||||
|
||||
cmp [ebp + thread_data.mode], MODE_PASSIVE_WAIT
|
||||
jne .not_passive
|
||||
@ -282,12 +285,17 @@ threadloop:
|
||||
|
||||
; Check if we received a newline character, if not, wait for more data
|
||||
mov ecx, eax
|
||||
mov al, 13
|
||||
mov al, 10
|
||||
repne scasb
|
||||
jne threadloop
|
||||
|
||||
cmp word[edi-1], 0x0a0d
|
||||
jne .got_command
|
||||
dec edi
|
||||
|
||||
; We got a command!
|
||||
mov byte [edi + 1], 0 ; append string with zero byte
|
||||
.got_command:
|
||||
mov byte [edi], 0 ; append string with zero byte
|
||||
lea esi, [ebp + thread_data.buffer]
|
||||
mov ecx, [ebp + thread_data.buffer_ptr]
|
||||
sub ecx, esi
|
||||
@ -332,7 +340,7 @@ thread_exit:
|
||||
|
||||
; initialized data
|
||||
|
||||
title db 'KolibriOS FTP daemon 0.1', 0
|
||||
title db 'FTP daemon', 0
|
||||
str1 db 'Starting FTP daemon on port %u.', 0
|
||||
str2 db '.', 0
|
||||
str2b db ' OK!',10,0
|
||||
|
Loading…
Reference in New Issue
Block a user