From patchwork Tue Jan 1 23:44:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 1019853 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=heimpold.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="B9Dkxcj9"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=heimpold.de header.i=@heimpold.de header.b="or/jVPRU"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43TrQm3N0qz9rxp for ; Wed, 2 Jan 2019 10:45:36 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cIrirmLGMVd6RQLM1EY6gAwp8uqN/1iYVt8wKk8cjpQ=; b=B9Dkxcj9cBEHg4 tTp9BK1fdNuR1YVavUCWYKlT04awN5WoLujUNGoqwE/NKxBa/1upToq17aYKSYGSnLJKv9s7JDWJ1 jmaEWE8+45DLl3FLrW018JAaBizoFFURk4MTUKuo7qDJqMGTR+vSqUKSY7QvlTXUwPhAooou9AiZW pxPu09Y/oP7wPL46p/++gA+UIvwx/QDuYjEJO9CrezyQUeubkoQD4RWOJ3dNbstjNSd9GhT3kxolZ iUDJXYXxoDEmpSgKwdwVW4UJxWiLym8Rk+LDi2/tE3I3/tKvtfFP1yn/3muJu0+RrHhIwGgrygCW2 uE+ihYpQjVFtsn5hAyWw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1geTiv-0004Hd-Lh; Tue, 01 Jan 2019 23:45:25 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::2]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1geTig-00030S-Ah for openwrt-devel@lists.openwrt.org; Tue, 01 Jan 2019 23:45:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1546386303; s=strato-dkim-0002; d=heimpold.de; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=Wv8grdURwv5blfM9ol67Z0sU+YRPBh682u38FQvZkJg=; b=or/jVPRU/l+2TNxxisjmVzfo6Xjpcz4QitEkxcLF5pJC+ffLRHV8WkdoJgV2+4DrDp zaQ/JqGydgvlgNhFSw5Xt+f7tsuZ/PCuETsm/SVC8u6XKW+8rspF4UQj7uUwZNXU9gYT RQKtDyy9abgVFWBCq816eie+eiuRBrSnlaEhR5ASsRVoxEZspCrv3dJnz5FopjHMUA9o BmEW47ONxJUcQO0LPkKMT84utcztbb3R/rYPMiDKjY6knf0i1TcjVNE/YDc/JB2oA8GQ KshMkLab4UwwYsIo2PaJzGv8XyVkOONjw2+QYO37z+CFBu3f8QUjUTxUAzTjge0BSEa4 8T2Q== X-RZG-AUTH: ":O2kGeEG7b/pS1EW8QnKjhhg/vO4pzqdNytq77N6ZKUSN7PfdWTGbO3oK8Gj1rLTl4HJ2UQ==" X-RZG-CLASS-ID: mo00 Received: from tonne.mhei.heimpold.itr by smtp.strato.de (RZmta 44.9 DYNA|AUTH) with ESMTPSA id y05b79v01Nj3HZq (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 2 Jan 2019 00:45:03 +0100 (CET) Received: from kerker.mhei.heimpold.itr (kerker.mhei.heimpold.itr [192.168.8.1]) by tonne.mhei.heimpold.itr (Postfix) with ESMTP id A440A1C7ABD; Wed, 2 Jan 2019 00:45:02 +0100 (CET) From: Michael Heimpold To: openwrt-devel@lists.openwrt.org Date: Wed, 2 Jan 2019 00:44:56 +0100 Message-Id: <71d5124a90a8975fb846a55486244dd71a25507a.1546385477.git.mhei@heimpold.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190101_154510_902253_F2ABE3FE X-CRM114-Status: UNSURE ( 8.89 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a01:238:20a:202:5300:0:0:2 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [OpenWrt-Devel] [PATCH 4/7] procd: shift arguments for askfirst only once X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Heimpold MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org In case we want to process an inittab item multiple times (e.g. in case of hotplugging) we must not shift the arguments for askfirst multiple times. So check whether we already did it. Signed-off-by: Michael Heimpold --- inittab.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/inittab.c b/inittab.c index 18023f5..45118f4 100644 --- a/inittab.c +++ b/inittab.c @@ -165,9 +165,12 @@ static void askfirst(struct init_action *a) } a->tout.cb = respawn; - for (i = MAX_ARGS - 1; i >= 1; i--) - a->argv[i] = a->argv[i - 1]; - a->argv[0] = ask; + /* shift arguments only if not yet done */ + if (a->argv[0] != ask) { + for (i = MAX_ARGS - 1; i >= 1; i--) + a->argv[i] = a->argv[i - 1]; + a->argv[0] = ask; + } a->respawn = 500; a->proc.cb = child_exit; @@ -200,9 +203,12 @@ static void askconsole(struct init_action *a) } a->tout.cb = respawn; - for (i = MAX_ARGS - 1; i >= 1; i--) - a->argv[i] = a->argv[i - 1]; - a->argv[0] = ask; + /* shift arguments only if not yet done */ + if (a->argv[0] != ask) { + for (i = MAX_ARGS - 1; i >= 1; i--) + a->argv[i] = a->argv[i - 1]; + a->argv[0] = ask; + } a->respawn = 500; a->proc.cb = child_exit;