Skip to content

Add missing documentation for validate_augeas and validate_cmd to README.markdown #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,38 @@ The following values will fail, causing compilation to abort:



- *Type*: statement

validate_augeas
--------------
Perform validation of a string using an Augeas lens
The first argument of this function should be a string to
test, and the second argument should be the name of the Augeas lens to use.
If Augeas fails to parse the string with the lens, the compilation will
abort with a parse error.

A third argument can be specified, listing paths which should
not be found in the file. The `$file` variable points to the location
of the temporary file being tested in the Augeas tree.

For example, if you want to make sure your passwd content never contains
a user `foo`, you could write:

validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])

Or if you wanted to ensure that no users used the '/bin/barsh' shell,
you could use:

validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']

If a fourth argument is specified, this will be the error message raised and
seen by the user.

A helpful error message can be returned like this:

validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')


- *Type*: statement

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



- *Type*: statement


validate_cmd
-------------
Perform validation of a string with an external command.
The first argument of this function should be a string to
test, and the second argument should be a path to a test command
taking a file as last argument. If the command, launched against
a tempfile containing the passed string, returns a non-null value,
compilation will abort with a parse error.

If a third argument is specified, this will be the error message raised and
seen by the user.

A helpful error message can be returned like this:

Example:

validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')



- *Type*: statement

validate_hash
Expand Down