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
0c367fef
Commit
0c367fef
authored
17 years ago
by
Yang Tse
Browse files
Options
Downloads
Patches
Plain Diff
ConnectTimeout requires OpenSSH 3.7 or later
parent
a418d290
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/sshserver.pl
+55
-39
55 additions, 39 deletions
tests/sshserver.pl
with
55 additions
and
39 deletions
tests/sshserver.pl
+
55
−
39
View file @
0c367fef
...
...
@@ -12,12 +12,16 @@
use
strict
;
use
File::
Spec
;
my
$verbose
=
0
;
# set to 1 for debugging
my
$verbose
=
1
;
# set to 1 for debugging
my
$showfiles
=
0
;
my
$port
=
8999
;
# just our default, weird enough
my
$listenaddr
=
"
127.0.0.1
";
# address on which to listen
my
$conffile
=
"
curl_sshd_config
";
# sshd configuration data
my
$conffile_ssh
=
"
curl_ssh_config
";
# ssh configuration data
my
$knownhostsfile
=
"
curl_client_knownhosts
";
# ssh knownhosts file
my
$path
=
`
pwd
`;
chomp
$path
;
...
...
@@ -75,6 +79,24 @@ sub displayfile {
print
"
=== End of file
$file
\n
";
}
# Append a string to sshd config file
sub
set_sshd_option
{
my
(
$string
)
=
@_
;
if
(
open
(
FILE
,
"
>>
$conffile
"))
{
print
FILE
"
$string
\n
";
close
FILE
;
}
}
# Append a string to ssh config file
sub
set_ssh_option
{
my
(
$string
)
=
@_
;
if
(
open
(
FILE
,
"
>>
$conffile_ssh
"))
{
print
FILE
"
$string
\n
";
close
FILE
;
}
}
# Parse options
do
{
if
(
$ARGV
[
0
]
eq
"
-v
")
{
...
...
@@ -93,10 +115,6 @@ do {
}
}
while
(
shift
@ARGV
);
my
$conffile
=
"
curl_sshd_config
";
# sshd configuration data
my
$conffile_ssh
=
"
curl_ssh_config
";
# ssh configuration data
my
$knownhostsfile
=
"
curl_client_knownhosts
";
# ssh knownhosts file
# Searching for sshd and sftp-server will be done first
# in the PATH and afterwards in other common locations.
my
@spath
;
...
...
@@ -133,45 +151,48 @@ my $ssh_daemon;
my
$ssh_ver_major
;
my
$ssh_ver_minor
;
my
$ssh_ver_patch
;
chomp
(
$tmpstr
=
qx($sshd -V 2>&1 | grep OpenSSH)
);
if
(
$tmpstr
=~
/OpenSSH[_-](\d+)\.(\d+)(\.(\d+))*/
)
{
(
$ssh_ver_major
,
$ssh_ver_minor
,
$ssh_ver_patch
)
=
(
$
1
,
$
2
,
$
4
);
$ssh_daemon
=
'
OpenSSH
';
if
(
10
*
$ssh_ver_major
+
$ssh_ver_minor
==
36
)
{
$showfiles
=
1
;
my
$ssh_version
;
foreach
$tmpstr
(
qx($sshd -V 2>&1)
)
{
if
(
$tmpstr
=~
/OpenSSH[_-](\d+)\.(\d+)(\.(\d+))*/i
)
{
(
$ssh_ver_major
,
$ssh_ver_minor
,
$ssh_ver_patch
)
=
(
$
1
,
$
2
,
$
4
);
$ssh_daemon
=
'
OpenSSH
';
$ssh_version
=
10
*
$ssh_ver_major
+
$ssh_ver_minor
;
if
(
$ssh_version
==
36
)
{
$showfiles
=
1
;
}
last
;
}
}
if
(
!
$ssh_daemon
)
{
chomp
(
$tmpstr
=
qx($sshd -V 2>&1 | grep Sun_SSH)
);
if
(
$tmpstr
=~
/Sun[_-]SSH[_-](\d+)\.(\d+)/
)
{
if
(
$tmpstr
=~
/Sun[_-]SSH[_-](\d+)\.(\d+)/i
)
{
(
$ssh_ver_major
,
$ssh_ver_minor
)
=
(
$
1
,
$
2
);
$ssh_daemon
=
'
SunSSH
';
if
(
10
*
$ssh_ver_major
+
$ssh_ver_minor
==
11
)
{
$ssh_version
=
10
*
$ssh_ver_major
+
$ssh_ver_minor
;
if
(
$ssh_version
==
11
)
{
$showfiles
=
1
;
}
last
;
}
}
if
(
$verbose
)
{
print
STDERR
"
ssh_daemon:
$ssh_daemon
\n
";
print
STDERR
"
ssh_ver_major:
$ssh_ver_major
\n
";
print
STDERR
"
ssh_ver_minor:
$ssh_ver_minor
\n
";
print
STDERR
"
ssh_ver_patch:
$ssh_ver_patch
\n
";
}
# Verify minimum SSH daemon version.
my
$sshd_ver_ok
=
1
;
if
((
$ssh_daemon
=~
/OpenSSH/
)
&&
(
10
*
$ssh_ver_major
+
$ssh_ver_minor
<
36
))
{
print
"
SSH server daemon found is OpenSSH
$ssh_ver_major
.
$ssh_ver_minor
\n
";
if
(
!
$ssh_daemon
)
{
if
(
$verbose
)
{
print
STDERR
"
unsupported SSH server daemon found
\n
";
chomp
(
$tmpstr
=
qx($sshd -V 2>&1)
);
print
STDERR
"
$tmpstr
\n
";
}
$sshd_ver_ok
=
0
;
}
if
((
$ssh_daemon
=~
/SunSSH/
)
&&
(
10
*
$ssh_ver_major
+
$ssh_ver_minor
<
11
))
{
print
"
SSH server daemon found is SunSSH
$ssh_ver_major
.
$ssh_ver_minor
\n
";
elsif
((
$ssh_daemon
=~
/OpenSSH/
)
&&
(
$ssh_version
<
36
))
{
if
(
$verbose
)
{
print
STDERR
"
sshd found is
$ssh_daemon
$ssh_ver_major
.
$ssh_ver_minor
\n
";
}
$sshd_ver_ok
=
0
;
}
if
(
!
$ssh_daemon
)
{
print
"
SSH server daemon found is not OpenSSH nor SunSSH
\n
";
chomp
(
$tmpstr
=
qx($sshd -V 2>&1)
)
;
print
"
$tmpstr
\n
";
els
if
(
(
$ssh_daemon
=~
/SunSSH/
)
&&
(
$ssh_version
<
11
)
)
{
if
(
$verbose
)
{
print
STDERR
"
sshd found is
$ssh_daemon
$ssh_ver_major
.
$ssh_ver_minor
\n
"
;
}
$sshd_ver_ok
=
0
;
}
if
(
!
$sshd_ver_ok
)
{
...
...
@@ -251,14 +272,6 @@ EOFSSHD
;
close
FILE
||
die
"
Could not close
$conffile
";
sub
set_sshd_option
{
my
(
$string
)
=
@_
;
if
(
open
(
FILE
,
"
>>
$conffile
"))
{
print
FILE
"
$string
\n
";
close
FILE
;
}
}
if
(
$supports_UsePAM
)
{
set_sshd_option
('
UsePAM no
');
}
...
...
@@ -288,7 +301,6 @@ Protocol 2
BatchMode yes
CheckHostIP no
Compression no
ConnectTimeout 20
ForwardX11 no
GatewayPorts no
HostbasedAuthentication yes
...
...
@@ -299,6 +311,10 @@ EOFSSH
;
close
SSHFILE
||
die
"
Could not close
$conffile_ssh
";
if
((
$ssh_daemon
=~
/OpenSSH/
)
&&
(
$ssh_version
>=
37
))
{
set_ssh_option
('
ConnectTimeout 20
');
# Supported in OpenSSH 3.7 and later
}
# Verify that sshd supports our configuration file
if
(
system
"
$sshd
-t -f
$conffile
> log/sshd.log 2>&1
")
{
...
...
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