From 520338b8dee90750e6be533b4f8145c5947c5af7 Mon Sep 17 00:00:00 2001 From: Blair Zajac Date: Sat, 12 Jan 2013 04:19:14 +0000 Subject: [PATCH] portextract::extract_main: use_dmg fails to mount DMG is user isn't root. The MacPorts user may not be able to mount a DMG with hdiutil; it will fail with an "hdiutil: attach failed - Device not configured" error. So only if a DMG is being used, elevate back to root to do the mount and unmount the DMG. git-svn-id: https://svn.macports.org/repository/macports/trunk/base@101504 d073be05-634f-4543-b044-5fe20cf6d1d6 --- src/port1.0/portextract.tcl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/port1.0/portextract.tcl b/src/port1.0/portextract.tcl index b9eb8033fe..dbdabb9c78 100644 --- a/src/port1.0/portextract.tcl +++ b/src/port1.0/portextract.tcl @@ -113,7 +113,7 @@ proc portextract::extract_start {args} { } proc portextract::extract_main {args} { - global UI_PREFIX filespath worksrcpath extract.dir usealtworkpath altprefix + global UI_PREFIX filespath worksrcpath extract.dir usealtworkpath altprefix use_dmg if {![exists distfiles] && ![exists extract.only]} { # nothing to do @@ -129,7 +129,19 @@ proc portextract::extract_main {args} { } else { option extract.args "'[option distpath]/$distfile'" } - if {[catch {command_exec extract} result]} { + + # If the MacPorts user does not have the privileges to mount a + # DMG then hdiutil will fail with this error: + # hdiutil: attach failed - Device not configured + # So elevate back to root. + if {[tbool use_dmg]} { + elevateToRoot {extract dmg} + } + set code [catch {command_exec extract} result] + if {[tbool use_dmg]} { + dropPrivileges + } + if {$code} { return -code error "$result" }