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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211102224041.5105-1-rdunlap@infradead.org>
Date:   Tue,  2 Nov 2021 15:40:41 -0700
From:   Randy Dunlap <rdunlap@...radead.org>
To:     linux-kernel@...r.kernel.org
Cc:     Randy Dunlap <rdunlap@...radead.org>,
        Masahiro Yamada <masahiroy@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        linux-kbuild@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>,
        Nicolas Schier <nicolas@...sle.eu>
Subject: [PATCH v2] scripts/config: allow "O=config-dir" option

Support "O=config-dir" as the location of the .config file
like (some) other kernel build (make) tools do.

Also check for the existence of the config-dir/config-file
and report if there is no such file instead of letting grep
report that there is no such file.

Signed-off-by: Randy Dunlap <rdunlap@...radead.org>
Cc: Masahiro Yamada <masahiroy@...nel.org>
Cc: Nick Desaulniers <ndesaulniers@...gle.com>
Cc: linux-kbuild@...r.kernel.org
Cc: Andi Kleen <ak@...ux.intel.com>
Reviewed-by: Nicolas Schier <nicolas@...sle.eu>
---
v2:
- use 'shellcheck' and other recommendations from Nicolas
- move one comment from the commit description to under the "---" line

Someone asked for this "feature" a few months ago but I don't
recall who it was.

 scripts/config |   44 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 5 deletions(-)

--- linux-next-20211102.orig/scripts/config
+++ linux-next-20211102/scripts/config
@@ -37,6 +37,7 @@ commands:
 
 options:
 	--file config-file   .config file to change (default .config)
+	O=config-dir         Specify the directory location of the config-file
 	--keep-case|-k       Keep next symbols' case (dont' upper-case it)
 
 $myname doesn't check the validity of the .config file. This is done at next
@@ -124,15 +125,48 @@ undef_var() {
 	txt_delete "^# $name is not set" "$FN"
 }
 
-if [ "$1" = "--file" ]; then
-	FN="$2"
-	if [ "$FN" = "" ] ; then
+DIR=
+FN=
+
+while [ "$DIR" = "" ] || [ "$FN" = "" ]; do
+
+	if [ "$1" = "" ] ; then
 		usage
 	fi
-	shift 2
-else
+	if [ "$1" = "--file" ]; then
+		FN="$2"
+		if [ "$FN" = "" ] ; then
+			usage
+		fi
+		shift 2
+		continue
+	fi
+
+	optn=$1
+	optnlen=${#optn}
+	if [ "$optnlen" -gt 1 ] && [ "${optn:0:2}" = "O=" ]; then
+		DIR=${optn:2}
+		shift
+		if [ "$DIR" = "" ]; then
+			usage
+		fi
+		continue
+	fi
+	break	# something other than --file or O=dir
+done
+
+if [ "$FN" = "" ]; then
 	FN=.config
 fi
+if [ "$DIR" != "" ]; then
+	DIR=$DIR"/"
+fi
+FN="${DIR}${FN}"
+
+if [ ! -r "$FN" ]; then
+	echo "No such config file: $FN"
+	exit
+fi
 
 if [ "$1" = "" ] ; then
 	usage

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ