Skip to content

Commit d479df6

Browse files
committed
Merge pull request #132 from raphink/dev/missing_doc
Add missing documentation for validate_augeas and validate_cmd to README.markdown
2 parents 9a06f11 + a1510a1 commit d479df6

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

README.markdown

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,38 @@ The following values will fail, causing compilation to abort:
777777

778778

779779

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+
780812
- *Type*: statement
781813

782814
validate_bool
@@ -799,6 +831,29 @@ The following values will fail, causing compilation to abort:
799831

800832

801833

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+
802857
- *Type*: statement
803858

804859
validate_hash

0 commit comments

Comments
 (0)