@@ -777,6 +777,38 @@ The following values will fail, causing compilation to abort:
777
777
778
778
779
779
780
+ - * Type* : statement
781
+
782
+ validate_augeas
783
+ --------------
784
+ Perform validation of a string using an Augeas lens
785
+ The first argument of this function should be a string to
786
+ test, and the second argument should be the name of the Augeas lens to use.
787
+ If Augeas fails to parse the string with the lens, the compilation will
788
+ abort with a parse error.
789
+
790
+ A third argument can be specified, listing paths which should
791
+ not be found in the file. The ` $file ` variable points to the location
792
+ of the temporary file being tested in the Augeas tree.
793
+
794
+ For example, if you want to make sure your passwd content never contains
795
+ a user ` foo ` , you could write:
796
+
797
+ validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
798
+
799
+ Or if you wanted to ensure that no users used the '/bin/barsh' shell,
800
+ you could use:
801
+
802
+ validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']
803
+
804
+ If a fourth argument is specified, this will be the error message raised and
805
+ seen by the user.
806
+
807
+ A helpful error message can be returned like this:
808
+
809
+ validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
810
+
811
+
780
812
- * Type* : statement
781
813
782
814
validate_bool
@@ -799,6 +831,29 @@ The following values will fail, causing compilation to abort:
799
831
800
832
801
833
834
+ - * Type* : statement
835
+
836
+
837
+ validate_cmd
838
+ -------------
839
+ Perform validation of a string with an external command.
840
+ The first argument of this function should be a string to
841
+ test, and the second argument should be a path to a test command
842
+ taking a file as last argument. If the command, launched against
843
+ a tempfile containing the passed string, returns a non-null value,
844
+ compilation will abort with a parse error.
845
+
846
+ If a third argument is specified, this will be the error message raised and
847
+ seen by the user.
848
+
849
+ A helpful error message can be returned like this:
850
+
851
+ Example:
852
+
853
+ validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
854
+
855
+
856
+
802
857
- * Type* : statement
803
858
804
859
validate_hash
0 commit comments