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
55b7c1c3
Commit
55b7c1c3
authored
24 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
REST support seems to work
NLST sends an NLST-looking list renamed the upload file
parent
190ecd65
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
+51
-17
51 additions, 17 deletions
tests/ftpserver.pl
with
51 additions
and
17 deletions
tests/ftpserver.pl
+
51
−
17
View file @
55b7c1c3
...
...
@@ -60,18 +60,22 @@ sub REAPER {
# USER is ok in fresh state
my
%commandok
=
(
"
USER
"
=>
"
fresh
",
"
PASS
"
=>
"
passwd
",
"
PASV
"
=>
"
loggedin|twosock
",
"
PORT
"
=>
"
loggedin|twosock
",
"
TYPE
"
=>
"
loggedin|twosock
",
"
LIST
"
=>
"
twosock
",
"
NLST
"
=>
"
twosock
",
"
RETR
"
=>
"
twosock
",
"
STOR
"
=>
"
twosock
",
"
CWD
"
=>
"
loggedin
",
"
SIZE
"
=>
"
loggedin|twosock
",
"
QUIT
"
=>
"
loggedin|twosock
",
'
USER
'
=>
'
fresh
',
'
PASS
'
=>
'
passwd
',
'
PASV
'
=>
'
loggedin|twosock
',
'
PORT
'
=>
'
loggedin|twosock
',
'
TYPE
'
=>
'
loggedin|twosock
',
'
LIST
'
=>
'
twosock
',
'
NLST
'
=>
'
twosock
',
'
RETR
'
=>
'
twosock
',
'
STOR
'
=>
'
twosock
',
'
APPE
'
=>
'
twosock
',
'
REST
'
=>
'
twosock
',
'
CWD
'
=>
'
loggedin|twosock
',
'
SYST
'
=>
'
loggedin
',
'
SIZE
'
=>
'
loggedin|twosock
',
'
PWD
'
=>
'
loggedin|twosock
',
'
QUIT
'
=>
'
loggedin|twosock
',
);
# initially, we're in 'fresh' state
...
...
@@ -82,24 +86,29 @@ my %statechange = ( 'USER' => 'passwd', # USER goes to passwd state
);
# this text is shown before the function specified below is run
my
%displaytext
=
('
USER
'
=>
'
331 We are happy you popped in!
',
# output FTP line
my
%displaytext
=
('
USER
'
=>
'
331 We are happy you popped in!
',
'
PASS
'
=>
'
230 Welcome you silly person
',
'
PORT
'
=>
'
200 You said PORT - I say FINE
',
'
TYPE
'
=>
'
200 I modify TYPE as you wanted
',
'
LIST
'
=>
'
150 here comes a directory
',
'
NLST
'
=>
'
150 here comes a directory
',
'
CWD
'
=>
'
250 CWD command successful.
',
'
QUIT
'
=>
'
221 bye bye baby
',
'
SYST
'
=>
'
215 UNIX Type: L8
',
# just fake something
'
QUIT
'
=>
'
221 bye bye baby
',
# just reply something
'
PWD
'
=>
'
257 "/nowhere/anywhere" is current directory
',
'
REST
'
=>
'
350 Yeah yeah we set it there for you
',
);
# callback functions for certain commands
my
%commandfunc
=
(
'
PORT
'
=>
\
&PORT_command
,
'
LIST
'
=>
\
&LIST_command
,
'
NLST
'
=>
\
&L
I
ST_command
,
# use LIST for now
'
NLST
'
=>
\
&
N
LST_command
,
'
PASV
'
=>
\
&PASV_command
,
'
RETR
'
=>
\
&RETR_command
,
'
SIZE
'
=>
\
&SIZE_command
,
'
REST
'
=>
\
&REST_command
,
'
STOR
'
=>
\
&STOR_command
,
'
APPE
'
=>
\
&STOR_command
,
# append looks like upload
);
# this is a built-in fake-dir ;-)
...
...
@@ -115,6 +124,11 @@ my @ftpdir=("total 20\r\n",
"
drwxrwxrwx 2 98 1 512 Oct 30 14:33 pub
\r\n
",
"
dr-xr-xr-x 5 0 1 512 Oct 1 1997 usr
\r\n
");
my
$rest
=
0
;
sub
REST_command
{
$rest
=
$_
[
0
];
}
sub
LIST_command
{
# print "150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes)\r\n";
...
...
@@ -129,6 +143,16 @@ sub LIST_command {
return
0
;
}
sub
NLST_command
{
my
@ftpdir
=
("
file
",
"
with space
",
"
fake
",
"
..
",
"
..
",
"
funny
",
"
README
");
for
(
@ftpdir
)
{
print
SOCK
"
$_
\r\n
";
}
close
(
SOCK
);
print
"
226 ASCII transfer complete
\r\n
";
return
0
;
}
sub
SIZE_command
{
my
$testno
=
$_
[
0
];
...
...
@@ -172,9 +196,15 @@ sub RETR_command {
if
(
$size
)
{
open
(
FILE
,
"
<
$filename
");
if
(
$rest
)
{
# move read pointer forward
seek
(
FILE
,
$rest
,
1
);
$size
-=
$rest
;
}
print
"
150 Binary data connection for
$testno
() (
$size
bytes).
\r\n
";
$rest
=
0
;
# reset rest again
open
(
FILE
,
"
<
$filename
");
while
(
<
FILE
>
)
{
print
SOCK
$_
;
}
...
...
@@ -194,7 +224,7 @@ sub STOR_command {
logmsg
"
STOR test number
$testno
\n
";
my
$filename
=
"
log/
ftpout
.
$testno
";
my
$filename
=
"
log/
upload
.
$testno
";
print
"
125 Gimme gimme gimme!
\r\n
";
...
...
@@ -319,6 +349,10 @@ for ( $waitedpid = 0;
logmsg
"
GOT: ($1)
$_
\n
";
if
(
$verbose
)
{
print
STDERR
"
IN:
$full
\n
";
}
my
$ok
=
$commandok
{
$FTPCMD
};
if
(
$ok
!~
/$state/
)
{
print
"
500
$FTPCMD
not OK in state:
$state
!
\r\n
";
...
...
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