]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update test and docs in preparation for removing '&'
authorAlan T. DeKok <aland@freeradius.org>
Sat, 18 Jan 2025 20:45:25 +0000 (15:45 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 18 Jan 2025 20:45:49 +0000 (15:45 -0500)
doc/antora/modules/reference/pages/raddb/mods-available/echo.adoc
raddb/mods-available/echo
src/tests/modules/exec/module.conf

index 8e46a3ba2bcce3335185d6902a0c76d0c349c9cd..f3fc5446752b88e974b3323ba8b550978246c477 100644 (file)
@@ -58,6 +58,38 @@ arguments.
 Dynamic translation is done on this field, so things like
 the following example will work.
 
+The example program below has a few important features
+which should be noted:
+
+  * The string for the program name uses triple quotes.
+  These allow the text inside of the string to contain
+  double-quote characters without needing to escape
+  them.  This doesn't affect the output string, but it
+  does make the configuration easier to read.
+
+  * The argument to "/bin/echo" is a double-quoted string.
+  That is, the attribute name, operator, and value are
+  passed to "echo" as one argument.  If the parameters to
+  the "echo" command were not quoted, then they would be
+  passed as three separate arguments.
+
+  * The attribute value is surrounded by single quotes.
+  These single quotes are inside of the single argument
+  to the "echo" command.
+
+  * If instead the "echo" command was passed three separate
+  arguments, then the attribute value would be printed
+  _without_ the quotes.  Because quoting an argument to
+  a command results in the _unquoted_ string being passed
+  to the command, as the argument.
+
+The summary of all of the above is that when printing
+attributes it's usually easier to run one shell script with
+no arguments.  That shell script can then print the
+attribute names, operators, and values.
+
+Any string values should also be quoted.
+
 
 
 input_pairs:: The attributes which are placed into the
@@ -115,7 +147,7 @@ thereby saving resources.
 ```
 exec echo {
        wait = yes
-       program = "/bin/echo Filter-Id := %{User-Name}"
+       program = """/bin/echo "Filter-Id := '%{User-Name}'" """
        input_pairs = &request
        output_pairs = &reply
        shell_escape = yes
index 6ba4c3d6be9d1be997087bb14c967d87c04a8460..08ce8fe386f20315474b0919b67e7d283a0522b0 100644 (file)
@@ -63,7 +63,39 @@ exec echo {
        #  Dynamic translation is done on this field, so things like
        #  the following example will work.
        #
-       program = "/bin/echo Filter-Id := %{User-Name}"
+       #  The example program below has a few important features
+       #  which should be noted:
+       #
+       #  * The string for the program name uses triple quotes.
+       #    These allow the text inside of the string to contain
+       #    double-quote characters without needing to escape
+       #    them.  This doesn't affect the output string, but it
+       #    does make the configuration easier to read.
+       #
+       #  * The argument to "/bin/echo" is a double-quoted string.
+       #    That is, the attribute name, operator, and value are
+       #    passed to "echo" as one argument.  If the parameters to
+       #    the "echo" command were not quoted, then they would be
+       #    passed as three separate arguments.
+       #
+       #  * The attribute value is surrounded by single quotes.
+       #    These single quotes are inside of the single argument
+       #    to the "echo" command.
+       #
+       #  * If instead the "echo" command was passed three separate
+       #    arguments, then the attribute value would be printed
+       #    _without_ the quotes.  Because quoting an argument to
+       #    a command results in the _unquoted_ string being passed
+       #    to the command, as the argument.
+       #
+       #  The summary of all of the above is that when printing
+       #  attributes it's usually easier to run one shell script with
+       #  no arguments.  That shell script can then print the
+       #  attribute names, operators, and values.
+       #
+       #  Any string values should also be quoted.
+       #
+       program = """/bin/echo "Filter-Id := '%{User-Name}'" """
 
        #
        #  input_pairs:: The attributes which are placed into the
index 06d17a8225e41eb251783bac7092bd5b72f6c1c1..2bfbe6d844b9d71e32bfa901fb1fa7e9827e86b5 100644 (file)
@@ -17,7 +17,7 @@ exec exec_async_mod {
        input_pairs = &request
        shell_escape = yes
        timeout = 10
-       program = "/bin/sh -c 'echo \'Called-Station-Id = welcome\''"
+       program = '''/bin/sh -c "echo \"Called-Station-Id = 'welcome'\" " '''
 }
 
 exec exec_sync {
@@ -33,7 +33,7 @@ exec exec_sync_mod {
        output_pairs = &control
        shell_escape = yes
        timeout = 10
-       program = "/bin/sh -c 'echo \'Called-Station-Id = welcome\''"
+       program = '''/bin/sh -c "echo \"Called-Station-Id = 'welcome'\" " '''
 }
 
 exec exec_sync_attrs {