From unknown Fri Aug 15 02:03:48 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#76702 <76702@debbugs.gnu.org> To: bug#76702 <76702@debbugs.gnu.org> Subject: Status: coreutils 9.1 cp --parents --preserve /dir/file fstat relative dir Reply-To: bug#76702 <76702@debbugs.gnu.org> Date: Fri, 15 Aug 2025 09:03:48 +0000 retitle 76702 coreutils 9.1 cp --parents --preserve /dir/file fstat relativ= e dir reassign 76702 coreutils submitter 76702 "Alan J. Goalby" severity 76702 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 02 23:32:25 2025 Received: (at submit) by debbugs.gnu.org; 3 Mar 2025 04:32:25 +0000 Received: from localhost ([127.0.0.1]:42400 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1toxTZ-0004ju-Rh for submit@debbugs.gnu.org; Sun, 02 Mar 2025 23:32:25 -0500 Received: from lists.gnu.org ([2001:470:142::17]:41794) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tol5e-0007UD-JN for submit@debbugs.gnu.org; Sun, 02 Mar 2025 10:18:51 -0500 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 1tol5E-0004Kt-6w for bug-coreutils@gnu.org; Sun, 02 Mar 2025 10:18:26 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tol5B-0006Rq-Rp for bug-coreutils@gnu.org; Sun, 02 Mar 2025 10:18:23 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4394345e4d5so24708435e9.0 for ; Sun, 02 Mar 2025 07:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740928699; x=1741533499; darn=gnu.org; h=from:content-disposition:mime-version:message-id:subject:to:date :from:to:cc:subject:date:message-id:reply-to; bh=no9VH3rGpgXt2BOF5KXXCEFAuPKQb1zhW6lnLMmBTaA=; b=DtRxUuCDUUOuFC/f8g3tKVUwk4OCpD5h2elU5YfEd9Zu3e7aFvKq/uR8X6AG5fanrs yBGwxR2zjefJtPmbZhF+0PxT6fs1qcweq6ahgg/eKRFEcyJJgc0Jk8wwtxF0s8cQz7v+ dGBXPxVD2ZQQhpBmoQGpNCL2yHZ2oAY+NEo/4UWvV0mCi5sCXtFSd0/XafDJ5G3xNXqh TXl4MTg8IL1FSSR5Y9gmXJ8RHB9FXtuDcnklQzmxKqcnQ1dfd7F99bOIq9ub0UZqc/G7 zZM4tSh/ezS4cQayEdUS9nF89FLfLZH9Y/V3MNDbwkKqtAlJP4YrRg3N/p28RPx1FXMh A/XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740928699; x=1741533499; h=from:content-disposition:mime-version:message-id:subject:to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=no9VH3rGpgXt2BOF5KXXCEFAuPKQb1zhW6lnLMmBTaA=; b=fMA4dwa7f9YygltqjqQkho0m1n5+AQN7Wrap61lW8UDa1D2JhNCItPK4LKQakaLpYR jkKQmmiK0+UnXZ4p1EFR7DAui8TWIldg+CnH0jUVBWolSuTtxw9LV9ITx8D9a/mQRHbZ A4Xf8+tgdW7cVCH9na2v/AwUiI/qly1IWUyYW9TEo46ISzMeoJw9bW7ksMx4sFHdCad1 bOVm89Wfi2CYbilQQeNKwDWxGZsuCN+usG/qCwi3ADQR9c0EN4ktFRMYnH+sXzgFJy6/ CvU3lY8592a5Nz76r+IViBqwj3NTK0h6N42zWGnVMAuRARkwYcDD5mKuyAQ8SWIOY+bp eoQw== X-Gm-Message-State: AOJu0YxyuLjUOeOBh291MZejn43NQjWX2oL5GV9gOVN2bEST/yEP+Gld nVf/k1uggWFeJm02r9nh5L2UGOvyA5XhHBbFTGL1fWoTylV+sKHQL1fU3POp92k= X-Gm-Gg: ASbGncvp9eEO6LZ+AP0iW61/C2e+FOJ5N5ReffwSDkwP9PFjMt86BfP/75eQFBCTY0Z pgNpxc2dZyNmcbccjPwjx+0Dqb3EvGmpLazoMrA83TUWyNOsxizlL4rSq6c7JPbnmSMsg+G26qX 50wJ0PQAeIMEt6IfpHKKDHCAkf9UqeYEOsRGjasCVuDR02ZjtB1hYJhpVnapirrzeJW98fFpGE1 +cQMF4alD2shCYs6iouz14pcriK7+FV/bms4kCKy0MzxBBCN/+cfNsnReFi+1Rc+OO0EGTePC0a FOT+Bx9Drg36BYStc7UD1s7h9Msi2ft4HuqE0lsSpeJplNqQQAmuuiA3FNI9eKgIwy11efnoaai sYxWxOLv4ZLQ= X-Google-Smtp-Source: AGHT+IHS9X+JGcxIpy55h61/d7DIMwrqbndalXVLuas0rg7c58QtHjffZYYcBTq18YRNg2Bpk8PPDg== X-Received: by 2002:a05:600c:3506:b0:439:8e46:ee73 with SMTP id 5b1f17b1804b1-43ba6704446mr93824615e9.15.1740928698808; Sun, 02 Mar 2025 07:18:18 -0800 (PST) Received: from li4.lan (host86-162-40-112.range86-162.btcentralplus.com. [86.162.40.112]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47965ddsm11909374f8f.18.2025.03.02.07.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Mar 2025 07:18:17 -0800 (PST) Received: from ag by li4.lan with local (Exim 4.94.2) (envelope-from ) id 1tol57-005GdV-2a; Sun, 02 Mar 2025 15:18:17 +0000 Date: Sun, 2 Mar 2025 15:18:17 +0000 To: bug-coreutils@gnu.org Subject: coreutils 9.1 cp --parents --preserve /dir/file fstat relative dir Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="31f+QnxVWivjRU2f" Content-Disposition: inline From: "Alan J. Goalby" Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alan.j.goalby@gmail.com; helo=mail-wm1-x334.google.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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, 02 Mar 2025 23:32:18 -0500 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 (/) --31f+QnxVWivjRU2f Content-Type: text/plain; charset=us-ascii Content-Disposition: inline When "cp --parents --preserve /dir/file /target/" needs to create /target/dir/, it appears to try to Fstat information from relative path "dir", not the actual parent path "/dir". E.g., "cd /tmp && mkdir NewDir && cp -a --parents /etc/passwd NewDir" will fail, as (1) below - unless (2) /tmp/etc exists, or (3) use "cd /", or (4) omit "--preserve". My enclosed cp-par-pres-demo.sh shows that: (1) Cp --parents --preserve /dir/file /target/" will * log ENOENT for relative "dir" for a missing /target/dir; * create that missing parent /target/dir with mode 700; * create a missing non-parent output correctly; and * return error status 1. (2) If ./dir exists, Cp takes /target/dir mode from it, not /dir. (3) With "cd /", this works normally, since "dir" is /dir. (4) Without --preserve, there is no error. This happens for Debian 12.9 coreutils 9.1-1, under linux 6.1.115 amd64, on an ext4 partition, for root and other users, e.g. nobody. And for an ext3 copy Chroot under linux 5.10.226. (md5sum --check verifies coreutils.md5sums lib*.msd5sums et al.) This does not happen for Debian 11.11 coreutils 8.32-4+b1, under linux 5.10.226 amd64 on ext4, nor for earlier versions on i386 ext3. I enclose logs from those good Debian 11 and wrong Debian 12 runs. My other tests show this not happening for relative input paths. Hope this helps. Alan J. Goalby --31f+QnxVWivjRU2f Content-Type: application/x-sh Content-Disposition: attachment; filename="cp-par-pres-demo.sh" Content-Transfer-Encoding: quoted-printable #!/bin/sh=0A# cp-par-pres-demo.sh - A J Goalby, Mar 2025=0A=0A# Constants. = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=0A=0ATmp= D=3D"/tmp/cp-par-pres-demo-out"; # top output directory=0AInpD=3D"/etc"; # = directory containing input file=0AInpF=3D"$InpD/passwd"; # input file=0A=0A= OddD=3D"$TmpD$InpD"; # directory at "dir" not "/dir"=0AOddM=3D'751'; # dist= inctive mode for OddD=0A=0A# Functions. +++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++=0A=0ARun1Cmd() { # log and run one command;= $@ =3D command argument...=0A local Stat;=0A printf ' * %s\n' "$*";= =0A "$@" || printf '*** %s gave STATUS %d ***\n' "${1:?}" "$?"; =0A}; = # Run1Cmd=0A=0ADemo1Cp() { # prepare, log, run, and check one Cp command; $= @=3Dbelow=0A local RunN Desc CwdD RunD;=0A RunN=3D"${1:?}"; # run num= ber=0A Desc=3D"${2:?}"; # run description=0A CwdD=3D"${3:?}"; # targe= t=0A shift 3; # now $@ =3D cp options=0A=0A printf '\n(%d) %s\n' "$Ru= nN" "$Desc"; # banner=0A=0A RunD=3D"$TmpD/run$RunN"; # target for this c= p=0A=0A Run1Cmd mkdir "$RunD"; # create output directory=0A=0A Run1Cm= d cd "$CwdD"; # set current directory=0A=0A Run1Cmd cp "$@" "$InpF" "$Ru= nD"; # do the cp=0A=0A find "$RunD" -printf ' > %u.%g.%m %p ' \=0A '(' = ! -perm 755 ! -perm 644 -printf '*** IFFY %m ***' \=0A -o -printf 'okay.'= ')' -printf '\n'; # show results=0A=0A}; # Demo1Cp=0A=0A# Initialisation. = +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=0A=0ARun1Cmd = export LC_ALL=3D'C'; # output ASCII=0A=0ARun1Cmd uname -a; # show system in= fo=0A=0ARun1Cmd hostname; # ...=0A=0ARun1Cmd cat /etc/debian_version; # ...= =0A=0ARun1Cmd umask 022; # set usual umask=0A=0ARun1Cmd mkdir "$TmpD"; # cr= eate temporary output directory=0A=0A# Demo1Cp's run Cp and show effect. ++= +++++++++++++++++++++++++++++++++++++++++=0A=0ADemo1Cp 1 'deb12 Cp gives no= -such, ?=3D1, root.root.700!' \=0A '/home' --parents --preserve;=0A=0Ae= cho;=0A=0ARun1Cmd mkdir --mode=3D"$OddM" "$OddD"; # create wrongly used dir= ectory=0A=0ADemo1Cp 2 "deb12 Cp wrongly uses relative '${InpD#/}' not '$Inp= D'!" \=0A "$TmpD" --parents --preserve;=0A=0ADemo1Cp 3 'Okay in / (so r= elative equals absolute).' \=0A '/' --parents --preserve;=0A=0ADemo1Cp = 4 'Okay without --preserve.' \=0A '/home' --parents;=0A=0A# Termination= =2E ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=0A=0Ae= cho;=0A=0ARun1Cmd rm --interactive=3Donce --recursive "$TmpD"; # offer to c= lean up=0A --31f+QnxVWivjRU2f Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fail-deb12p9-demo.log" * export LC_ALL=C * uname -a Linux tp3 6.1.0-27-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.115-1 (2024-11-01) x86_64 GNU/Linux * hostname tp3 * cat /etc/debian_version 12.9 * umask 022 * mkdir /tmp/cp-par-pres-demo-out (1) deb12 Cp gives no-such, ?=1, root.root.700! * mkdir /tmp/cp-par-pres-demo-out/run1 * cd /home * cp --parents --preserve /etc/passwd /tmp/cp-par-pres-demo-out/run1 cp: 'etc': No such file or directory *** cp gave STATUS 1 *** > root.root.755 /tmp/cp-par-pres-demo-out/run1 okay. > root.root.700 /tmp/cp-par-pres-demo-out/run1/etc *** IFFY 700 *** > root.root.644 /tmp/cp-par-pres-demo-out/run1/etc/passwd okay. * mkdir --mode=751 /tmp/cp-par-pres-demo-out/etc (2) deb12 Cp wrongly uses relative 'etc' not '/etc'! * mkdir /tmp/cp-par-pres-demo-out/run2 * cd /tmp/cp-par-pres-demo-out * cp --parents --preserve /etc/passwd /tmp/cp-par-pres-demo-out/run2 > root.root.755 /tmp/cp-par-pres-demo-out/run2 okay. > root.root.751 /tmp/cp-par-pres-demo-out/run2/etc *** IFFY 751 *** > root.root.644 /tmp/cp-par-pres-demo-out/run2/etc/passwd okay. (3) Okay in / (so relative equals absolute). * mkdir /tmp/cp-par-pres-demo-out/run3 * cd / * cp --parents --preserve /etc/passwd /tmp/cp-par-pres-demo-out/run3 > root.root.755 /tmp/cp-par-pres-demo-out/run3 okay. > root.root.755 /tmp/cp-par-pres-demo-out/run3/etc okay. > root.root.644 /tmp/cp-par-pres-demo-out/run3/etc/passwd okay. (4) Okay without --preserve. * mkdir /tmp/cp-par-pres-demo-out/run4 * cd /home * cp --parents /etc/passwd /tmp/cp-par-pres-demo-out/run4 > root.root.755 /tmp/cp-par-pres-demo-out/run4 okay. > root.root.755 /tmp/cp-par-pres-demo-out/run4/etc okay. > root.root.644 /tmp/cp-par-pres-demo-out/run4/etc/passwd okay. * rm --interactive=once --recursive /tmp/cp-par-pres-demo-out rm: remove 1 argument recursively? --31f+QnxVWivjRU2f Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="good-deb11p11-demo.log" * export LC_ALL=C * uname -a Linux li4 5.10.0-33-amd64 #1 SMP Debian 5.10.226-1 (2024-10-03) x86_64 GNU/Linux * hostname li4 * cat /etc/debian_version 11.11 * umask 022 * mkdir /tmp/cp-par-pres-demo-out (1) deb12 Cp gives no-such, ?=1, root.root.700! * mkdir /tmp/cp-par-pres-demo-out/run1 * cd /home * cp --parents --preserve /etc/passwd /tmp/cp-par-pres-demo-out/run1 > root.root.755 /tmp/cp-par-pres-demo-out/run1 okay. > root.root.755 /tmp/cp-par-pres-demo-out/run1/etc okay. > root.root.644 /tmp/cp-par-pres-demo-out/run1/etc/passwd okay. * mkdir --mode=751 /tmp/cp-par-pres-demo-out/etc (2) deb12 Cp wrongly uses relative 'etc' not '/etc'! * mkdir /tmp/cp-par-pres-demo-out/run2 * cd /tmp/cp-par-pres-demo-out * cp --parents --preserve /etc/passwd /tmp/cp-par-pres-demo-out/run2 > root.root.755 /tmp/cp-par-pres-demo-out/run2 okay. > root.root.755 /tmp/cp-par-pres-demo-out/run2/etc okay. > root.root.644 /tmp/cp-par-pres-demo-out/run2/etc/passwd okay. (3) Okay in / (so relative equals absolute). * mkdir /tmp/cp-par-pres-demo-out/run3 * cd / * cp --parents --preserve /etc/passwd /tmp/cp-par-pres-demo-out/run3 > root.root.755 /tmp/cp-par-pres-demo-out/run3 okay. > root.root.755 /tmp/cp-par-pres-demo-out/run3/etc okay. > root.root.644 /tmp/cp-par-pres-demo-out/run3/etc/passwd okay. (4) Okay without --preserve. * mkdir /tmp/cp-par-pres-demo-out/run4 * cd /home * cp --parents /etc/passwd /tmp/cp-par-pres-demo-out/run4 > root.root.755 /tmp/cp-par-pres-demo-out/run4 okay. > root.root.755 /tmp/cp-par-pres-demo-out/run4/etc okay. > root.root.644 /tmp/cp-par-pres-demo-out/run4/etc/passwd okay. * rm --interactive=once --recursive /tmp/cp-par-pres-demo-out rm: remove 1 argument recursively? --31f+QnxVWivjRU2f-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 03 08:21:16 2025 Received: (at 76702) by debbugs.gnu.org; 3 Mar 2025 13:21:17 +0000 Received: from localhost ([127.0.0.1]:46195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tp5jQ-0001mK-8C for submit@debbugs.gnu.org; Mon, 03 Mar 2025 08:21:16 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:47464) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tp5jK-0001li-Pi for 76702@debbugs.gnu.org; Mon, 03 Mar 2025 08:21:13 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-439a1e8ba83so42070735e9.3 for <76702@debbugs.gnu.org>; Mon, 03 Mar 2025 05:21:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741008064; x=1741612864; 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=lVFnA1aO+Uc6JRecWTc42i7zjNy8sZQIyFFX/UlQqvY=; b=LeIl2ZZ97aTA4BPbwddxL9Sb2GQiejO+IQQRB6nUmfk+WxnTaBnQ8Qj8v+Rn75l17k A+m7kH4z419dlIGH//FIjKsi0KL4I+iisZK9k8twmG+Tk4WdlQgogaxL7dpR+jPQYuSj xZfX4mhGzUmpy5ygq0okyVj+uTUbJfykmrhmrPxDdqTAIendz+mvMnRf+h0sOy4yjKks HxuxrUSF1o1ydlTkflHfzWMwoe/K3ZdhzZPGnfQlTFNNW6rUwlNOQsrofQV/fLDvYMIe 8HKTBD1JpcUN6Qv+eQmMcQic9cTj8VKo22/W49ATAkmS5jijK3C6ZqGJ9AYtc1HrXitw RETw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741008064; x=1741612864; 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=lVFnA1aO+Uc6JRecWTc42i7zjNy8sZQIyFFX/UlQqvY=; b=buc3+ddFqTNzAAz0HwsnHh9JxN6LCIFAeR3kypRNX4P4jHD9m4TJNfQ6PfnIDdwTNq 8wVqd3c88ouS2RxOFtf4SpLxAP2x2/LHELs0K9Ti61F34DkF+QI4HkeUs15FWF2XuVfP SVODtdH7FlWNnAmCv7G7GDNG19DZcad/gjHQiof2KN4VHMQ2z0XA3T1eZDO7czd0xHGP 7wTvR+ZwnZcraT1pcCQqq4ACOQNCPpU/9v/V+WHQsi4fAx2t0PxD5K0DkXsLRtzShIEc adnGAX413GTI0pyN0n6GlTXqEzcuUpCLDPaA34mpSkzMoix00IRs3R3MX3I6C41a/jaj svQw== X-Forwarded-Encrypted: i=1; AJvYcCUpQTvw7Gi+ZMlOPMF97beiopzcflg+sTW2zQHepijT7wA/l8i523drktPiNNymVSFvGOHmhg==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyFBMu37yAZgXvtdPIf3zLcsqfQXR/Sa8NzlGCdlGnJSP7XMPsx BuOKKssqBTR4GtobR7POMsBXuZZ+Wdgo0ey56js9Mlq9yhJRtlZz X-Gm-Gg: ASbGnctkbM1yeeDJrvG4wPA7iT0QsmO/acr3Z1CDs0SgtbVX14zHxsCX3adaWfDS9cg UBO07OI1Y1u0DDL56Gr3rpcD5utefXDIOjp/Z2w1OwFAK5gORAkIlw/su4ypg3gKzhzGnxFbkFn +Cu8pvwcRn6MfKzb8UBJXgxPan2bKVke4V7MhLr3EBnnDnv7Q59j/VRzkQn81MchylPP2FTgKuN 4YaO/NxPBNy61F6v8mS3419g8G42Eo/9DNN0EhWBgvC48PpN8pyO1B9nF9NuzEAUQdGM0XwfYr1 fOuq6AKImFThmYOoa7p8kjRXZd1lmIxaynJ3x438b0QNpljqLiWOyGoUWgnP7o5/UHcg10GOuyy 4YXERm+rUHbaivHwtizbWEs6n X-Google-Smtp-Source: AGHT+IGMqq/DUqZzEKNz2a4PYhHH0TJhztkEJLwpRumqWPcK6lnbUkW0G0e1ECFIhTlj2m9eKPxUEQ== X-Received: by 2002:a05:6000:1f8f:b0:38f:6287:6474 with SMTP id ffacd0b85a97d-390ec7cc2a5mr11335851f8f.15.1741008064041; Mon, 03 Mar 2025 05:21:04 -0800 (PST) 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-390e47a66bcsm14335259f8f.21.2025.03.03.05.21.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Mar 2025 05:21:03 -0800 (PST) Message-ID: <9745bbe4-3a97-4d08-8507-72110e77e2a9@draigBrady.com> Date: Mon, 3 Mar 2025 13:21:02 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: bug#76702: coreutils 9.1 cp --parents --preserve /dir/file fstat relative dir To: "Alan J. Goalby" , 76702@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: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76702 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 02/03/2025 15:18, Alan J. Goalby wrote: > When "cp --parents --preserve /dir/file /target/" needs to create > /target/dir/, it appears to try to Fstat information from relative > path "dir", not the actual parent path "/dir". > > E.g., "cd /tmp && mkdir NewDir && cp -a --parents /etc/passwd NewDir" > will fail, as (1) below - unless (2) /tmp/etc exists, or (3) use "cd > /", or (4) omit "--preserve". > > My enclosed cp-par-pres-demo.sh shows that: > > (1) Cp --parents --preserve /dir/file /target/" will > > * log ENOENT for relative "dir" for a missing /target/dir; > > * create that missing parent /target/dir with mode 700; > > * create a missing non-parent output correctly; and > > * return error status 1. > > (2) If ./dir exists, Cp takes /target/dir mode from it, not /dir. > > (3) With "cd /", this works normally, since "dir" is /dir. > > (4) Without --preserve, there is no error. > > This happens for Debian 12.9 coreutils 9.1-1, under linux 6.1.115 > amd64, on an ext4 partition, for root and other users, e.g. nobody. > And for an ext3 copy Chroot under linux 5.10.226. > > (md5sum --check verifies coreutils.md5sums lib*.msd5sums et al.) > > This does not happen for Debian 11.11 coreutils 8.32-4+b1, under linux > 5.10.226 amd64 on ext4, nor for earlier versions on i386 ext3. > > I enclose logs from those good Debian 11 and wrong Debian 12 runs. > > My other tests show this not happening for relative input paths. This should be fixed with: https://github.com/coreutils/coreutils/commit/c6b1fe434 It would be good to get that applied to Debian 12. thanks, Pádraig