lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20221212172533.184db5e6@gandalf.local.home>
Date:   Mon, 12 Dec 2022 17:25:33 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     LKML <linux-kernel@...r.kernel.org>
Cc:     John 'Warthog9' Hawley <warthog9@...nel.org>
Subject: [for-next] ktest.pl: One more change I had in store for 6.2


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest.git
for-next

Head SHA1: 88a51b4f2e65ca4378a81ff0925fad076e82e177


Steven Rostedt (Google) (1):
      ktest.pl: Add shell commands to variables

----
 tools/testing/ktest/ktest.pl    | 9 ++++++++-
 tools/testing/ktest/sample.conf | 8 ++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
---------------------------
commit 88a51b4f2e65ca4378a81ff0925fad076e82e177
Author: Steven Rostedt (Google) <rostedt@...dmis.org>
Date:   Wed Dec 7 21:29:44 2022 -0500

    ktest.pl: Add shell commands to variables
    
    Allow variables to execute shell commands. Note, these are processed when
    they are first seen while parsing the config file. This is useful if you
    have the same config file used for multiple hosts (as they may be in a git
    repository).
    
     HOSTNAME := ${shell hostname}
     DEFAULTS IF "${HOSTNAME}" == "frodo"
    
    Link: https://lkml.kernel.org/r/20221207212944.277ee850@gandalf.local.home
    
    Signed-off-by: Steven Rostedt (Google) <rostedt@...dmis.org>

diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 1737c59e4ff6..ac59999ed3de 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -802,7 +802,14 @@ sub process_variables {
 	my $end = $3;
 	# append beginning of value to retval
 	$retval = "$retval$begin";
-	if (defined($variable{$var})) {
+	if ($var =~ s/^shell\s+//) {
+	    $retval = `$var`;
+	    if ($?) {
+		doprint "WARNING: $var returned an error\n";
+	    } else {
+		chomp $retval;
+	    }
+	} elsif (defined($variable{$var})) {
 	    $retval = "$retval$variable{$var}";
 	} elsif (defined($remove_undef) && $remove_undef) {
 	    # for if statements, any variable that is not defined,
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index 5e7d1d729752..2d0fe15a096d 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -259,6 +259,14 @@
 # If PATH is not a config variable, then the ${PATH} in
 # the MAKE_CMD option will be evaluated by the shell when
 # the MAKE_CMD option is passed into shell processing.
+#
+# Shell commands can also be inserted with the ${shell <command>}
+# expression. Note, this is case sensitive, thus ${SHELL <command>}
+# will not work.
+#
+# HOSTNAME := ${shell hostname}
+# DEFAULTS IF "${HOSTNAME}" == "frodo"
+#
 
 #### Using options in other options ####
 #

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ