From patchwork Tue Jul 28 08:21:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 501072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 3007C1402DD for ; Tue, 28 Jul 2015 18:22:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 261F39174E; Tue, 28 Jul 2015 08:22:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qcqeSdBsZLsV; Tue, 28 Jul 2015 08:22:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 99E8B91222; Tue, 28 Jul 2015 08:22:54 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 8709B1C1F48 for ; Tue, 28 Jul 2015 08:22:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8244191222 for ; Tue, 28 Jul 2015 08:22:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KNirFatzqix1 for ; Tue, 28 Jul 2015 08:22:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0077.outbound.protection.outlook.com [157.56.111.77]) by whitealder.osuosl.org (Postfix) with ESMTPS id 4BE8B9121A for ; Tue, 28 Jul 2015 08:22:52 +0000 (UTC) Received: from BLUPR0301CA0018.namprd03.prod.outlook.com (10.162.113.156) by BLUPR03MB327.namprd03.prod.outlook.com (10.141.48.18) with Microsoft SMTP Server (TLS) id 15.1.231.11; Tue, 28 Jul 2015 08:22:49 +0000 Received: from BL2FFO11FD052.protection.gbl (2a01:111:f400:7c09::132) by BLUPR0301CA0018.outlook.office365.com (2a01:111:e400:5259::28) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Tue, 28 Jul 2015 08:22:49 +0000 Authentication-Results: spf=fail (sender IP is 137.71.25.55) smtp.mailfrom=crapouillou.net; crapouillou.net; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of crapouillou.net does not designate 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2FFO11FD052.mail.protection.outlook.com (10.173.161.214) with Microsoft SMTP Server (TLS) id 15.1.231.11 via Frontend Transport; Tue, 28 Jul 2015 08:22:48 +0000 Received: from NWD2HUBCAS9.ad.analog.com (nwd2hubcas9.ad.analog.com [10.64.72.142]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id t6S8MG35024407 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 28 Jul 2015 01:22:17 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS9.ad.analog.com (10.64.72.142) with Microsoft SMTP Server id 14.3.210.2; Tue, 28 Jul 2015 04:21:36 -0400 Received: from carl.ad.analog.com ([10.44.2.243]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id t6S8LZoG011224; Tue, 28 Jul 2015 04:21:36 -0400 From: Paul Cercueil To: Date: Tue, 28 Jul 2015 10:21:31 +0200 Message-ID: <1438071691-9078-1-git-send-email-paul@crapouillou.net> X-Mailer: git-send-email 2.4.6 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130825453689047659; (52f37747-95c3-483a-bd05-08d153b03fac); () X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD052; 1:++qePp6mMSWP4YLnMp3K/m+2i5AbOqPQl8T3Dt9Z4W6ECTTiclWGyCUCHOmeB3XuPApt3eX5h/cl2/9AV8BJIsXgba7ZSb9XDflHccUfY72861H32tTTzcQethfaKPWnH0PnFuV1HTAXzQc5yB2m2G0Qh/0CI3+gLN5+be+qR6Hwbr+Q9rH0t3evmMOzuUYPdxEWGy3b6shSRQb8zAlX4gGWbD0UbzOaZfaD18EbCv0mNe8LIEg+/ENECgO9U0URwtNXGJXLC/YUygrp/PqHEFv3i79c7iSD2Y0/NCJD2PF1Pgud/MCN7fFJiza3bsDNc2b0jDcDwi2pb0EMQitVSeLlsyziBnDWhL+SBgNKjkU= X-Forefront-Antispam-Report: CIP:137.71.25.55; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(6009001)(2980300002)(339900001)(199003)(189002)(2351001)(229853001)(189998001)(33646002)(86362001)(47776003)(87936001)(50226001)(85426001)(46102003)(50986999)(105606002)(19580395003)(19580405001)(50466002)(48376002)(36756003)(62966003)(77156002)(77096005)(92566002)(106466001)(5001970100001)(110136002)(5003940100001)(6806004)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB327; H:nwd2mta1.analog.com; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:nwd2mail10.analog.com; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB327; 2:ot3ObW02xmxtt6PW3kijXeL85XgEU6txVqybFsQhuUyVTA9k64MHvGsXJdi6tl+K/fj+2JP7lRt1tz/dRksMcLNFWlMryuGu9Ipvo/uqmbKDuDWYH+Hom9ZBLUSKSs+WBgg0g36yPw/gy6/yKW3YSOGoBltlI/zQ6QPpB+LDp7E=; 3:ub1gwGy1o/WoaLeLtdjnUPvm6luW8bqKVX6y/SZ/lN/nwSD06SH4BjggkZmzHEAC+oqInevWsWZyLMx7L3X3ErwfXl8qY+D+wiBZnNPlnpS/bw/n5CLQIh4XuNOKeeUZstFNV8y2nfVWD4pAdfyjxnOfNKoRLkOTMef9Dhs0n4+FJLNO1ctj1oncXCRze6t+AA10TTsFpbU9GdpTqPHaW4Lh1RnjY0PfKLP9XSa4RgI=; 25:CgoJm8Dh4SJKnYO6QyJwe6iUm0RxUILculieo8pr+VSJR8iRIJrfaj6T/RzsUAMTVe7wJpz4yNLI14ZOy4l+IZF6lza9Y3sxKXmWlZjVryqt3Mow69Vy8PgQrVQqJYl4qkibTmRELz/TQJ8fMG4ftDeddI16EniKZTLipOumc0tj43iVyg2nLzMzmdnYq918rxiIrxA7/JTI30O2se/q026M1oIUOYH0xt8R274pPhhdIhhFE8fS55bkKbyPfaEY; 4:8HXBACd2gX4UjBuIJnJ1NBAbuYipdEbWM0JKON7C7++86MTXPSMA+Pd34ea4YcrqDdSiRMqBH6uKxAxfyIU0r7X3TavIrFOfmxMoTnkUcwMZIqXbHo11kWv15nMhU0fUIj8QpPTlRGHb6tvrPhgXpK49tNr1p5iLT/IGSE4557QCFNCbZBRHJUrmGCTO4SHTmUnHj2bPbbTt9GVdfTw8p6632Bc5jUZfG2mlw6yH18iZXA5A4VtwfHRLjeqUzxX6+wFzKpG6YKQeHXbuYCHnJ4YL5iaX62s+CABL4w+Tim I= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB327; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BLUPR03MB327; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR03MB327; X-Forefront-PRVS: 06515DA04B X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB327;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banAXQyPkTglygGwCw43FoTs9QKg3dZ5jkqrmRG4W1JQ7eANrUlyrMtbirfSvIC1JvJJAI3a+RXiw=; 24:pEmqr+waf6EEU6jV0IBH/nX9ApzQ3FMFDtyx3G9GPd4OHTOffF/Qo1A9VyI6cGKgO6heoOj8QP60nRJDc2UWRmDjW4iGe05c9htjpJplRto= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2015 08:22:48.7955 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[137.71.25.55]; Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB327 Cc: Paul Cercueil Subject: [Buildroot] [PATCH v2] package/dropbear: Fix symlink only if pointing to the right directory 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: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This commit ensures that the /etc/dropbear symlink won't be removed if it points elsewhere than /var/run/dropbear. Signed-off-by: Paul Cercueil Reviewed-by: "Yann E. MORIN" --- v2: Use "readlink -f", as the symbolic link might be pointing to a relative path and not an absolute path. package/dropbear/S50dropbear | 6 ++++-- package/dropbear/dropbear.service | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package/dropbear/S50dropbear b/package/dropbear/S50dropbear index af50ccf..f551677 100644 --- a/package/dropbear/S50dropbear +++ b/package/dropbear/S50dropbear @@ -12,12 +12,14 @@ start() { echo -n "Starting dropbear sshd: " umask 077 - # If /etc/dropbear is not a directory, and + # If /etc/dropbear is a symlink to /var/run/dropbear, and # - the filesystem is RO (i.e. we can not rm the symlink), # create the directory pointed to by the symlink. # - the filesystem is RW (i.e. we can rm the symlink), # replace the symlink with an actual directory - if ! [ -d /etc/dropbear ]; then + if [ -L /etc/dropbear \ + -a "$(readlink -f /etc/dropbear)" = "/var/run/dropbear" ] + then if rm -f /etc/dropbear; then mkdir -p /etc/dropbear else diff --git a/package/dropbear/dropbear.service b/package/dropbear/dropbear.service index 0e2cf54..f1d4d5d 100644 --- a/package/dropbear/dropbear.service +++ b/package/dropbear/dropbear.service @@ -3,13 +3,13 @@ Description=Dropbear SSH daemon After=syslog.target network.target auditd.service [Service] -# If /etc/dropbear is not a directory, and +# If /etc/dropbear is a symlink to /var/run/dropbear, and # - the filesystem is RO (i.e. we can not rm the symlink), # create the directory pointed to by the symlink. # - the filesystem is RW (i.e. we can rm the symlink), # replace the symlink with an actual directory ExecStartPre=/bin/sh -c '\ -if ! [ -d /etc/dropbear ]; then \ +if [ -L /etc/dropbear -a "$(readlink -f /etc/dropbear)" = "/var/run/dropbear" ]; then \ if rm -f /etc/dropbear; then \ mkdir -p /etc/dropbear; \ else \