File: simulate_safe_functions.cf.sub

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (52 lines) | stat: -rw-r--r-- 1,703 bytes parent folder | download | duplicates (3)
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
body common control
{
  inputs => { "../plucked.cf.sub" };
}

bundle agent test
{
  vars:
    "unsafe_functions" slist => {
      "execresult",
      "execresult_as_data",
      "returnszero",
      "usemodule"
    };

    "test_1" string => execresult("touch $(sys.statedir)$(const.dirsep)execresult_safe", useshell),
      meta => { "simulate_safe" };
    "test_2" string => execresult("touch $(sys.statedir)$(const.dirsep)execresult_unsafe", useshell);
    "test_3" data => execresult_as_data("touch $(sys.statedir)$(const.dirsep)execresult_as_data_safe", useshell),
      meta => { "simulate_safe" };
    "test_4" data => execresult_as_data("touch $(sys.statedir)$(const.dirsep)execresult_as_data_unsafe", useshell);

  classes:
    "test_5" expression => returnszero("touch $(sys.statedir)$(const.dirsep)returnszero_safe", useshell),
      meta => { "simulate_safe" };
    "test_6" expression => returnszero("touch $(sys.statedir)$(const.dirsep)returnszero_unsafe", useshell);
    "test_7" expression => usemodule("usemodule_safe.sh", useshell),
      meta => { "simulate_safe" };
    "test_8" expression => usemodule("usemodule_unsafe.sh", useshell);

}

bundle agent check
{
  classes:
    "pass_$(test.unsafe_functions)" expression => not(fileexists("$(sys.statedir)$(const.dirsep)$(test.unsafe_functions)_unsafe"));
    "fail_$(test.unsafe_functions)" expression => fileexists("$(sys.statedir)$(const.dirsep)$(test.unsafe_functions)_unsafe");

  reports:
    "$(this.promise_filename) FAIL"
      if => classmatch("fail_.*");
    "$(this.promise_filename) Pass"
      if => strcmp(countclassesmatching("fail.*"), 0);
}

bundle agent __main__
{
  methods:
    "init";
    "test";
    "check";
}