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
f22c690b
Commit
f22c690b
authored
24 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
flushes the log handles before fork, now the logs work too!
parent
05ec503e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/ftpserver.pl
+23
-14
23 additions, 14 deletions
tests/ftpserver.pl
with
23 additions
and
14 deletions
tests/ftpserver.pl
+
23
−
14
View file @
f22c690b
...
...
@@ -21,7 +21,7 @@ sub spawn; # forward declaration
open
(
FTPLOG
,
"
>log/ftpd.log
")
||
print
STDERR
"
failed to open log file, runs without logging
\n
";
sub
logmsg
{
print
FTPLOG
@_
;
}
sub
logmsg
{
print
FTPLOG
"
$$:
";
print
FTPLOG
@_
;
}
sub
ftpmsg
{
print
INPUT
@_
;
}
...
...
@@ -115,11 +115,13 @@ my @ftpdir=("total 20\r\n",
sub
LIST_command
{
# print "150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes)\r\n";
logmsg
"
$$: pass data to child pid
\n
";
for
(
@ftpdir
)
{
print
KID_TO_WRITE
$_
;
# print STDERR "PASS: $_";
}
close
(
KID_TO_WRITE
);
logmsg
"
$$: done passing data to child pid
\n
";
print
"
226 ASCII transfer complete
\r\n
";
return
0
;
...
...
@@ -179,10 +181,12 @@ sub PASV_command {
if
(
0
==
$pid
)
{
# the child process runs the child function
logmsg
"
$$ is a child PASV
\n
";
}
else
{
# parent continues
# print STDERR "parent after fork!\n";
logmsg
"
$$ is a parent from PASV
\n
";
return
;
# continue please
}
...
...
@@ -198,6 +202,7 @@ sub PASV_command {
}
if
(
11000
==
$port
)
{
print
"
500 no free ports!
\r\n
";
logmsg
"
couldn't find free port
\n
";
exit
;
}
listen
(
Server2
,
SOMAXCONN
)
||
die
"
listen: $!
";
...
...
@@ -212,20 +217,17 @@ sub PASV_command {
my
(
$port
,
$iaddr
)
=
sockaddr_in
(
$paddr
);
my
$name
=
gethostbyaddr
(
$iaddr
,
AF_INET
);
logmsg
"
data connection from
$name
[
",
inet_ntoa
(
$iaddr
),
"
] at port
$port
\n
";
logmsg
"
$$:
data connection from
$name
[
",
inet_ntoa
(
$iaddr
),
"
] at port
$port
\n
";
open
(
STDOUT
,
"
>&Client2
")
||
die
"
can't dup client to stdout
";
# print STDERR "#### CONN\n";
while
(
<
STDIN
>
)
{
print
$_
;
# print STDERR "SEND: $_";
}
close
(
SOCK
);
close
(
Client2
);
logmsg
"
process dies here
\n
";
exit
;
}
...
...
@@ -288,10 +290,15 @@ for ( $waitedpid = 0;
my
(
$port
,
$iaddr
)
=
sockaddr_in
(
$paddr
);
my
$name
=
gethostbyaddr
(
$iaddr
,
AF_INET
);
# flush data:
$|
=
1
;
logmsg
"
connection from
$name
[
",
inet_ntoa
(
$iaddr
),
"
] at port
$port
\n
";
# this code is forked and run
spawn
sub
{
open
(
STDIN
,
"
<&Client
")
||
die
"
can't dup client to stdin
";
open
(
STDOUT
,
"
>&Client
")
||
die
"
can't dup client to stdout
";
open
(
INPUT
,
"
>log/server.input
")
||
logmsg
"
failed to open log/server.input
\n
";
...
...
@@ -312,9 +319,6 @@ for ( $waitedpid = 0;
# < 150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes).
# * Getting file with size: -1
# flush data:
$|
=
1
;
print
"
220-running the curl suite test server
\r\n
",
"
220-running the curl suite test server
\r\n
",
"
220 running the curl suite test server
\r\n
";
...
...
@@ -365,15 +369,20 @@ for ( $waitedpid = 0;
my
$func
=
$commandfunc
{
$FTPCMD
};
if
(
$func
)
{
# it is!
# flush the handles before the possible fork
FTPLOG
->
autoflush
(
1
);
INPUT
->
autoflush
(
1
);
\
&$func
(
$FTPARG
);
}
logmsg
"
gone to state
$state
\n
";
}
# while(1)
close
(
Client
);
close
(
Client2
);
close
(
Server2
);
# print "Hello there, $name, it's now ", scalar localtime, "\r\n";
}
exit
;
# print "Hello there, $name, it's now ", scalar localtime, "\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