From unknown Mon Jun 23 18:30:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9002: file-error Doing chown operation not permitted Resent-From: jidanni@jidanni.org Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Jul 2011 13:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9002 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 9002@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.130987110424563 (code B ref -1); Tue, 05 Jul 2011 13:06:02 +0000 Received: (at submit) by debbugs.gnu.org; 5 Jul 2011 13:05:04 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qe5JH-0006O4-MV for submit@debbugs.gnu.org; Tue, 05 Jul 2011 09:05:04 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qe5JF-0006NJ-QE for submit@debbugs.gnu.org; Tue, 05 Jul 2011 09:05:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qe5J9-00021T-Cm for submit@debbugs.gnu.org; Tue, 05 Jul 2011 09:04:56 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:53258) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qe5J9-00021P-3r for submit@debbugs.gnu.org; Tue, 05 Jul 2011 09:04:55 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qe5J7-0005N1-ID for bug-gnu-emacs@gnu.org; Tue, 05 Jul 2011 09:04:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qe5J5-000216-RY for bug-gnu-emacs@gnu.org; Tue, 05 Jul 2011 09:04:53 -0400 Received: from caiajhbdcaid.dreamhost.com ([208.97.132.83]:38793 helo=homiemail-a4.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qe5J5-00020t-Fo for bug-gnu-emacs@gnu.org; Tue, 05 Jul 2011 09:04:51 -0400 Received: from homiemail-a4.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a4.g.dreamhost.com (Postfix) with ESMTP id 645A551C063 for ; Tue, 5 Jul 2011 06:04:50 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:subject :date:message-id:mime-version:content-type; q=dns; s=jidanni.org ; b=gO0q47vLD6zTzb/AwL0mVW5wJ1v6i33Vt6Jj7QQbePIoJRFH3REZgbDxkXyH YfjiAtDlEbOeJ3aCHY7b2cgpxkGJ6nWZpysjKY71ah9XSDuFRz1FKFdcZx+h5Hrt F2Ocgt5c1ILzIj23ViP/gLN12jnrXi+yHNSh+OZTGsfQ2Q4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to :subject:date:message-id:mime-version:content-type; s= jidanni.org; bh=hO9cmIza549r4qLLjNf1SOgdKjg=; b=K8DhlIGWdyHnE4XE IUzhMNYzN7umwQLenaU7l08ClunqC+KZbB5g1qv80qCUimlvzCcS0xyS+iefQRro qElmHotSmxFHIDoPTFdbrDGfnhTeJjhi1dALivZzoE99QzXWJ1C1WXwxr7qEDhtF b4h8ldVPSAS7EfOwjvhH/8cAAEc= Received: from jidanni.org (218-163-2-223.dynamic.hinet.net [218.163.2.223]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a4.g.dreamhost.com (Postfix) with ESMTPSA id 010BB51C062 for ; Tue, 5 Jul 2011 06:04:49 -0700 (PDT) From: jidanni@jidanni.org Date: Tue, 05 Jul 2011 20:55:51 +0800 Message-ID: <878vscopig.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.5 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.5 (-----) R runs the command dired-do-rename. Try this: Have two directories, both owned by you, but on separate disks. Try to move a file that is NOT owned by you from one to the other. Move `/cf/updates/df.j3d' to `/home/jidanni/df.j3d' failed: (file-error Doing chown operation not permitted /home/jidanni/df.j3d) That is because emacs is not using the mv(1) command like it should, but instead resorting to a different error prone half home baked method or something. Tested on Debian. P.S., file-error: Doing chown #looks better than file-error Doing chown From unknown Mon Jun 23 18:30:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9002: file-error Doing chown operation not permitted Resent-From: Glenn Morris Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Jul 2011 21:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9002 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Paul Eggert Cc: 9002@debbugs.gnu.org Received: via spool by 9002-submit@debbugs.gnu.org id=B9002.131085167910079 (code B ref 9002); Sat, 16 Jul 2011 21:28:02 +0000 Received: (at 9002) by debbugs.gnu.org; 16 Jul 2011 21:27:59 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QiCP1-0002cW-0d for submit@debbugs.gnu.org; Sat, 16 Jul 2011 17:27:59 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QiCOy-0002cJ-Io for 9002@debbugs.gnu.org; Sat, 16 Jul 2011 17:27:57 -0400 Received: from localhost ([127.0.0.1]:46153) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiCOt-0001xY-7g; Sat, 16 Jul 2011 17:27:51 -0400 From: Glenn Morris References: <878vscopig.fsf@jidanni.org> X-Spook: counter terrorism illuminati afsatcom Cohiba InfoSec X-Ran: 4Z_Me|Nba78Yp7K)y@&b#1DM^i>=7rwA_KOQn#W95/Gb!@RiCwDD-Gvzb^UgwNh]N}~(ip X-Hue: red X-Attribution: GM Date: Sat, 16 Jul 2011 17:27:50 -0400 In-Reply-To: <878vscopig.fsf@jidanni.org> (jidanni@jidanni.org's message of "Tue, 05 Jul 2011 20:55:51 +0800") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.4 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) jidanni@jidanni.org wrote: > Have two directories, both owned by you, but on separate disks. > > Try to move a file that is NOT owned by you from one to the other. > > Move `/cf/updates/df.j3d' to `/home/jidanni/df.j3d' failed: > (file-error Doing chown operation not permitted /home/jidanni/df.j3d) Emacs 23.3 does not give this error, but the trunk does. This seems to be a result of the changes in http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8306 From unknown Mon Jun 23 18:30:56 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: jidanni@jidanni.org Subject: bug#9002: closed (Re: bug#9002: file-error Doing chown operation not permitted) Message-ID: References: <4E2209AE.1050808@cs.ucla.edu> <878vscopig.fsf@jidanni.org> X-Gnu-PR-Message: they-closed 9002 X-Gnu-PR-Package: emacs Reply-To: 9002@debbugs.gnu.org Date: Sat, 16 Jul 2011 22:00:05 +0000 Content-Type: multipart/mixed; boundary="----------=_1310853605-16143-1" This is a multi-part message in MIME format... ------------=_1310853605-16143-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #9002: file-error Doing chown operation not permitted which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 9002@debbugs.gnu.org. --=20 9002: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D9002 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1310853605-16143-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 9002-done) by debbugs.gnu.org; 16 Jul 2011 21:59:28 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QiCtT-0004B3-5q for submit@debbugs.gnu.org; Sat, 16 Jul 2011 17:59:27 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QiCtI-0004Aa-Kc; Sat, 16 Jul 2011 17:59:18 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 1E03239E80F2; Sat, 16 Jul 2011 14:59:11 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z1LbqqcXt1Ej; Sat, 16 Jul 2011 14:59:10 -0700 (PDT) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 6AAB839E80E1; Sat, 16 Jul 2011 14:59:10 -0700 (PDT) Message-ID: <4E2209AE.1050808@cs.ucla.edu> Date: Sat, 16 Jul 2011 14:59:10 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 MIME-Version: 1.0 To: Glenn Morris Subject: Re: bug#9002: file-error Doing chown operation not permitted References: <878vscopig.fsf@jidanni.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 9002-done Cc: 8306@debbugs.gnu.org, 9002-done@debbugs.gnu.org, jidanni@jidanni.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) On 07/16/11 14:27, Glenn Morris wrote: > Emacs 23.3 does not give this error, but the trunk does. This seems to > be a result of the changes in > > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8306 Right you are, and thanks for reporting it. I fixed it in bzr 105261 on the trunk. copy-file's help string says "try to transfer the uid and gid", with the implication that it's OK if the attempt fails and no diagnosis should be made. The doc uses stronger language for file modes ("This function always sets the file modes") so a diagnostic is more appropriate there and I left that one alone. ------------=_1310853605-16143-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 5 Jul 2011 13:05:04 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qe5JH-0006O4-MV for submit@debbugs.gnu.org; Tue, 05 Jul 2011 09:05:04 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qe5JF-0006NJ-QE for submit@debbugs.gnu.org; Tue, 05 Jul 2011 09:05:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qe5J9-00021T-Cm for submit@debbugs.gnu.org; Tue, 05 Jul 2011 09:04:56 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:53258) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qe5J9-00021P-3r for submit@debbugs.gnu.org; Tue, 05 Jul 2011 09:04:55 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qe5J7-0005N1-ID for bug-gnu-emacs@gnu.org; Tue, 05 Jul 2011 09:04:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qe5J5-000216-RY for bug-gnu-emacs@gnu.org; Tue, 05 Jul 2011 09:04:53 -0400 Received: from caiajhbdcaid.dreamhost.com ([208.97.132.83]:38793 helo=homiemail-a4.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qe5J5-00020t-Fo for bug-gnu-emacs@gnu.org; Tue, 05 Jul 2011 09:04:51 -0400 Received: from homiemail-a4.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a4.g.dreamhost.com (Postfix) with ESMTP id 645A551C063 for ; Tue, 5 Jul 2011 06:04:50 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:subject :date:message-id:mime-version:content-type; q=dns; s=jidanni.org ; b=gO0q47vLD6zTzb/AwL0mVW5wJ1v6i33Vt6Jj7QQbePIoJRFH3REZgbDxkXyH YfjiAtDlEbOeJ3aCHY7b2cgpxkGJ6nWZpysjKY71ah9XSDuFRz1FKFdcZx+h5Hrt F2Ocgt5c1ILzIj23ViP/gLN12jnrXi+yHNSh+OZTGsfQ2Q4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to :subject:date:message-id:mime-version:content-type; s= jidanni.org; bh=hO9cmIza549r4qLLjNf1SOgdKjg=; b=K8DhlIGWdyHnE4XE IUzhMNYzN7umwQLenaU7l08ClunqC+KZbB5g1qv80qCUimlvzCcS0xyS+iefQRro qElmHotSmxFHIDoPTFdbrDGfnhTeJjhi1dALivZzoE99QzXWJ1C1WXwxr7qEDhtF b4h8ldVPSAS7EfOwjvhH/8cAAEc= Received: from jidanni.org (218-163-2-223.dynamic.hinet.net [218.163.2.223]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a4.g.dreamhost.com (Postfix) with ESMTPSA id 010BB51C062 for ; Tue, 5 Jul 2011 06:04:49 -0700 (PDT) From: jidanni@jidanni.org To: bug-gnu-emacs@gnu.org Subject: file-error Doing chown operation not permitted Date: Tue, 05 Jul 2011 20:55:51 +0800 Message-ID: <878vscopig.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.5 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.5 (-----) R runs the command dired-do-rename. Try this: Have two directories, both owned by you, but on separate disks. Try to move a file that is NOT owned by you from one to the other. Move `/cf/updates/df.j3d' to `/home/jidanni/df.j3d' failed: (file-error Doing chown operation not permitted /home/jidanni/df.j3d) That is because emacs is not using the mv(1) command like it should, but instead resorting to a different error prone half home baked method or something. Tested on Debian. P.S., file-error: Doing chown #looks better than file-error Doing chown ------------=_1310853605-16143-1-- From unknown Mon Jun 23 18:30:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9002: file-error Doing chown operation not permitted Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Jul 2011 01:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9002 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Cc: 9002@debbugs.gnu.org Received: via spool by 9002-submit@debbugs.gnu.org id=B9002.13108656904927 (code B ref 9002); Sun, 17 Jul 2011 01:22:02 +0000 Received: (at 9002) by debbugs.gnu.org; 17 Jul 2011 01:21:30 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QiG2z-0001HQ-2X for submit@debbugs.gnu.org; Sat, 16 Jul 2011 21:21:29 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QiG2w-0001HC-Hz for 9002@debbugs.gnu.org; Sat, 16 Jul 2011 21:21:27 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id BD9C539E80F2 for <9002@debbugs.gnu.org>; Sat, 16 Jul 2011 18:21:20 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bz5NhP6mLTRW for <9002@debbugs.gnu.org>; Sat, 16 Jul 2011 18:21:20 -0700 (PDT) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 5010439E80F0 for <9002@debbugs.gnu.org>; Sat, 16 Jul 2011 18:21:20 -0700 (PDT) Message-ID: <4E22390B.4010009@cs.ucla.edu> Date: Sat, 16 Jul 2011 18:21:15 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 MIME-Version: 1.0 References: <878vscopig.fsf@jidanni.org> <4E2209AE.1050808@cs.ucla.edu> In-Reply-To: <4E2209AE.1050808@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.4 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.4 (--) On 07/16/11 14:59, Paul Eggert wrote: > copy-file's help string says "try to > transfer the uid and gid", with the implication that it's OK > if the attempt fails and no diagnosis should be made. In further building/testing I ran into a problem with that patch: it runs afoul of fchown's __attribute__((warn_unused_result)) in recent glibc versions. I've installed the following further patch to address this: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-07-16 23:40:44 +0000 +++ src/ChangeLog 2011-07-17 01:18:51 +0000 @@ -1,3 +1,11 @@ +2011-07-17 Paul Eggert + + * fileio.c (Fcopy_file): Pacify gcc re fchown. (Bug#9002) + This works around a problem with the previous change to Fcopy_file. + Recent glibc declares fchown with __attribute__((warn_unused_result)), + and without this change, GCC might complain about discarding + fchown's return value. + 2011-07-16 Juanma Barranquero * makefile.w32-in (GLOBAL_SOURCES): Add gnutls.c (followup to bug#9059). === modified file 'src/fileio.c' --- src/fileio.c 2011-07-16 21:53:38 +0000 +++ src/fileio.c 2011-07-17 01:18:51 +0000 @@ -38,6 +38,8 @@ #include #endif +#include + #include "lisp.h" #include "intervals.h" #include "buffer.h" @@ -1960,7 +1962,7 @@ if (input_file_statable_p) { if (!NILP (preserve_uid_gid)) - fchown (ofd, st.st_uid, st.st_gid); + ignore_value (fchown (ofd, st.st_uid, st.st_gid)); if (fchmod (ofd, st.st_mode & 07777) != 0) report_file_error ("Doing chmod", Fcons (newname, Qnil)); } From unknown Mon Jun 23 18:30:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9002: file-error Doing chown operation not permitted Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Jul 2011 17:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9002 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 9002@debbugs.gnu.org Received: via spool by 9002-submit@debbugs.gnu.org id=B9002.13110098681023 (code B ref 9002); Mon, 18 Jul 2011 17:25:02 +0000 Received: (at 9002) by debbugs.gnu.org; 18 Jul 2011 17:24:28 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QirYR-0000GR-RK for submit@debbugs.gnu.org; Mon, 18 Jul 2011 13:24:28 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QirYO-0000GC-AK for 9002@debbugs.gnu.org; Mon, 18 Jul 2011 13:24:26 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 0B10B39E80E0 for <9002@debbugs.gnu.org>; Mon, 18 Jul 2011 10:24:18 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yZifeWbOWC1K for <9002@debbugs.gnu.org>; Mon, 18 Jul 2011 10:24:17 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 3332F39E80F7 for <9002@debbugs.gnu.org>; Mon, 18 Jul 2011 10:24:17 -0700 (PDT) Message-ID: <4E246C36.3070706@cs.ucla.edu> Date: Mon, 18 Jul 2011 10:24:06 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Thunderbird/3.1.11 MIME-Version: 1.0 References: <878vscopig.fsf@jidanni.org> <4E2209AE.1050808@cs.ucla.edu> <4E22390B.4010009@cs.ucla.edu> In-Reply-To: <4E22390B.4010009@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.1 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.1 (---) In yet more testing I found a couple more issues. First, many systems allow you to change gid on files that you can't set the uid of, if you're a member of the group and own the file. Second, if we can't set the uid and/or gid we shouldn't enable the setuid and/or gid bits, as the result would be setuid and/or setgid to the wrong user. I pushed the following further patch into the trunk. * fileio.c (Fcopy_file): Adjust mode if fchown fails. (Bug#9002) If fchown fails to set both uid and gid, try to set just gid, as that is sometimes allowed. Adjust the file's mode to eliminate setuid or setgid bits that are inappropriate if fchown fails. === modified file 'src/fileio.c' --- src/fileio.c 2011-07-17 01:18:51 +0000 +++ src/fileio.c 2011-07-18 17:15:29 +0000 @@ -38,8 +38,6 @@ #include #endif -#include - #include "lisp.h" #include "intervals.h" #include "buffer.h" @@ -1961,9 +1959,21 @@ owner and group. */ if (input_file_statable_p) { + int mode_mask = 07777; if (!NILP (preserve_uid_gid)) - ignore_value (fchown (ofd, st.st_uid, st.st_gid)); - if (fchmod (ofd, st.st_mode & 07777) != 0) + { + /* Attempt to change owner and group. If that doesn't work + attempt to change just the group, as that is sometimes allowed. + Adjust the mode mask to eliminate setuid or setgid bits + that are inappropriate if the owner and group are wrong. */ + if (fchown (ofd, st.st_uid, st.st_gid) != 0) + { + mode_mask &= ~06000; + if (fchown (ofd, -1, st.st_gid) == 0) + mode_mask |= 02000; + } + } + if (fchmod (ofd, st.st_mode & mode_mask) != 0) report_file_error ("Doing chmod", Fcons (newname, Qnil)); } #endif /* not MSDOS */