24
24
import json
25
25
from tests_utils import *
26
26
27
- def test_cwd_relative ():
28
- conf = base_config ()
29
- conf ['process' ]['args' ] = ['./init' , 'echo' , 'hello' ]
30
- conf ['process' ]['cwd' ] = "/sbin"
31
- add_all_namespaces (conf )
32
- try :
33
- out , _ = run_and_get_output (conf )
34
- if "hello" not in str (out ):
35
- return - 1
36
- except Exception as e :
37
- return - 1
38
- return 0
39
-
40
- def test_cwd_relative_subdir ():
41
- conf = base_config ()
42
- conf ['process' ]['args' ] = ['sbin/init' , 'echo' , 'hello' ]
43
- conf ['process' ]['cwd' ] = "/"
44
- add_all_namespaces (conf )
45
- try :
46
- out , _ = run_and_get_output (conf )
47
- if "hello" not in str (out ):
48
- return - 1
49
- except :
50
- return - 1
51
- return 0
52
-
53
- def test_cwd_not_exist ():
54
- conf = base_config ()
55
- conf ['process' ]['args' ] = ['/init' , 'true' ]
56
- conf ['process' ]['cwd' ] = "/doesnotexist"
57
- add_all_namespaces (conf )
58
- try :
59
- run_and_get_output (conf )
60
- except :
61
- return - 1
62
- return 0
63
-
64
- def test_cwd_absolute ():
65
- conf = base_config ()
66
- conf ['process' ]['args' ] = ['/init' , 'echo' , 'hello' ]
67
- conf ['process' ]['cwd' ] = "/sbin"
68
- add_all_namespaces (conf )
69
- try :
70
- out , _ = run_and_get_output (conf )
71
- if "hello" not in str (out ):
72
- return - 1
73
- except :
74
- return - 1
75
- return 0
76
-
77
27
def test_not_allowed_ipc_sysctl ():
78
28
if is_rootless ():
79
29
return 77
@@ -556,6 +506,21 @@ def test_invalid_id():
556
506
return - 1
557
507
return 0
558
508
509
+ def test_home_unknown_id ():
510
+ if is_rootless ():
511
+ return 77
512
+
513
+ conf = base_config ()
514
+ conf ['process' ]['args' ] = ['/init' , 'printenv' , "HOME" ]
515
+ conf ['process' ]['user' ]['uid' ] = 101010
516
+ conf ['process' ]['user' ]['gid' ] = 101010
517
+ add_all_namespaces (conf )
518
+ out , _ = run_and_get_output (conf )
519
+ if out != "/" :
520
+ sys .stderr .write ("expected: `/`, got output: `%s`\n " % out )
521
+ return - 1
522
+ return 0
523
+
559
524
all_tests = {
560
525
"start" : test_start ,
561
526
"start-override-config" : test_start_override_config ,
@@ -565,10 +530,6 @@ def test_invalid_id():
565
530
"sd-notify-env" : test_sd_notify_env ,
566
531
"sd-notify-proxy" : test_sd_notify_proxy ,
567
532
"listen_pid_env" : test_listen_pid_env ,
568
- "cwd-relative" : test_cwd_relative ,
569
- "cwd-relative-subdir" : test_cwd_relative_subdir ,
570
- "cwd-absolute" : test_cwd_absolute ,
571
- "cwd-not-exist" : test_cwd_not_exist ,
572
533
"empty-home" : test_empty_home ,
573
534
"delete-in-created-state" : test_delete_in_created_state ,
574
535
"run-rootless-netns-with-userns" : test_run_rootless_netns_with_userns ,
@@ -579,6 +540,7 @@ def test_invalid_id():
579
540
"ioprio" : test_ioprio ,
580
541
"run-keep" : test_run_keep ,
581
542
"invalid-id" : test_invalid_id ,
543
+ "home-unknown-id" : test_home_unknown_id ,
582
544
}
583
545
584
546
if __name__ == "__main__" :
0 commit comments