[38640] branches/gsoc08-privileges/base/src/port1.0

pmagrath at macports.org pmagrath at macports.org
Sat Jul 26 09:07:58 PDT 2008


Revision: 38640
          http://trac.macosforge.org/projects/macports/changeset/38640
Author:   pmagrath at macports.org
Date:     2008-07-26 09:07:57 -0700 (Sat, 26 Jul 2008)
Log Message:
-----------
Fix various clean target related bugs caused by the new privilege dropping code.

Modified Paths:
--------------
    branches/gsoc08-privileges/base/src/port1.0/portclean.tcl
    branches/gsoc08-privileges/base/src/port1.0/portutil.tcl

Modified: branches/gsoc08-privileges/base/src/port1.0/portclean.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portclean.tcl	2008-07-26 13:27:52 UTC (rev 38639)
+++ branches/gsoc08-privileges/base/src/port1.0/portclean.tcl	2008-07-26 16:07:57 UTC (rev 38640)
@@ -51,24 +51,24 @@
     ui_msg "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] [option portname]]"
     
 	# start gsoc08-privileges
-	if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } { 
+	#if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } { 
 	# if started with sudo but have dropped the privileges
-		ui_debug "Can't guarantee a good clean without elevated privileges."
+	#	ui_debug "Can't guarantee a good clean without elevated privileges."
 		# TODO: modify so that privilege descalation is conditional on needing
 		# to clean a directory in the /opt hierarchy.
-		ui_debug "Going to escalate privileges back to root."
-		seteuid $euid	
-		setegid $egid
-		ui_debug "euid changed to: [geteuid]"
-		ui_debug "egid changed to: [getegid]"
-	}
+	#	ui_debug "Going to escalate privileges back to root."
+	#	seteuid $euid	
+	#	setegid $egid
+	#	ui_debug "euid changed to: [geteuid]"
+	#	ui_debug "egid changed to: [getegid]"
+	#}
 	# end gsoc08-privileges
 }
 
 proc clean_main {args} {
     global UI_PREFIX
 	global ports_clean_dist ports_clean_work ports_clean_archive
-	global ports_clean_all
+	global ports_clean_all usealtworkpath
 
 	if {[info exists ports_clean_all] && $ports_clean_all == "yes" || \
 		[info exists ports_clean_dist] && $ports_clean_dist == "yes"} {
@@ -87,10 +87,35 @@
 		 ui_info "$UI_PREFIX [format [msgcat::mc "Removing build directory for %s"] [option portname]]"
 		 clean_work
 	}
-
+	
+	# start gsoc-08 privileges
+	if {$usealtworkpath == "yes"} {
+		ui_info "$UI_PREFIX [format [msgcat::mc "Removing alt source directory for %s"] [option portname]]"
+		clean_altsource
+	}
+	# end gsoc-08 privileges
+	
     return 0
 }
 
+proc clean_altsource {args} {
+    global usealtworkpath worksymlink
+    
+    set sourcepath [string map {"work" ""} $worksymlink] 
+
+	if {[file isdirectory $sourcepath]} {
+		ui_debug "Removing directory: ${sourcepath}"
+		if {[catch {delete $sourcepath} result]} {
+			ui_debug "$::errorInfo"
+			ui_error "$result"
+		}
+	} else {
+		ui_debug "No alt source directory found to remove."
+	}
+
+	return 0
+}
+
 #
 # Remove the directory where the distfiles reside.
 # This is crude, but works.
@@ -172,7 +197,7 @@
 			ui_error "$result"
 		}
 	} else {
-		ui_debug "No work directory found to remove."
+		ui_debug "No work directory found to remove at: ${portbuildpath}"
 	}
 
 	# Clean symlink, if necessary

Modified: branches/gsoc08-privileges/base/src/port1.0/portutil.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portutil.tcl	2008-07-26 13:27:52 UTC (rev 38639)
+++ branches/gsoc08-privileges/base/src/port1.0/portutil.tcl	2008-07-26 16:07:57 UTC (rev 38640)
@@ -1396,7 +1396,7 @@
 # open file to store name of completed targets
 proc open_statefile {args} {
     global workpath worksymlink place_worksymlink portname portpath ports_ignore_older
-    global altprefix macportsuser euid egid usealtworkpath env applications_dir
+    global altprefix macportsuser euid egid usealtworkpath env applications_dir portbuildpath
     
 	# start gsoc08-privileges
 
@@ -1458,6 +1458,7 @@
 		# get alternative paths
 		set newworkpath "$altprefix/[ string range $workpath 1 end ]"
 		set newworksymlink "$altprefix/[ string range $worksymlink 1 end ]"
+		set newportbuildpath "$altprefix/[ string range $portbuildpath 1 end ]"
 		
 		set sourcepath [string map {"work" ""} $worksymlink] 
 		set newsourcepath "$altprefix/[ string range $sourcepath 1 end ]"
@@ -1469,12 +1470,15 @@
 			ui_debug "$newsourcepath created"
 			ui_debug "Going to copy: ${sourcepath}Portfile"
 			file copy ${sourcepath}Portfile $newsourcepath
-			ui_debug "Going to copy: ${sourcepath}files"
-			file copy ${sourcepath}files $newsourcepath
+			if {[file exists ${sourcepath}files] } {
+				ui_debug "Going to copy: ${sourcepath}files"
+				file copy ${sourcepath}files $newsourcepath
+			}
 		}
 		
 		set workpath $newworkpath
 		set worksymlink $newworksymlink
+		set portbuildpath $newportbuildpath
 		
 		ui_debug "Going to use $newworkpath for statefile."
     }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080726/7a7aa54a/attachment.html 


More information about the macports-changes mailing list