1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
START_MARKER 
 
dnl --- Security 
 
cond([[ __builtin["security"] ]],[[ 
test_true([[ 
#pike 7.4 
functionp(call_with_creds)]]) 
test_true([[ 
#pike 7.4 
functionp(get_current_creds)]]) 
test_true([[ 
#pike 7.4 
functionp(get_object_creds)]]) 
 
test_do([[ rm("security"); ]]) 
test_do([[ 
  object c = Pike.Security.Creds(class{}(), Pike.Security.BIT_SECURITY, 0); 
  Pike.Security.call_with_creds(c, lambda() { 
    Stdio.File("security", "cwt"); }); 
  Pike.Security.call_with_creds(c, rm, "security"); 
]]) 
test_eval_error([[ 
  object c = Pike.Security.Creds(class{}(), 0, 0); 
  Pike.Security.call_with_creds(c, lambda() { 
    Stdio.File("security", "cwt"); }); 
]]) 
test_eval_error([[ 
  object c = Pike.Security.Creds(class{}(), 0, 0); 
  Pike.Security.call_with_creds(c, rm, "security"); 
]]) 
test_eval_error([[ 
  object u = class { 
    int valid_open() { return 0; } }(); 
  object c = Pike.Security.Creds(u, Pike.Security.BIT_CONDITIONAL_IO, 0); 
  Pike.Security.call_with_creds(c, lambda() { 
    Stdio.File("security", "cwt"); }); 
]]) 
test_eval_error([[ 
  object u = class { 
    int valid_open() { return 1; } }(); 
  object c = Pike.Security.Creds(u, Pike.Security.BIT_CONDITIONAL_IO, 0); 
  Pike.Security.call_with_creds(c, lambda() { 
    Stdio.File("security", "cwt")->write("x"); }); 
]]) 
test_eval_error([[ 
  object u = class { 
    int valid_open() { return 3; } }(); 
  object c = Pike.Security.Creds(u, Pike.Security.BIT_CONDITIONAL_IO, 0); 
  Pike.Security.call_with_creds(c, lambda() { 
    Stdio.File("security", "cwt"); }); 
]]) 
test_any([[ 
  object u = class { 
    int valid_open() { return 2; } }(); 
  object c = Pike.Security.Creds(u, Pike.Security.BIT_CONDITIONAL_IO, 0); 
  Pike.Security.call_with_creds(c, lambda() { 
    Stdio.File("security", "cwt"); }); 
  return rm("security"); 
]],1) 
test_false( file_stat("security") ) 
test_do( rm("security") ) 
 
define(test_call_0,[[ 
  test_any([[ 
#if constant($1) 
    array err = catch { 
      Pike.Security.call_with_creds(Pike.Security.Creds(class{}(),0,0),$1); 
    }; 
    return has_suffix(err[0], "permission denied.\n"); 
#else 
    return 1; 
#endif 
  ]], 1) 
]]) 
 
test_call_0(add_constant) 
test_call_0(exit) 
test_call_0(_exit) 
test_call_0(next_object) 
test_call_0(_next) 
test_call_0(_prev) 
test_call_0(_verify_internals) 
test_call_0(_debug) 
test_call_0(_optimizer_debug) 
test_call_0(_assembler_debug) 
test_call_0(_compiler_trace) 
test_call_0(replace_master) 
test_call_0(_reset_dmalloc) 
test_call_0(_locate_references) 
test_call_0(_describe) 
test_call_0(_gc_set_watch) 
test_call_0(_dump_backlog) 
 
test_call_0(signal) 
test_call_0(fork) 
test_call_0(kill) 
test_call_0(alarm) 
test_call_0(ualarm) 
 
]]) 
 
dnl --- Type checking 
 
typeof(`+((["":14]))) == typeof((["":14])) 
dnl test_any(return __get_return_type(__low_check_call(typeof(`+), typeof((["":14])))), typeof((["":14]))) 
dnl `+((["":14]), "") is invalid ==> 0. 
dnl test_false(__get_return_type(__low_check_call(__low_check_call(typeof(`+), typeof((["":14]))), typeof("")))) 
// typeof(`+((["":14]), "", master())) == mixed. 
test_any(return __get_return_type(__low_check_call(__low_check_call(__low_check_call(typeof(`+), typeof((["":14]))), typeof("")), typeof(master()))), 
         __get_first_arg_type(typeof(predef::intp))) 
 
END_MARKER