70
70
# use warnings;
71
71
use Cwd;
72
72
73
+ # Subs imported from serverhelp module
74
+ use serverhelp qw(
75
+ servername_str
76
+ ) ;
77
+
73
78
# Variables and subs imported from sshhelp module
74
79
use sshhelp qw(
75
80
$sshdexe
@@ -802,22 +807,27 @@ sub runhttpserver {
802
807
my $pidfile = $HTTPPIDFILE ;
803
808
my $port = $HTTPPORT ;
804
809
my $ip = $HOSTIP ;
805
- my $nameext ;
810
+ my $proto = ' http' ;
811
+ my $ipvnum = 4;
812
+ my $idnum = 1;
813
+ my $srvrname ;
806
814
my $fork = $forkserver ?" --fork" :" " ;
807
815
808
816
if ($ipv6 ) {
809
817
# if IPv6, use a different setup
818
+ $ipvnum = 6;
810
819
$pidfile = $HTTP6PIDFILE ;
811
820
$port = $HTTP6PORT ;
812
821
$ip = $HOST6IP ;
813
- $nameext =" -ipv6" ;
814
822
}
815
823
816
824
# don't retry if the server doesn't work
817
825
if ($doesntrun {$pidfile }) {
818
826
return (0,0);
819
827
}
820
828
829
+ $srvrname = servername_str($proto , $ipvnum , $idnum );
830
+
821
831
my $pid = processexists($pidfile );
822
832
if ($pid > 0) {
823
833
stopserver($pid );
@@ -836,7 +846,7 @@ sub runhttpserver {
836
846
837
847
if ($httppid <= 0 || !kill (0, $httppid )) {
838
848
# it is NOT alive
839
- logmsg " RUN: failed to start the HTTP $nameext server\n " ;
849
+ logmsg " RUN: failed to start the $srvrname server\n " ;
840
850
stopserver(" $pid2 " );
841
851
displaylogs($testnumcheck );
842
852
$doesntrun {$pidfile } = 1;
@@ -846,7 +856,7 @@ sub runhttpserver {
846
856
# Server is up. Verify that we can speak to it.
847
857
my $pid3 = verifyserver(" http" , $ip , $port );
848
858
if (!$pid3 ) {
849
- logmsg " RUN: HTTP $nameext server failed verification\n " ;
859
+ logmsg " RUN: $srvrname server failed verification\n " ;
850
860
# failed to talk to it properly. Kill the server and return failure
851
861
stopserver(" $httppid $pid2 " );
852
862
displaylogs($testnumcheck );
@@ -856,7 +866,7 @@ sub runhttpserver {
856
866
$pid2 = $pid3 ;
857
867
858
868
if ($verbose ) {
859
- logmsg " RUN: HTTP $nameext server is now running PID $httppid \n " ;
869
+ logmsg " RUN: $srvrname server is now running PID $httppid \n " ;
860
870
}
861
871
862
872
sleep (1);
@@ -873,13 +883,18 @@ sub runhttpsserver {
873
883
my $RUNNING ;
874
884
my $ip = $HOSTIP ;
875
885
my $pidfile = $HTTPSPIDFILE ;
886
+ my $proto = ' https' ;
887
+ my $ipvnum = 4;
888
+ my $idnum = 1;
889
+ my $srvrname ;
876
890
877
891
if (!$stunnel ) {
878
892
return 0;
879
893
}
880
894
881
895
if ($ipv6 ) {
882
896
# not complete yet
897
+ $ipvnum = 6;
883
898
$ip = $HOST6IP ;
884
899
}
885
900
@@ -888,6 +903,8 @@ sub runhttpsserver {
888
903
return (0,0);
889
904
}
890
905
906
+ $srvrname = servername_str($proto , $ipvnum , $idnum );
907
+
891
908
my $pid = processexists($pidfile );
892
909
if ($pid > 0) {
893
910
# kill previous stunnel!
@@ -903,7 +920,7 @@ sub runhttpsserver {
903
920
904
921
if ($httpspid <= 0 || !kill (0, $httpspid )) {
905
922
# it is NOT alive
906
- logmsg " RUN: failed to start the HTTPS server\n " ;
923
+ logmsg " RUN: failed to start the $srvrname server\n " ;
907
924
stopservers($verbose );
908
925
displaylogs($testnumcheck );
909
926
$doesntrun {$pidfile } = 1;
@@ -913,7 +930,7 @@ sub runhttpsserver {
913
930
# Server is up. Verify that we can speak to it.
914
931
my $pid3 = verifyserver(" https" , $ip , $HTTPSPORT );
915
932
if (!$pid3 ) {
916
- logmsg " RUN: HTTPS server failed verification\n " ;
933
+ logmsg " RUN: $srvrname server failed verification\n " ;
917
934
# failed to talk to it properly. Kill the server and return failure
918
935
stopserver(" $httpspid $pid2 " );
919
936
displaylogs($testnumcheck );
@@ -923,7 +940,7 @@ sub runhttpsserver {
923
940
# Here pid3 is actually the pid returned by the unsecure-http server.
924
941
925
942
if ($verbose ) {
926
- logmsg " RUN: HTTPS server is now running PID $httpspid \n " ;
943
+ logmsg " RUN: $srvrname server is now running PID $httpspid \n " ;
927
944
}
928
945
929
946
sleep (1);
@@ -941,20 +958,22 @@ sub runpingpongserver {
941
958
my $port ;
942
959
my $pidfile ;
943
960
my $ip =$HOSTIP ;
944
- my $nameext ;
945
961
my $cmd ;
946
962
my $flag ;
963
+ my $ipvnum = 4;
964
+ my $idnum = ($id && ($id =~ / ^(\d +)$ / ) && ($id > 1)) ? $id : 1;
965
+ my $srvrname ;
947
966
948
967
if ($proto eq " ftp" ) {
949
- $port = $id ?$FTP2PORT :$FTPPORT ;
950
- $pidfile = $id ?$FTP2PIDFILE :$FTPPIDFILE ;
968
+ $port = ( $idnum >1) ?$FTP2PORT :$FTPPORT ;
969
+ $pidfile = ( $idnum >1) ?$FTP2PIDFILE :$FTPPIDFILE ;
951
970
952
971
if ($ipv6 ) {
953
972
# if IPv6, use a different setup
973
+ $ipvnum = 6;
954
974
$pidfile = $FTP6PIDFILE ;
955
975
$port = $FTP6PORT ;
956
976
$ip = $HOST6IP ;
957
- $nameext =" -ipv6" ;
958
977
}
959
978
}
960
979
elsif ($proto eq " pop3" ) {
@@ -980,6 +999,8 @@ sub runpingpongserver {
980
999
return (0,0);
981
1000
}
982
1001
1002
+ $srvrname = servername_str($proto , $ipvnum , $idnum );
1003
+
983
1004
my $pid = processexists($pidfile );
984
1005
if ($pid > 0) {
985
1006
stopserver($pid );
@@ -990,8 +1011,8 @@ sub runpingpongserver {
990
1011
$flag .= $debugprotocol ?" -v " :" " ;
991
1012
$flag .= " -s \" $srcdir \" " ;
992
1013
my $addr ;
993
- if ($id ) {
994
- $flag .=" --id $id " ;
1014
+ if ($idnum > 1 ) {
1015
+ $flag .=" --id $idnum " ;
995
1016
}
996
1017
if ($ipv6 ) {
997
1018
$flag .=" --ipv6 " ;
@@ -1005,7 +1026,7 @@ sub runpingpongserver {
1005
1026
1006
1027
if ($ftppid <= 0 || !kill (0, $ftppid )) {
1007
1028
# it is NOT alive
1008
- logmsg " RUN: failed to start the " . uc ( $proto ) . " $id$nameext server\n " ;
1029
+ logmsg " RUN: failed to start the $srvrname server\n " ;
1009
1030
stopserver(" $pid2 " );
1010
1031
displaylogs($testnumcheck );
1011
1032
$doesntrun {$pidfile } = 1;
@@ -1015,7 +1036,7 @@ sub runpingpongserver {
1015
1036
# Server is up. Verify that we can speak to it.
1016
1037
my $pid3 = verifyserver($proto , $ip , $port );
1017
1038
if (!$pid3 ) {
1018
- logmsg " RUN: " . uc ( $proto ) . " $id$nameext server failed verification\n " ;
1039
+ logmsg " RUN: $srvrname server failed verification\n " ;
1019
1040
# failed to talk to it properly. Kill the server and return failure
1020
1041
stopserver(" $ftppid $pid2 " );
1021
1042
displaylogs($testnumcheck );
@@ -1025,8 +1046,7 @@ sub runpingpongserver {
1025
1046
$pid2 = $pid3 ;
1026
1047
1027
1048
if ($verbose ) {
1028
- logmsg " RUN: " . uc ($proto ) ." $id$nameext server is now running" .
1029
- " PID $ftppid \n " ;
1049
+ logmsg " RUN: $srvrname server is now running PID $ftppid \n " ;
1030
1050
}
1031
1051
1032
1052
sleep (1);
@@ -1043,13 +1063,18 @@ sub runftpsserver {
1043
1063
my $RUNNING ;
1044
1064
my $ip = $HOSTIP ;
1045
1065
my $pidfile = $FTPSPIDFILE ;
1066
+ my $proto = ' ftps' ;
1067
+ my $ipvnum = 4;
1068
+ my $idnum = 1;
1069
+ my $srvrname ;
1046
1070
1047
1071
if (!$stunnel ) {
1048
1072
return 0;
1049
1073
}
1050
1074
1051
1075
if ($ipv6 ) {
1052
1076
# not complete yet
1077
+ $ipvnum = 6;
1053
1078
$ip = $HOST6IP ;
1054
1079
}
1055
1080
@@ -1058,6 +1083,8 @@ sub runftpsserver {
1058
1083
return (0,0);
1059
1084
}
1060
1085
1086
+ $srvrname = servername_str($proto , $ipvnum , $idnum );
1087
+
1061
1088
my $pid = processexists($pidfile );
1062
1089
if ($pid > 0) {
1063
1090
# kill previous stunnel!
@@ -1072,7 +1099,7 @@ sub runftpsserver {
1072
1099
1073
1100
if ($ftpspid <= 0 || !kill (0, $ftpspid )) {
1074
1101
# it is NOT alive
1075
- logmsg " RUN: failed to start the FTPS server\n " ;
1102
+ logmsg " RUN: failed to start the $srvrname server\n " ;
1076
1103
stopservers($verbose );
1077
1104
displaylogs($testnumcheck );
1078
1105
$doesntrun {$pidfile } = 1;
@@ -1082,7 +1109,7 @@ sub runftpsserver {
1082
1109
# Server is up. Verify that we can speak to it.
1083
1110
my $pid3 = verifyserver(" ftps" , $ip , $FTPSPORT );
1084
1111
if (!$pid3 ) {
1085
- logmsg " RUN: FTPS server failed verification\n " ;
1112
+ logmsg " RUN: $srvrname server failed verification\n " ;
1086
1113
# failed to talk to it properly. Kill the server and return failure
1087
1114
stopserver(" $ftpspid $pid2 " );
1088
1115
displaylogs($testnumcheck );
@@ -1092,7 +1119,7 @@ sub runftpsserver {
1092
1119
# Here pid3 is actually the pid returned by the unsecure-ftp server.
1093
1120
1094
1121
if ($verbose ) {
1095
- logmsg " RUN: FTPS server is now running PID $ftpspid \n " ;
1122
+ logmsg " RUN: $srvrname server is now running PID $ftpspid \n " ;
1096
1123
}
1097
1124
1098
1125
sleep (1);
@@ -1111,22 +1138,27 @@ sub runtftpserver {
1111
1138
# check for pidfile
1112
1139
my $pidfile = $TFTPPIDFILE ;
1113
1140
my $ip =$HOSTIP ;
1114
- my $nameext ;
1115
1141
my $cmd ;
1142
+ my $proto = ' tftp' ;
1143
+ my $ipvnum = 4;
1144
+ my $idnum = ($id && ($id =~ / ^(\d +)$ / ) && ($id > 1)) ? $id : 1;
1145
+ my $srvrname ;
1116
1146
1117
1147
if ($ipv6 ) {
1118
1148
# if IPv6, use a different setup
1149
+ $ipvnum = 6;
1119
1150
$pidfile = $TFTP6PIDFILE ;
1120
1151
$port = $TFTP6PORT ;
1121
1152
$ip = $HOST6IP ;
1122
- $nameext =" -ipv6" ;
1123
1153
}
1124
1154
1125
1155
# don't retry if the server doesn't work
1126
1156
if ($doesntrun {$pidfile }) {
1127
1157
return (0,0);
1128
1158
}
1129
1159
1160
+ $srvrname = servername_str($proto , $ipvnum , $idnum );
1161
+
1130
1162
my $pid = processexists($pidfile );
1131
1163
if ($pid > 0) {
1132
1164
stopserver($pid );
@@ -1136,8 +1168,8 @@ sub runtftpserver {
1136
1168
# start our server:
1137
1169
my $flag =$debugprotocol ?" -v " :" " ;
1138
1170
$flag .= " -s \" $srcdir \" " ;
1139
- if ($id ) {
1140
- $flag .=" --id $id " ;
1171
+ if ($idnum > 1 ) {
1172
+ $flag .=" --id $idnum " ;
1141
1173
}
1142
1174
if ($ipv6 ) {
1143
1175
$flag .=" --ipv6 " ;
@@ -1148,7 +1180,7 @@ sub runtftpserver {
1148
1180
1149
1181
if ($tftppid <= 0 || !kill (0, $tftppid )) {
1150
1182
# it is NOT alive
1151
- logmsg " RUN: failed to start the TFTP $id$nameext server\n " ;
1183
+ logmsg " RUN: failed to start the $srvrname server\n " ;
1152
1184
stopserver(" $pid2 " );
1153
1185
displaylogs($testnumcheck );
1154
1186
$doesntrun {$pidfile } = 1;
@@ -1158,7 +1190,7 @@ sub runtftpserver {
1158
1190
# Server is up. Verify that we can speak to it.
1159
1191
my $pid3 = verifyserver(" tftp" , $ip , $port );
1160
1192
if (!$pid3 ) {
1161
- logmsg " RUN: TFTP $id$nameext server failed verification\n " ;
1193
+ logmsg " RUN: $srvrname server failed verification\n " ;
1162
1194
# failed to talk to it properly. Kill the server and return failure
1163
1195
stopserver(" $tftppid $pid2 " );
1164
1196
displaylogs($testnumcheck );
@@ -1168,7 +1200,7 @@ sub runtftpserver {
1168
1200
$pid2 = $pid3 ;
1169
1201
1170
1202
if ($verbose ) {
1171
- logmsg " RUN: TFTP $id$nameext server is now running PID $tftppid \n " ;
1203
+ logmsg " RUN: $srvrname server is now running PID $tftppid \n " ;
1172
1204
}
1173
1205
1174
1206
sleep (1);
@@ -1186,12 +1218,18 @@ sub runsshserver {
1186
1218
my $port = $SSHPORT ;
1187
1219
my $socksport = $SOCKSPORT ;
1188
1220
my $pidfile = $SSHPIDFILE ;
1221
+ my $proto = ' ssh' ;
1222
+ my $ipvnum = 4;
1223
+ my $idnum = ($id && ($id =~ / ^(\d +)$ / ) && ($id > 1)) ? $id : 1;
1224
+ my $srvrname ;
1189
1225
1190
1226
# don't retry if the server doesn't work
1191
1227
if ($doesntrun {$pidfile }) {
1192
1228
return (0,0);
1193
1229
}
1194
1230
1231
+ $srvrname = servername_str($proto , $ipvnum , $idnum );
1232
+
1195
1233
my $pid = processexists($pidfile );
1196
1234
if ($pid > 0) {
1197
1235
stopserver($pid );
@@ -1210,7 +1248,7 @@ sub runsshserver {
1210
1248
1211
1249
if ($sshpid <= 0 || !kill (0, $sshpid )) {
1212
1250
# it is NOT alive
1213
- logmsg " RUN: failed to start the SSH server\n " ;
1251
+ logmsg " RUN: failed to start the $srvrname server\n " ;
1214
1252
stopserver(" $pid2 " );
1215
1253
$doesntrun {$pidfile } = 1;
1216
1254
return (0,0);
@@ -1222,7 +1260,7 @@ sub runsshserver {
1222
1260
1223
1261
my $pid3 = verifyserver(" ssh" ,$ip ,$port );
1224
1262
if (!$pid3 ) {
1225
- logmsg " RUN: SSH server failed verification\n " ;
1263
+ logmsg " RUN: $srvrname server failed verification\n " ;
1226
1264
# failed to fetch server pid. Kill the server and return failure
1227
1265
stopserver(" $sshpid $pid2 " );
1228
1266
$doesntrun {$pidfile } = 1;
@@ -1247,7 +1285,7 @@ sub runsshserver {
1247
1285
}
1248
1286
1249
1287
if ($verbose ) {
1250
- logmsg " RUN: SSH server is now running PID $pid2 \n " ;
1288
+ logmsg " RUN: $srvrname server is now running PID $pid2 \n " ;
1251
1289
}
1252
1290
1253
1291
return ($pid2 , $sshpid );
@@ -1261,12 +1299,18 @@ sub runsocksserver {
1261
1299
my $ip =$HOSTIP ;
1262
1300
my $port = $SOCKSPORT ;
1263
1301
my $pidfile = $SOCKSPIDFILE ;
1302
+ my $proto = ' socks' ;
1303
+ my $ipvnum = 4;
1304
+ my $idnum = ($id && ($id =~ / ^(\d +)$ / ) && ($id > 1)) ? $id : 1;
1305
+ my $srvrname ;
1264
1306
1265
1307
# don't retry if the server doesn't work
1266
1308
if ($doesntrun {$pidfile }) {
1267
1309
return (0,0);
1268
1310
}
1269
1311
1312
+ $srvrname = servername_str($proto , $ipvnum , $idnum );
1313
+
1270
1314
my $pid = processexists($pidfile );
1271
1315
if ($pid > 0) {
1272
1316
stopserver($pid );
0 commit comments