From patchwork Mon Nov 5 17:59:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 993272 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="ag11csbW"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42pgSJ3Y0qz9sDr for ; Tue, 6 Nov 2018 05:00:00 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387595AbeKFDUp (ORCPT ); Mon, 5 Nov 2018 22:20:45 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:43662 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387515AbeKFDUp (ORCPT ); Mon, 5 Nov 2018 22:20:45 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA5Hsg8D152946; Mon, 5 Nov 2018 17:59:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=GATJbgMH132r6/3kz3LODbtDMTr5d924lr5jDzBb244=; b=ag11csbWwVPrETtHi1m7oDBgTN9/bZ/pxPEkEwO7W3dW8UITr5ybkA8n4L31nO9F4jZr 2uENtnt/mMlkIWsdPXVKwwTPpiY6yvDFeDwN2V17p4ia0hCfeVblGKSfRH9b8EplpBXL EI9GTtP8h9IG+5/ADb3+xcLFgzI1acNjI6X7UctuMvzJzkrhmpupxfmJpfgxpfAy0vn8 KMu+4X1qPwgvzWQEKCvuiww/Cud8bHqK1ZnRMJ/qMCPfPeIl67+/CSG4CK7a0r0ABB3L GUARAc5M1Hwi5jYXaicoJA7hbLAiymgYWQhLsQNImtUFo0D4tUX2YbNuXMXOQvccQor5 Fw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2nh33trjsa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Nov 2018 17:59:53 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wA5HxlfI004580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Nov 2018 17:59:47 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wA5HxlnX027378; Mon, 5 Nov 2018 17:59:47 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 09:59:47 -0800 Date: Mon, 5 Nov 2018 09:59:46 -0800 From: "Darrick J. Wong" To: "Theodore Ts'o" Cc: linux-ext4 Subject: [PATCH] e2scrub: fix systemd escaping again Message-ID: <20181105175946.GA4124@magnolia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811050160 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Darrick J. Wong Apparently newer versions of systemd than the one on this author's laptop now complain about lack of (path) escaping in unit instance variable contents: # e2scrub_all Scrubbing /home... Invalid unit name "e2scrub@/home" was escaped as "e2scrub@-home" (maybe you should use systemd-escape?) Starting Online ext4 Metadata Check for /home... So change the escape_path_for_systemd function to escape paths unconditionally to make the warning go away. Signed-off-by: Darrick J. Wong --- scrub/e2scrub_all.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in index 9581dc2c4..23d122d25 100644 --- a/scrub/e2scrub_all.in +++ b/scrub/e2scrub_all.in @@ -101,13 +101,18 @@ ls_scrub_targets() { # systemd doesn't know to do path escaping on the instance variable we pass # to the e2scrub service, which breaks things if there is a dash in the path # name. Therefore, do the path escaping ourselves if needed. +# +# systemd path escaping also drops the initial slash so we add that back in so +# that log messages from the service units preserve the full path and users can +# look up log messages using full paths. However, for "/" the escaping rules +# do /not/ drop the initial slash, so we have to special-case that here. escape_path_for_systemd() { local path="$1" - if echo "${path}" | grep -q -- "-"; then + if [ "${path}" != "/" ]; then echo "-$(systemd-escape --path "${path}")" else - echo "${path}" + echo "-" fi }