From patchwork Sun Apr 12 14:34:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Martin X-Patchwork-Id: 460504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 9A6EB14027F for ; Mon, 13 Apr 2015 00:35:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=PJXd7OLl; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 68820A11E7; Sun, 12 Apr 2015 14:35:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uHogQ_Hpyxqc; Sun, 12 Apr 2015 14:35:04 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 31EA69DA0A; Sun, 12 Apr 2015 14:35:04 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 98C291C229C for ; Sun, 12 Apr 2015 14:35:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5DD6133314 for ; Sun, 12 Apr 2015 14:34:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qk9P8bPB0CaD for ; Sun, 12 Apr 2015 14:34:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by silver.osuosl.org (Postfix) with ESMTPS id 8687133312 for ; Sun, 12 Apr 2015 14:34:56 +0000 (UTC) Received: by wgso17 with SMTP id o17so57682114wgs.1 for ; Sun, 12 Apr 2015 07:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=au7Ejf2LN4pAdO2QYHZd1zRyE0tPawdJyAQKJ5wnpx8=; b=PJXd7OLlPXOLHC6gRvGbSLUHGMr/vn/VBqr5mEBOp1YDiz2Y3jm4Kv1PX6h6CoA3sq ngD9HZYXvTkWqs/DcloPecdCAoO/BlFrrmEZlgVmGLKyKUvIA+SSTivV62uJLGD6EUUT CHnaZV33NfUFc2J1PkQeGI9Kf8TJlRjbPJP8IZo6UQerzRuJ+bZtgj+V9z7ddwyBYK/e 1v2wFYP2Md3FA3RF9/eGsT8nVrLZJLLDRcjrTdK/Etzq2DxVy5qqkFeLQwd4RDwow6rZ QcIe2WwU9rW06v5NmoO1r9HL+mkjr7FslIwt2cQZsR9o/jty149/i9PcVlcXCe8MCxyT XHBA== X-Received: by 10.194.222.197 with SMTP id qo5mr19231625wjc.142.1428849295283; Sun, 12 Apr 2015 07:34:55 -0700 (PDT) Received: from bobook.localdomain (ivr94-4-82-229-165-48.fbx.proxad.net. [82.229.165.48]) by mx.google.com with ESMTPSA id pa4sm7244535wjb.11.2015.04.12.07.34.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Apr 2015 07:34:54 -0700 (PDT) From: Samuel Martin To: buildroot@buildroot.org Date: Sun, 12 Apr 2015 16:34:44 +0200 Message-Id: <1428849285-21092-3-git-send-email-s.martin49@gmail.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1428849285-21092-1-git-send-email-s.martin49@gmail.com> References: <1428849285-21092-1-git-send-email-s.martin49@gmail.com> Subject: [Buildroot] [autobuild 3/4] autobuild-run: sanitize make options X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" So far, --make-opts allows the user to override any make option or variable, especially '-C' and 'O=' which should not in the autobuild context. So, this change drop '-C' option and 'O=' and 'BR2_JLEVEL=' variables from the --make-opts arguments. Signed-off-by: Samuel Martin --- scripts/autobuild-run | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/scripts/autobuild-run b/scripts/autobuild-run index a7cdc12..dbfc33e 100755 --- a/scripts/autobuild-run +++ b/scripts/autobuild-run @@ -773,6 +773,40 @@ def merge(dict_1, dict_2): return dict((str(key), dict_1.get(key) or dict_2.get(key)) for key in set(dict_2) | set(dict_1)) +def sanitize_make_opts(make_opts): + """ sanitize make options + + - do not allow to override '-C' option + - do not allow to user deifined 'O=' and 'BR2_JLEVEL=' + - print log when overloading 'BR2_DL_DIR=' + + Return the sanitized make options string. + """ + make_opts = make_opts.split(" ") + for i, arg in enumerate(make_opts): + if arg.startswith("-C"): + # remove both '-C' and '-C' arguments + warn = "WARN: sanitizing make-opts (removing arguments '%s" % arg + make_opts.remove(arg) + if arg == '-C': + # remove '' in case of '-C ' + # (no need for incrementing i since make_opts[i] already points + # to '' after arg (i.e. '-C') has been removed + warn += " %s" % make_opts[i] + make_opts.remove(make_opts[i]) + warn += "')" + print(warn) + elif "=" in arg: + var = arg.split("=", 1)[0] + if var in ("BR2_DL_DIR",): + print("INFO: using user defined '%s' (%s)" % (var, arg)) + elif var in ("BR2_JLEVEL", "O",): + warn = "WARN: sanitizing make variable (removing arguments '%s')" % arg + make_opts.remove(arg) + print(warn) + return " ".join(make_opts) + + def main(): # Avoid locale settings of autobuilder machine leaking in, for example @@ -833,6 +867,7 @@ def main(): sys.exit(1) buildpid = multiprocessing.Array('i', int(args['--ninstances'])) + make_opts = sanitize_make_opts(args['--make-opts']) processes = [] for i in range(0, int(args['--ninstances'])): p = multiprocessing.Process(target=run_instance, kwargs=dict( @@ -842,7 +877,7 @@ def main(): http_login = args['--http-login'], http_password = args['--http-password'], submitter = args['--submitter'], - make_opts = args['--make-opts'], + make_opts = make_opts, upload = upload, buildpid = buildpid ))