From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RVFGx-0006GU-KO for garchives@archives.gentoo.org; Tue, 29 Nov 2011 04:26:23 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8AB3121C029; Tue, 29 Nov 2011 04:26:10 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 5C1B921C029 for ; Tue, 29 Nov 2011 04:26:10 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D50071B400C for ; Tue, 29 Nov 2011 04:26:09 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id E9F7080044 for ; Tue, 29 Nov 2011 04:26:08 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/util/movefile.py X-VCS-Directories: pym/portage/util/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: ee59f1c63ecc54ad286c82c0adb2ae74011de69e Date: Tue, 29 Nov 2011 04:26:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 7c3b45d6-3f68-4053-a987-030a3fbf2b5a X-Archives-Hash: 7520cfdebeda03c457a37d428e7ac9de commit: ee59f1c63ecc54ad286c82c0adb2ae74011de69e Author: Zac Medico gentoo org> AuthorDate: Tue Nov 29 04:25:54 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Nov 29 04:25:54 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Dee59f1c6 movefile: chown/mod before rename --- pym/portage/util/movefile.py | 22 +++++++--------------- 1 files changed, 7 insertions(+), 15 deletions(-) diff --git a/pym/portage/util/movefile.py b/pym/portage/util/movefile.py index c205fe9..d15291a 100644 --- a/pym/portage/util/movefile.py +++ b/pym/portage/util/movefile.py @@ -16,6 +16,10 @@ from portage.localization import _ from portage.process import spawn from portage.util import writemsg =20 +def _apply_stat(os, src_stat, dest): + os.chown(dest, src_stat.st_uid, src_stat.st_gid) + os.chmod(dest, stat.S_IMODE(src_stat.st_mode)) + if hasattr(_os, "getxattr"): # Python >=3D3.3 def _copyxattr(src, dest): @@ -167,19 +171,20 @@ def movefile(src, dest, newmtime=3DNone, sstat=3DNo= ne, mysettings=3DNone, return None # Invalid cross-device-link 'bind' mounted or actually Cross-Device if renamefailed: - didcopy=3D0 if stat.S_ISREG(sstat[stat.ST_MODE]): dest_tmp =3D dest + "#new" try: # For safety copy then move it over. if selinux_enabled: selinux.copyfile(src, dest_tmp) _copyxattr(src, dest_tmp) + _apply_stat(os, sstat, dest_tmp) selinux.rename(dest_tmp, dest) else: shutil.copyfile(src, dest_tmp) _copyxattr(src, dest_tmp) + _apply_stat(os, sstat, dest_tmp) os.rename(dest_tmp, dest) - didcopy=3D1 + os.unlink(src) except SystemExit as e: raise except Exception as e: @@ -196,19 +201,6 @@ def movefile(src, dest, newmtime=3DNone, sstat=3DNon= e, mysettings=3DNone, "dest": _unicode_decode(dest, encoding=3Dencoding)}, noiselevel=3D-= 1) writemsg("!!! %s\n" % a, noiselevel=3D-1) return None # failure - try: - if didcopy: - # didcopy is True only if S_ISREG returned True - os.chown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) - os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset = on chown - os.unlink(src) - except SystemExit as e: - raise - except Exception as e: - print(_("!!! Failed to chown/chmod/unlink in movefile()")) - print("!!!",dest) - print("!!!",e) - return None =20 # Always use stat_obj[stat.ST_MTIME] for the integral timestamp which # is returned, since the stat_obj.st_mtime float attribute rounds *up*