[54367] trunk/base/src/port1.0/portutil.tcl
jmr at macports.org
jmr at macports.org
Sat Jul 25 09:52:19 PDT 2009
Revision: 54367
http://trac.macports.org/changeset/54367
Author: jmr at macports.org
Date: 2009-07-25 09:52:18 -0700 (Sat, 25 Jul 2009)
Log Message:
-----------
fix reading of ${target}.asroot settings, and fix permission problems in reinplace (#20330)
Modified Paths:
--------------
trunk/base/src/port1.0/portutil.tcl
Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl 2009-07-25 14:53:17 UTC (rev 54366)
+++ trunk/base/src/port1.0/portutil.tcl 2009-07-25 16:52:18 UTC (rev 54367)
@@ -911,7 +911,7 @@
return -code error "reinplace copy failed"
}
- eval file attributes {$file} $attributes
+ fileAttrsAsRoot $file $attributes
file delete "$tmpfile"
}
@@ -1219,7 +1219,9 @@
if {$procedure != ""} {
set targetname [ditem_key $ditem name]
- if { [tbool ${targetname}.asroot] } {
+ set target [ditem_key $ditem provides]
+ global ${target}.asroot
+ if { [tbool ${target}.asroot] } {
elevateToRoot $targetname
}
@@ -2358,6 +2360,26 @@
}
##
+# Change attributes of file while running as root
+#
+# @param file the file in question
+# @param attributes the attributes for the file
+proc fileAttrsAsRoot {file attributes} {
+ global euid macportsuser
+ if {[getuid] == 0 && [geteuid] != 0} {
+ # Started as root, but not root now
+ seteuid $euid
+ ui_debug "euid changed to: [geteuid]"
+ ui_debug "setting attributes on $file"
+ eval file attributes {$file} $attributes
+ seteuid [name_to_uid "$macportsuser"]
+ ui_debug "euid changed to: [geteuid]"
+ } else {
+ eval file attributes {$file} $attributes
+ }
+}
+
+##
# Elevate privileges back to root.
#
# @param action the action for which privileges are being elevated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090725/abc7b4d2/attachment.html>
More information about the macports-changes
mailing list