Forum: CFEngine Help
Subject: Re: Trying to use a variable inside a regex
Author: daveseff
Link to topic: https://cfengine.com/forum/read.php?3,27490,27536#msg-27536

Yes. Silly me. I did actually get my library function to work properly. 



bundle agent set_selinux_boolean(s, i){

classes:
  "BOOL_OFF"  expression => strcmp("$(i)", "off");
  "BOOL_ON"   expression => strcmp("$(i)", "on");
  "sebooloff" expression => regcmp(".*off$", execresult("/usr/sbin/getsebool 
$(s)", "noshell"));
  "seboolon"  expression => regcmp(".*on$", execresult("/usr/sbin/getsebool 
$(s)", "noshell"));

reports:

   sebooloff.BOOL_ON::
      "$(s) is off. Lets turn it on.";
   seboolon.BOOL_OFF::
      "$(s) is on. Let's turn it off.";

commands:

   sebooloff.BOOL_ON::
      "/usr/sbin/setsebool -P $(s) on";
   seboolon.BOOL_OFF::
      "/usr/sbin/setsebool -P $(s) off";

}


_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to