@@ -5,11 +5,13 @@ BEGIN {
5
5
$basedir = $0 ;
6
6
$basedir =~ s | (.*)/[^/]*| $1 | ;
7
7
8
- $test_count = 38;
8
+ $test_count_ipv4 = 34;
9
+ $test_count_ipv6 = 4;
9
10
10
11
$test_ipsec = 0;
11
12
if ( system (" ip xfrm policy help 2>&1 | grep -q ctx" ) eq 0 ) {
12
- $test_count += 8;
13
+ $test_count_ipv4 += 4;
14
+ $test_count_ipv6 += 4;
13
15
$test_ipsec = 1;
14
16
}
15
17
@@ -23,10 +25,17 @@ BEGIN {
23
25
24
26
$rc = ` $basedir /../kvercmp $kvercur $kverminstream ` ;
25
27
if ( $netlabelctl gt " 021" and $rc > 0 ) {
26
- $test_count += 3;
28
+ $test_count_ipv6 += 3;
27
29
$test_calipso_stream = 1;
28
30
}
29
31
32
+ $test_count = $test_count_ipv4 ;
33
+ $test_ipv6 = 0;
34
+ if ( system (" test -f /proc/net/if_inet6" ) eq 0 ) {
35
+ $test_count += $test_count_ipv6 ;
36
+ $test_ipv6 = 1;
37
+ }
38
+
30
39
plan tests => $test_count ;
31
40
}
32
41
@@ -298,16 +307,6 @@ if ($test_ipsec) {
298
307
" runcon -t test_inet_bad_client_t -- $basedir /client stream 127.0.0.1 65535 2>&1" ;
299
308
ok( $result >> 8 eq 5 );
300
309
301
- # Verify that authorized client can communicate with the server.
302
- $result =
303
- system " runcon -t test_inet_client_t $basedir /client stream ::1 65535" ;
304
- ok( $result eq 0 );
305
-
306
- # Verify that unauthorized client cannot communicate with the server.
307
- $result = system
308
- " runcon -t test_inet_bad_client_t -- $basedir /client stream ::1 65535 2>&1" ;
309
- ok( $result >> 8 eq 5 );
310
-
311
310
# Kill the server.
312
311
server_end($pid );
313
312
@@ -325,24 +324,50 @@ if ($test_ipsec) {
325
324
" runcon -t test_inet_bad_client_t -- $basedir /client dgram 127.0.0.1 65535 2>&1" ;
326
325
ok( $result >> 8 eq 8 );
327
326
328
- # Verify that unauthorized client cannot communicate with the server.
329
- $result = system
330
- " runcon -t test_inet_bad_client_t -- $basedir /client dgram ::1 65535 2>&1" ;
331
- ok( $result >> 8 eq 8 );
332
-
333
327
# Kill the server.
334
328
server_end($pid );
335
329
336
- # Start the dgram server for IPSEC test using IPv6 but do not request peer context.
337
- $pid = server_start( " -t test_inet_server_t" , " -n dgram 65535" );
330
+ if ($test_ipv6 ) {
338
331
339
- # This test now passes.
340
- $result = system
341
- " runcon -t test_inet_client_t $basedir /client -e nopeer dgram ::1 65535" ;
342
- ok( $result eq 0 );
332
+ # Start the IPv6 stream server.
333
+ $pid = server_start( " -t test_inet_server_t" , " -6 stream 65535" );
343
334
344
- # Kill the server.
345
- server_end($pid );
335
+ # Verify that authorized client can communicate with the server.
336
+ $result = system
337
+ " runcon -t test_inet_client_t $basedir /client stream ::1 65535" ;
338
+ ok( $result eq 0 );
339
+
340
+ # Verify that unauthorized client cannot communicate with the server.
341
+ $result = system
342
+ " runcon -t test_inet_bad_client_t -- $basedir /client stream ::1 65535 2>&1" ;
343
+ ok( $result >> 8 eq 5 );
344
+
345
+ # Kill the server.
346
+ server_end($pid );
347
+
348
+ # Start the IPv6 dgram server.
349
+ $pid = server_start( " -t test_inet_server_t" , " -6 dgram 65535" );
350
+
351
+ # Verify that unauthorized client cannot communicate with the server.
352
+ $result = system
353
+ " runcon -t test_inet_bad_client_t -- $basedir /client dgram ::1 65535 2>&1" ;
354
+ ok( $result >> 8 eq 8 );
355
+
356
+ # Kill the server.
357
+ server_end($pid );
358
+
359
+ # Start the dgram server for IPSEC test using IPv6 but do not request
360
+ # peer context.
361
+ $pid = server_start( " -t test_inet_server_t" , " -6n dgram 65535" );
362
+
363
+ # This test now passes.
364
+ $result = system
365
+ " runcon -t test_inet_client_t $basedir /client -e nopeer dgram ::1 65535" ;
366
+ ok( $result eq 0 );
367
+
368
+ # Kill the server.
369
+ server_end($pid );
370
+ }
346
371
347
372
# Flush IPSEC configuration.
348
373
system " /bin/sh $basedir /ipsec-flush" ;
@@ -364,16 +389,6 @@ $result = system
364
389
" runcon -t test_inet_bad_client_t -- $basedir /client -e nopeer stream 127.0.0.1 65535 2>&1" ;
365
390
ok( $result >> 8 eq 5 );
366
391
367
- # Verify that authorized client can communicate with the server.
368
- $result = system
369
- " runcon -t test_inet_client_t -- $basedir /client -e nopeer stream ::1 65535" ;
370
- ok( $result eq 0 );
371
-
372
- # Verify that unauthorized client cannot communicate with the server.
373
- $result = system
374
- " runcon -t test_inet_bad_client_t -- $basedir /client -e nopeer stream ::1 65535 2>&1" ;
375
- ok( $result >> 8 eq 5 );
376
-
377
392
# Kill the server.
378
393
server_end($pid );
379
394
@@ -390,41 +405,69 @@ $result = system
390
405
" runcon -t test_inet_bad_client_t -- $basedir /client -e nopeer dgram 127.0.0.1 65535 2>&1" ;
391
406
ok( $result >> 8 eq 8 );
392
407
393
- # Verify that authorized client can communicate with the server.
394
- $result = system
395
- " runcon -t test_inet_client_t $basedir /client -e nopeer dgram ::1 65535" ;
396
- ok( $result eq 0 );
408
+ # Kill the server.
409
+ server_end($pid );
397
410
398
- # Verify that unauthorized client cannot communicate with the server.
399
- $result = system
411
+ if ($test_ipv6 ) {
412
+
413
+ # Start the IPv6 stream server.
414
+ $pid = server_start( " -t test_inet_server_t" , " -6n stream 65535" );
415
+
416
+ # Verify that authorized client can communicate with the server.
417
+ $result = system
418
+ " runcon -t test_inet_client_t -- $basedir /client -e nopeer stream ::1 65535" ;
419
+ ok( $result eq 0 );
420
+
421
+ # Verify that unauthorized client cannot communicate with the server.
422
+ $result = system
423
+ " runcon -t test_inet_bad_client_t -- $basedir /client -e nopeer stream ::1 65535 2>&1" ;
424
+ ok( $result >> 8 eq 5 );
425
+
426
+ # Kill the server.
427
+ server_end($pid );
428
+
429
+ # Start the IPv6 dgram server.
430
+ $pid = server_start( " -t test_inet_server_t" , " -6n dgram 65535" );
431
+
432
+ # Verify that authorized client can communicate with the server.
433
+ $result = system
434
+ " runcon -t test_inet_client_t $basedir /client -e nopeer dgram ::1 65535" ;
435
+ ok( $result eq 0 );
436
+
437
+ # Verify that unauthorized client cannot communicate with the server.
438
+ $result = system
400
439
" runcon -t test_inet_bad_client_t -- $basedir /client -e nopeer dgram ::1 65535 2>&1" ;
401
- ok( $result >> 8 eq 8 );
440
+ ok( $result >> 8 eq 8 );
402
441
403
- # Kill the server.
404
- server_end($pid );
442
+ # Kill the server.
443
+ server_end($pid );
444
+ }
405
445
406
446
# Flush iptables configuration.
407
447
system " /bin/sh $basedir /iptables-flush" ;
408
448
409
- if ($ test_calipso_stream ) {
449
+ if ( $test_ipv6 and $ test_calipso_stream ) {
410
450
411
451
# Load NetLabel configuration for CALIPSO/IPv6 labeling over loopback.
412
452
system " /bin/sh $basedir /calipso-load" ;
413
453
414
454
# Start the stream server.
415
- $pid = server_start( " -t test_inet_server_t -l s0:c0.c10" , " stream 65535" );
455
+ $pid =
456
+ server_start( " -t test_inet_server_t -l s0:c0.c10" , " -6 stream 65535" );
416
457
417
458
# Verify that authorized client can communicate with the server.
418
459
$result = system
419
460
" runcon -t test_inet_client_t -l s0:c0.c10 $basedir /client -e system_u:object_r:netlabel_peer_t:s0:c0.c10 stream ::1 65535" ;
420
461
ok( $result eq 0 );
421
462
422
- # Verify that authorized client can communicate with the server using different valid level.
463
+ # Verify that authorized client can communicate with the server using
464
+ # different valid level.
423
465
$result = system
424
466
" runcon -t test_inet_client_t -l s0:c8.c10 $basedir /client -e system_u:object_r:netlabel_peer_t:s0:c8.c10 stream ::1 65535" ;
425
467
ok( $result eq 0 );
426
468
427
- # Verify that authorized client cannot communicate with the server using invalid level.
469
+ # Verify that authorized client cannot communicate with the server using
470
+ # invalid level.
428
471
$result = system
429
472
" runcon -t test_inet_client_t -l s0:c8.c12 -- $basedir /client stream ::1 65535 2>&1" ;
430
473
ok( $result >> 8 eq 5 );
0 commit comments