From unknown Sun Jun 22 11:35:46 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#78245 <78245@debbugs.gnu.org> To: bug#78245 <78245@debbugs.gnu.org> Subject: Status: rm -d fails to remove non-empty directory Reply-To: bug#78245 <78245@debbugs.gnu.org> Date: Sun, 22 Jun 2025 18:35:46 +0000 retitle 78245 rm -d fails to remove non-empty directory reassign 78245 coreutils submitter 78245 Yannick Le Pennec severity 78245 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun May 04 13:14:20 2025 Received: (at submit) by debbugs.gnu.org; 4 May 2025 17:14:21 +0000 Received: from localhost ([127.0.0.1]:58771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uBcuw-000854-IS for submit@debbugs.gnu.org; Sun, 04 May 2025 13:14:20 -0400 Received: from lists.gnu.org ([2001:470:142::17]:57422) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uBWmT-0000B0-P9 for submit@debbugs.gnu.org; Sun, 04 May 2025 06:41:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uBWmL-0002tc-FU for bug-coreutils@gnu.org; Sun, 04 May 2025 06:41:02 -0400 Received: from mail-northeuropeazolkn190110000.outbound.protection.outlook.com ([2a01:111:f403:d200::] helo=DB3PR0202CU003.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uBWmI-0006kI-WA for bug-coreutils@gnu.org; Sun, 04 May 2025 06:41:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BXqIotpEI8UbLnbpLk0YqPuiAonqD6AK9An6G6zJT1drbg2Mj4K+JFHkr1n2Gatgcu4A4DE05v79Ye3qSTakmw/icfE+MvNxBw5gwNt+2IXDcvDsCfNNX3AXmKHL0AcwbwVHnxGBEOSc/N8q0+m5QvFBIgKaMXpkeNUzOpt09zvpxB9MfVjZH2fzKKIKyPlmcvTx7fYwqplUnY6W4+fRekeAp8fh7qjojQzgF7ynyXeUzrdKSQFDTGDGbAXYU72Oo036v5Xf11JIc3YuGygyLW6VFQ9yAz/HdhrRA+KBLDsF9EMfKMmOZ7n1qGGlwN7Cr0AKSFOpUI0JuEyjdlY41w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wVmaM/lTB2qOS5rAHSf60KxdNbft3+nBj0yyLxe7tlQ=; b=xjOerVZBxtb9bD2wJUeSPV46q2RFC/g1C3LHiRdXrv2fqe6KAcfdDXn78FjzYJBYG1VLxzs/WNHURa4qknAwlTkiIiDVXhH1jOzsMYqENJjyWsKZgYXiO1gvpohi1tsT9hp58ttcfE1osE7dHGoAcB+1BQZUf9C3K7bwK5+mfrLq05wa03trYawaf9/J/9qNRID/v2FGOJRWTP2V4URyFRgUJrahdGvX2TWVBVOmNd3Ek71KbUzr4JyOUiqP0Po/jU7k/jePSYuU66jYTWbZBsc+eb8arwJiw2XA23+btknPQhTmyzMYoNrM0ex2dZlXZ/fUukyen8e45AcqlftnBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=LIVE.FR; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wVmaM/lTB2qOS5rAHSf60KxdNbft3+nBj0yyLxe7tlQ=; b=SVklVHzqJ2ee4CeXwq8tXTBj8/5oy+5KWwEvNbCGBAyuESdu95MPzZ8ecREe9bfYXECwcnpeBpe/BgOgY1lpttGKZHM6PEcopQKizUvjdLEBjMRpvCRvVgTegn8WX97Wbs4Yf78bbQnnU4YQ+P71N3XHuNM4VnWuwJSaNHPmtjlkxKGwJuXU5RS2bgJA5RRrThejDV+yNFIPrpABCdIJKRsLZHP4RjuVjLTcxCZMnMcGK7yYem2m1o3gNlUvKlAR7OLP6QzX2JMWBkXfsHzCNvpiI4E3eIK8/BTQK/s7taTVzd7/4M0NYq3GabMW2G/H2fR4C1iYXhghnjNFXUrJrA== Received: from VI1PR02MB4829.eurprd02.prod.outlook.com (2603:10a6:803:9d::15) by AS8PR02MB10079.eurprd02.prod.outlook.com (2603:10a6:20b:638::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.12; Sun, 4 May 2025 10:35:54 +0000 Received: from VI1PR02MB4829.eurprd02.prod.outlook.com ([fe80::dc17:dd68:b745:db98]) by VI1PR02MB4829.eurprd02.prod.outlook.com ([fe80::dc17:dd68:b745:db98%6]) with mapi id 15.20.8699.012; Sun, 4 May 2025 10:35:54 +0000 Message-ID: Subject: rm -d fails to remove non-empty directory From: Yannick Le Pennec To: bug-coreutils@gnu.org Date: Sun, 04 May 2025 12:35:52 +0200 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.1-1 X-ClientProxiedBy: PR0P264CA0142.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::34) To VI1PR02MB4829.eurprd02.prod.outlook.com (2603:10a6:803:9d::15) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR02MB4829:EE_|AS8PR02MB10079:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d08310c-e6c4-47b6-3662-08dd8af77246 X-MS-Exchange-SLBlob-MailProps: laRBL560oLR0Ybdxcp7KTbjbpYD2CblC09oRJ5hTyOq1OnP0vrHacX9myquNIyk0INgH69/QyzQ/JrwD55RHp/XJeUl1FmCBygTUA3Fp1JBlxCV8Z7KJ/RImnrIfg86vEItDA7ozQP9D/7ajWU2SOTf63wex/aiblllUm5YH73Ok69fqOXt9ACMYyQoWyWiHQIbUyjMFgHJ2QcMSmVhApyIKM6X3bttaNX983bdWZ5RtIOtzDnzVlkqjeTIg2n/kJTKvV7LihDJVy2g6QTzv2aXV3hOW36HMryAe+C6wYaEokddZpaQCVujoOYklEZ7MG1J9R+uFXIE2MDl3MAZepn/1wANMNUPtqSJCm/nGDutD2K3iBlj3MKQWzm68Gt4pbUXrB7DsMEMHYZCWa8Bnj66I2DyIZMxCUM37qSaWChUa8r8b7YH7TUHOFws8NNX2Gx9YizeQrLvr4NgJHVcLt9RVXrK7+pBzvBG5389qWoyOZN1+KPDALtJ655bhkF+3gha2JJDtq+zNqnKbxFQ4Umy0m8gLvIMUPWrY0DmZWIcKas20KfeaibYTB7iqEBadJGJoB7mzsCGzfy36FKZzDfGX6bvQ3LcppSGFBAkALaOCU3VnRPoB3G7PeOJinTdABO9rJAMepAG1XvFJR5mL5mJfC6YLBAgaEgRndUGgxTfTP1dRdD1VJCaLaHfFfMYtBT7qYF5wp2gTTxSVaduQFBb7NLRB8eF6aFPEjf8/jNyO2z9CfbQlQFHXOTNpvoAWvxkqqLmyQXttiflJND36E/bM9N3MXbi2 X-Microsoft-Antispam: BCL:0; ARA:14566002|8060799006|19110799003|461199028|5072599009|7092599003|6090799003|15080799006|10035399004|3412199025|440099028; X-Microsoft-Antispam-Message-Info: =?utf-8?B?OEpyRG12SzJNS2wrY0pmVUVRNjljOEVVT3lPbXlJamZ0V0x5MHEzLzNHakow?= =?utf-8?B?eEZFdmhhaXB4UU1iazhYWm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V0laNFJMWk91YzRIL3BQalA1S2NkSElaZ09HNkhoSXMraUV2SUNUWFdE?= =?utf-8?B?eE1kV2RIQ0NsRGJXcTdOQjJBL01nbyt6Rzh3dXo3VDdrMm9mYndKWTFmZ25W?= =?utf-8?B?TVNaa3ZKZDRMKzA3VllhT0VvZ0I5N2JnUEFiSW5SSytMa1E0cURvd1hyS3c5?= =?utf-8?B?M09ucC9QMmp1ZTVzd2s3SDdtTVhhL1B3R256dk9KTklIekp6b2h2VmsxU3lt?= =?utf-8?B?dUVLclF2ckdPZDFxYVRsSmhabU9Bd1E2bDQ4NWZ2SndPSkZSUGZBa3BuR3BU?= =?utf-8?B?Y2Qxb2dDbXJ0ZlljemRVQWxQMGJtT1YwcTIzc3lGM2pueXptK2ZYam9LSldI?= =?utf-8?B?bWR3bVpSZ1RDNCs5aThMZm5ldFlNM1FacTF1SU1wN2EzTkU3WEVCNER4UFMw?= =?utf-8?B?TVk4VkNZNnB5b204RmRhbVFwZ1BqbWllY25obVRSNlJKWWsvTGtFSlVubmVX?= =?utf-8?B?MlhCNVhqWHYrSFhCVFdKWElmNytwRXdjVE9rckc4S2kveHJGMlRrNzE1SUs3?= =?utf-8?B?Rk9LbDdleFJxNGNWRVBhTmtIWGw0WVdWRzZJa1B1VC9qUC8wdEF1b0duOGpC?= =?utf-8?B?aUZTN2oraUtWRGVjZ0FZVThUMlBSVk1YVFJ1U0ltck5tTXFrVWtMSE1XbTcx?= =?utf-8?B?WGFSZmZUZEFrUTI0dVBJS003d1pGTW5yMGxLRWcxZGRQSC9JRmVzZUdnUDdy?= =?utf-8?B?bTlNZTFMc0IxeFF5V0dDd3F3UStzbmVBMmtkZVI0cCtDeUVZalRIMHJxTWxR?= =?utf-8?Q?YzwV37voHJmwDS243h5zz+dOo68kisxpCBdr7SS?= X-OriginatorOrg: sct-15-20-7828-19-msonline-outlook-12d23.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 4d08310c-e6c4-47b6-3662-08dd8af77246 X-MS-Exchange-CrossTenant-AuthSource: VI1PR02MB4829.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2025 10:35:54.1767 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR02MB10079 Received-SPF: pass client-ip=2a01:111:f403:d200::; envelope-from=yannick.lepennec@live.fr; helo=DB3PR0202CU003.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 04 May 2025 13:14:15 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Dear Maintainer, On CephFS, creating a snapshot is done suchly: $ mkdir .snap/snapshot-name This creates a directory which contains a view of the current directory at the time the snapshot was created, and is therefore non-empty if the current directory was non-empty at that time. Its contents are immutable. Removing a snapshot is done suchly: $ rmdir .snap/snapshot-name This works fine even if .snap/snapshot-name is non-empty, as rmdir calls rmdir(2) directly without trying to be smart, and the Ceph filesystem understands what rmdir on a snapshot directory means: remove the snapshot. One would naturally expect rm -d to behave *exactly the same* as rmdir, but this isn't the case, because rm -d first does a getdents on the directory, observes it is non-empty, and refuses to perform the removal. >From what I understand, this is non-compliant behavior per XCU rm 2.a. and = 4. and XSH remove(): https://pubs.opengroup.org/onlinepubs/9799919799/utilities/rm.html > 2. If file is of type directory, the following steps shall be taken: > a. If neither the -R option nor the -r option is specified, but -d > is specified, rm shall proceed with step 3 for the current file. > 4. rm shall perform actions equivalent to the remove() function defined > in the System Interfaces volume of POSIX.1-2024 called with a > pathname of the current file used as the path argument. https://pubs.opengroup.org/onlinepubs/9799919799/functions/remove.html > If path names a directory, remove(path) shall be equivalent to rmdir(pa= th) In short: rm -d .snap/snapshot-name shall be equivalent to: remove(".snap/snapshot-name") which in turn shall be equivalent to: rmdir(".snap/snapshot-name") Moreover other coreutils rm implementations (such as uutils or voreutils) do not exhibit this bug and correctly remove non-empty directories. Regards, Yannick Le Pennec From debbugs-submit-bounces@debbugs.gnu.org Sun May 04 14:01:23 2025 Received: (at 78245) by debbugs.gnu.org; 4 May 2025 18:01:23 +0000 Received: from localhost ([127.0.0.1]:59430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uBdeV-0005xW-Cz for submit@debbugs.gnu.org; Sun, 04 May 2025 14:01:23 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:54392) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uBdeT-0005xG-8G for 78245@debbugs.gnu.org; Sun, 04 May 2025 14:01:22 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-39c13fa05ebso2092856f8f.0 for <78245@debbugs.gnu.org>; Sun, 04 May 2025 11:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746381675; x=1746986475; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=+GckYFItn9lKMKDH8GMfuOY9ZmM2AxUo5F2kZh+7Vj0=; b=gc0g/b8oE9a5GJllLkPbngI8Uj+NEK578M77q/d64/iyxNudG3prLrOuXcp7/AOL44 +va06r94ioanFfwLOE+cUMgz0C31soS7Yik8hT5KF1XUJZDjzGr/m/bZlgELNX4PfBz8 kCa3ArMHUK+k8Z7wW8c8uqpQEDgywllsx8UPb0oh270x353BoCV8gZSfzCyByY/VDp6y JHrNw4sneKcEFVxtfi1WBBN4LLZau/9XwZs/evupes9Eond1IYH8j2xBjQLdaYWlBFYN U9XsrxKEHj3h8qvUm+umMiWKByqDlp2gDlSRm7cAp9Ja+I9qDmf2tc0ZCFjyDKxyiLSS muRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746381675; x=1746986475; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+GckYFItn9lKMKDH8GMfuOY9ZmM2AxUo5F2kZh+7Vj0=; b=nL49oBb0rNX0QQLxbmuF6ZCdqNjea5EHn8p7RpVRUxu/EtzkMc6DEZxnn+wixEeJne X5asGcmjOc4up8d87YPCUx4HAthjckwGHe6eaN9ghSzGLTL1+b+1ib3sqIZxvMQcLfs9 tDWLi8HxjDxh/qMVo3Jcve+e8TXRrY34uzHs2UUpMsluHmUvDWLGfY+I7nVUrve20cPI qA22brzWD1s9iBfGUwLjczivTniUNAslSCa7v5zF1MvpNv/stgMynIzz+yktepVE1ZhD eOr9meULiipEewmRD/qjoyx5LKErwMDvcf4NPQU1SxRMpqeYW0GRRJaqKg0bKJpIG3Y8 D/yQ== X-Forwarded-Encrypted: i=1; AJvYcCVb9ZuQPt6RyXmkVT78rmvt8s5UwqFqNYoeWI4FpmACoopAa5yhqTb85sJ+fdBdSoRmDJswXg==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yzspq3cahMlTNkop/0jQpovUm1nofdwdOzfdMPXsaEMm66M4xd5 lgyhHfELZe04oeu0fKeo9HkoeuqVQfCoOly89lXXtZKLqMWlcyMb X-Gm-Gg: ASbGncuDpyxEv4uTqnl3lYMAYQcUec4F+lBi/KXpZnFkxXddE4uAp4cOVIIFvVxsWqE A+UhX/I/+E8Br4dY/EIn1KF6sOHfoQHxK9A4trfUxsWUBdzWxryeeC5DFjVLbkH2mRx3ELw4ivd sAbwwvbZ2tAJCPToKS78eaUezzd5lbxKpM8hVhw/CAh6ix8zJabPHJsCmb6BwWYLL3KX0eCuOrB 7csooMUAjmtIqvRJ16CmXHBH24fr6SLSlLhPH0xJFJocKciqHwXsAmcKS1j3YVbacGCZ91Utmoy qh2ic6gmFkDstBCExozFSiugr4oPO2aWnYZGWKZRFUs6ocnmT0uIndEywjk/PUqBfjILIGU0UXM +MG1wNgqis730DJGFZzVwjVS+EBSCoQ8= X-Google-Smtp-Source: AGHT+IFHU965AA19r9PdSVmW275v3apZjjMQoc4F299LhOgHi0M+X/m5r+LRMoSOoNGTryZun25A7A== X-Received: by 2002:a5d:64e6:0:b0:3a0:82f8:a999 with SMTP id ffacd0b85a97d-3a09fdd80acmr3462692f8f.51.1746381674511; Sun, 04 May 2025 11:01:14 -0700 (PDT) Received: from [192.168.1.31] (86-44-211-146-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.44.211.146]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3a099b0fe92sm8095947f8f.68.2025.05.04.11.01.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 04 May 2025 11:01:13 -0700 (PDT) Message-ID: Date: Sun, 4 May 2025 19:01:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: bug#78245: rm -d fails to remove non-empty directory To: Yannick Le Pennec , 78245@debbugs.gnu.org References: Content-Language: en-US From: =?UTF-8?Q?P=C3=A1draig_Brady?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78245 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 04/05/2025 11:35, Yannick Le Pennec wrote: > Dear Maintainer, > > On CephFS, creating a snapshot is done suchly: > $ mkdir .snap/snapshot-name > > This creates a directory which contains a view of the current directory > at the time the snapshot was created, and is therefore non-empty if the > current directory was non-empty at that time. Its contents are immutable. > > Removing a snapshot is done suchly: > $ rmdir .snap/snapshot-name > > This works fine even if .snap/snapshot-name is non-empty, as rmdir calls > rmdir(2) directly without trying to be smart, and the Ceph filesystem > understands what rmdir on a snapshot directory means: remove the snapshot. > > One would naturally expect rm -d to behave *exactly the same* as rmdir, > but this isn't the case, because rm -d first does a getdents on the > directory, observes it is non-empty, and refuses to perform the removal. > > From what I understand, this is non-compliant behavior per XCU rm 2.a. and 4. > and XSH remove(): > > https://pubs.opengroup.org/onlinepubs/9799919799/utilities/rm.html > >> 2. If file is of type directory, the following steps shall be taken: >> a. If neither the -R option nor the -r option is specified, but -d >> is specified, rm shall proceed with step 3 for the current file. > >> 4. rm shall perform actions equivalent to the remove() function defined >> in the System Interfaces volume of POSIX.1-2024 called with a >> pathname of the current file used as the path argument. > > https://pubs.opengroup.org/onlinepubs/9799919799/functions/remove.html > >> If path names a directory, remove(path) shall be equivalent to rmdir(path) > > In short: > rm -d .snap/snapshot-name > shall be equivalent to: > remove(".snap/snapshot-name") > which in turn shall be equivalent to: > rmdir(".snap/snapshot-name") > > Moreover other coreutils rm implementations (such as uutils or voreutils) > do not exhibit this bug and correctly remove non-empty directories. > > Regards, > > Yannick Le Pennec For reference this was also reported at: https://bugs.debian.org/1104300