Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
af7a5b29
Commit
af7a5b29
authored
15 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
support IMAP select and LOGOUT
parent
344bbcf2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/ftpserver.pl
+58
-26
58 additions, 26 deletions
tests/ftpserver.pl
with
58 additions
and
26 deletions
tests/ftpserver.pl
+
58
−
26
View file @
af7a5b29
...
...
@@ -348,18 +348,18 @@ if($proto eq "ftp") {
'
PROT
'
=>
'
500 PROT not implemented
',
);
%commandfunc
=
(
'
PORT
'
=>
\
&PORT_
command
,
'
EPRT
'
=>
\
&PORT_
command
,
'
LIST
'
=>
\
&LIST_
command
,
'
NLST
'
=>
\
&NLST_
command
,
'
PASV
'
=>
\
&PASV_
command
,
'
EPSV
'
=>
\
&PASV_
command
,
'
RETR
'
=>
\
&RETR_
command
,
'
SIZE
'
=>
\
&SIZE_
command
,
'
REST
'
=>
\
&REST_
command
,
'
STOR
'
=>
\
&STOR_
command
,
'
APPE
'
=>
\
&STOR_
command
,
# append looks like upload
'
MDTM
'
=>
\
&MDTM_
command
,
%commandfunc
=
(
'
PORT
'
=>
\
&PORT_
ftp
,
'
EPRT
'
=>
\
&PORT_
ftp
,
'
LIST
'
=>
\
&LIST_
ftp
,
'
NLST
'
=>
\
&NLST_
ftp
,
'
PASV
'
=>
\
&PASV_
ftp
,
'
EPSV
'
=>
\
&PASV_
ftp
,
'
RETR
'
=>
\
&RETR_
ftp
,
'
SIZE
'
=>
\
&SIZE_
ftp
,
'
REST
'
=>
\
&REST_
ftp
,
'
STOR
'
=>
\
&STOR_
ftp
,
'
APPE
'
=>
\
&STOR_
ftp
,
# append looks like upload
'
MDTM
'
=>
\
&MDTM_
ftp
,
);
}
elsif
(
$proto
eq
"
pop3
")
{
...
...
@@ -374,10 +374,12 @@ elsif($proto eq "pop3") {
}
elsif
(
$proto
eq
"
imap
")
{
%commandfunc
=
('
FETCH
'
=>
\
&FETCH_imap
,
'
SELECT
'
=>
\
&SELECT_imap
,
);
%displaytext
=
('
LOGIN
'
=>
'
OK We are happy you popped in!
',
'
SELECT
'
=>
'
OK selection done
',
'
LOGOUT
'
=>
'
OK thanks for the fish
',
);
}
...
...
@@ -407,9 +409,33 @@ sub close_dataconn {
################ IMAP commands
################
# global to allow the command functions to read it
my
$cmdid
;
# what was picked by SELECT
my
$selected
;
sub
SELECT_imap
{
my
(
$testno
)
=
@_
;
my
@data
;
my
$size
;
logmsg
"
SELECT_imap got test
$testno
\n
";
$selected
=
$testno
;
return
0
;
}
sub
FETCH_imap
{
my
(
$testno
)
=
@_
;
my
@data
;
my
$size
;
logmsg
"
FETCH_imap got test
$testno
\n
";
$testno
=
$selected
;
if
(
$testno
=~
/^verifiedserver$/
)
{
# this is the secret command that verifies that this actually is
...
...
@@ -437,11 +463,17 @@ sub FETCH_imap {
@data
=
getpart
("
reply
",
"
data
$testpart
");
}
sendcontrol
"
- OK Mail transfer starts
\r\n
";
for
(
@data
)
{
$size
+=
length
(
$_
);
}
sendcontrol
"
* FETCH starts {
$size
}
\r\n
";
for
my
$d
(
@data
)
{
sendcontrol
$d
;
}
sendcontrol
"
$cmdid
OK FETCH completed
\r\n
";
return
0
;
}
...
...
@@ -496,12 +528,12 @@ sub RETR_pop3 {
################ FTP commands
################
my
$rest
=
0
;
sub
REST_
command
{
sub
REST_
ftp
{
$rest
=
$_
[
0
];
logmsg
"
Set REST position to
$rest
\n
"
}
sub
LIST_
command
{
sub
LIST_
ftp
{
# print "150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes)\r\n";
# this is a built-in fake-dir ;-)
...
...
@@ -526,7 +558,7 @@ my @ftpdir=("total 20\r\n",
return
0
;
}
sub
NLST_
command
{
sub
NLST_
ftp
{
my
@ftpdir
=
("
file
",
"
with space
",
"
fake
",
"
..
",
"
..
",
"
funny
",
"
README
");
logmsg
"
pass NLST data on data connection
\n
";
for
(
@ftpdir
)
{
...
...
@@ -537,7 +569,7 @@ sub NLST_command {
return
0
;
}
sub
MDTM_
command
{
sub
MDTM_
ftp
{
my
$testno
=
$_
[
0
];
my
$testpart
=
"";
if
(
$testno
>
10000
)
{
...
...
@@ -564,7 +596,7 @@ sub MDTM_command {
return
0
;
}
sub
SIZE_
command
{
sub
SIZE_
ftp
{
my
$testno
=
$_
[
0
];
my
$testpart
=
"";
if
(
$testno
>
10000
)
{
...
...
@@ -609,7 +641,7 @@ sub SIZE_command {
return
0
;
}
sub
RETR_
command
{
sub
RETR_
ftp
{
my
(
$testno
)
=
@_
;
if
(
$testno
=~
/^verifiedserver$/
)
{
...
...
@@ -686,7 +718,7 @@ sub RETR_command {
return
0
;
}
sub
STOR_
command
{
sub
STOR_
ftp
{
my
$testno
=
$_
[
0
];
my
$filename
=
"
log/upload.
$testno
";
...
...
@@ -737,7 +769,7 @@ sub STOR_command {
return
0
;
}
sub
PASV_
command
{
sub
PASV_
ftp
{
my
(
$arg
,
$cmd
)
=
@_
;
my
$pasvport
;
my
$pidf
=
"
.sockdata
$ftpdnum$ext
.pid
";
...
...
@@ -843,7 +875,7 @@ sub PASV_command {
# Support both PORT and EPRT here. Consider LPRT too.
sub
PORT_
command
{
sub
PORT_
ftp
{
my
(
$arg
,
$cmd
)
=
@_
;
my
$port
;
my
$addr
;
...
...
@@ -1055,17 +1087,17 @@ while(1) {
# Remove trailing CRLF.
s/[\n\r]+$//
;
my
$cmdid
;
my
$FTPCMD
;
my
$FTPARG
;
my
$full
=
$_
;
if
(
$proto
eq
"
imap
")
{
# IMAP is different with its identifier first on the command line
unless
(
m/^([^ ]+) ([^ ]+) (.*)/i
)
{
sendcontrol
"
500 '
$_
': command not understood.
\r\n
";
unless
(
m/^([^ ]+) ([^ ]+) (.*)/
||
m/^([^ ]+) ([^ ]+)/
)
{
sendcontrol
"
$1 '
$_
': command not understood.
\r\n
";
last
;
}
$cmdid
=
$
1
;
$cmdid
=
$
1
;
# set the global variable
$FTPCMD
=
$
2
;
$FTPARG
=
$
3
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment