[70135] trunk/base/src/port/port.tcl

jmr at macports.org jmr at macports.org
Fri Jul 30 00:57:16 PDT 2010


Revision: 70135
          http://trac.macports.org/changeset/70135
Author:   jmr at macports.org
Date:     2010-07-30 00:57:13 -0700 (Fri, 30 Jul 2010)
Log Message:
-----------
make actions that will fail due to insufficient privileges fail early (#25671)

Modified Paths:
--------------
    trunk/base/src/port/port.tcl

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2010-07-30 07:50:19 UTC (rev 70134)
+++ trunk/base/src/port/port.tcl	2010-07-30 07:57:13 UTC (rev 70135)
@@ -1484,6 +1484,18 @@
     }
 }
 
+# check if the install prefix is writable
+# should be called by actions that will modify it
+proc prefix_unwritable {} {
+    global macports::portdbpath
+    if {[file writable $portdbpath]} {
+        return 0
+    } else {
+        ui_error "Insufficient privileges to write to MacPorts install prefix."
+        return 1
+    }
+}
+
     
 proc parsePortSpec { vername varname optname {remainder ""} } {
     upvar $vername portversion
@@ -2217,7 +2229,7 @@
 proc action_activate { action portlist opts } {
     global macports::registry.format
     set status 0
-    if {[require_portlist portlist]} {
+    if {[require_portlist portlist] || [prefix_unwritable]} {
         return 1
     }
     foreachport $portlist {
@@ -2251,7 +2263,7 @@
 proc action_deactivate { action portlist opts } {
     global macports::registry.format
     set status 0
-    if {[require_portlist portlist]} {
+    if {[require_portlist portlist] || [prefix_unwritable]} {
         return 1
     }
     foreachport $portlist {
@@ -2412,7 +2424,7 @@
 proc action_setrequested { action portlist opts } {
     global macports::registry.format
     set status 0
-    if {[require_portlist portlist]} {
+    if {[require_portlist portlist] || [prefix_unwritable]} {
         return 1
     }
     # set or unset?
@@ -2440,7 +2452,7 @@
 
 
 proc action_upgrade { action portlist opts } {
-    if {[require_portlist portlist]} {
+    if {[require_portlist portlist] || [prefix_unwritable]} {
         return 1
     }
     # shared depscache for all ports in the list
@@ -2814,6 +2826,9 @@
             return 1
         }
     }
+    if {[prefix_unwritable]} {
+        return 1
+    }
 
     foreachport $portlist {
         if {![registry::entry_exists_for_name $portname]} {
@@ -3593,6 +3608,9 @@
     if {[require_portlist portlist]} {
         return 1
     }
+    if {($action == "install" || $action == "archive") && [prefix_unwritable]} {
+        return 1
+    }
     foreachport $portlist {
         # If we have a url, use that, since it's most specific
         # otherwise try to map the portname to a url
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100730/6b271fe0/attachment.html>


More information about the macports-changes mailing list