]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move away from backticks, and use %exec()
authorAlan T. DeKok <aland@freeradius.org>
Mon, 30 Oct 2023 13:25:45 +0000 (09:25 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 30 Oct 2023 18:10:48 +0000 (14:10 -0400)
It looks harder to use.  Instead of passing one string which is
then split by exec, we pass multiple strings as function arguments.

However, this is likely safer, too.

src/tests/modules/exec/backticks_list.unlang
src/tests/modules/exec/module.conf
src/tests/modules/linelog/linelog.unlang
src/tests/modules/linelog/module.conf

index e946b5e7da02a4d433b0362978908336c7e25105..bb1261718fdc7ff99830b03f8c511bcff7acef5b 100644 (file)
@@ -2,7 +2,7 @@
 #  Sync calls should always return a zero length string
 #  because we don't wait for the response.
 #
-&Tmp-String-0 := `/bin/sh -c 'echo hello'`
+&Tmp-String-0 := %exec('/bin/sh', '-c', 'echo hello')
 if (&Tmp-String-0 != 'hello') {
        test_fail
 } else {
@@ -12,7 +12,7 @@ if (&Tmp-String-0 != 'hello') {
 #
 #  @todo - list over-rides are not allowed!
 #
-&control += `/bin/sh -c "echo Reply-Message := \'hello\'"`
+&control += %exec('/bin/sh', '-c', "echo Reply-Message := \'hello\'")
 
 if (&control.Reply-Message != 'hello') {
        test_fail
index c4fcd49ad6dbcabf5a3f0541a93031e2cfd98363..9e4382b9958cdd04ed4898cf0b9278fa86c5c80f 100644 (file)
@@ -1,3 +1,10 @@
+exec {
+       wait = yes
+       input_pairs = &request
+       shell_escape = yes
+       timeout = 10
+}
+
 exec exec_async {
        wait = no
        input_pairs = &request
index 99ff5d5da507401413a49cd4cc505391ec4e6841..723ff1976d30b5f368b6dbafa807c067d016827d 100644 (file)
@@ -273,7 +273,7 @@ else {
        test_fail
 }
 
-&Tmp-Integer-0 := `/bin/sh -c "wc -l < $ENV{MODULE_TEST_DIR}/test_e.log"`
+&Tmp-Integer-0 := %exec('/bin/sh', '-c', "wc -l < $ENV{MODULE_TEST_DIR}/test_e.log")
 
 if (&Tmp-Integer-0 == 3) {
        test_pass
index 5eebcd63871e6afeb1914b4c81c466c9c95f14f7..eae06742c5a76d3767c43b162bbd3d3efc3d164f 100644 (file)
@@ -140,3 +140,10 @@ linelog linelog_ref_multi {
                test_empty = &control.User-Name[*]
        }
 }
+
+exec {
+       wait = yes
+       input_pairs = &request
+       shell_escape = yes
+       timeout = 10
+}