[69471] trunk/base/src/port1.0/fetch_common.tcl

jmr at macports.org jmr at macports.org
Wed Jul 7 07:27:26 PDT 2010


Revision: 69471
          http://trac.macports.org/changeset/69471
Author:   jmr at macports.org
Date:     2010-07-07 07:27:26 -0700 (Wed, 07 Jul 2010)
Log Message:
-----------
reacquire root privileges when running ping

Modified Paths:
--------------
    trunk/base/src/port1.0/fetch_common.tcl

Modified: trunk/base/src/port1.0/fetch_common.tcl
===================================================================
--- trunk/base/src/port1.0/fetch_common.tcl	2010-07-07 14:26:35 UTC (rev 69470)
+++ trunk/base/src/port1.0/fetch_common.tcl	2010-07-07 14:27:26 UTC (rev 69471)
@@ -232,6 +232,14 @@
             continue
         }
 
+        # can't do the ping with dropped privileges (though it works fine if we didn't start as root)
+        if {[getuid] == 0 && [geteuid] != 0} {
+            set oldeuid [geteuid]
+            set oldegid [getegid]
+            seteuid 0
+            setegid 0
+        }
+
         foreach site $urllist {
             regexp $hostregex $site -> host
 
@@ -269,6 +277,11 @@
             ui_debug "$host ping time is $pingtimes($host)"
         }
 
+        if {[info exists oldeuid]} {
+            setegid $oldegid
+            seteuid $oldeuid
+        }
+
         set pinglist {}
         foreach site $urllist {
             regexp $hostregex $site -> host
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100707/f92e759b/attachment.html>


More information about the macports-changes mailing list