[38325] branches/gsoc08-privileges/base/src/port1.0
pmagrath at macports.org
pmagrath at macports.org
Tue Jul 15 13:58:33 PDT 2008
Revision: 38325
http://trac.macosforge.org/projects/macports/changeset/38325
Author: pmagrath at macports.org
Date: 2008-07-15 13:58:33 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
Add new patch.asroot, configure.asroot, build.asroot, destroot.asroot and install.asroot options to Portfile format and supporting code.
Modified Paths:
--------------
branches/gsoc08-privileges/base/src/port1.0/portbuild.tcl
branches/gsoc08-privileges/base/src/port1.0/portconfigure.tcl
branches/gsoc08-privileges/base/src/port1.0/portdestroot.tcl
branches/gsoc08-privileges/base/src/port1.0/portinstall.tcl
branches/gsoc08-privileges/base/src/port1.0/portpatch.tcl
Modified: branches/gsoc08-privileges/base/src/port1.0/portbuild.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portbuild.tcl 2008-07-15 20:52:31 UTC (rev 38324)
+++ branches/gsoc08-privileges/base/src/port1.0/portbuild.tcl 2008-07-15 20:58:33 UTC (rev 38325)
@@ -42,8 +42,10 @@
options build.target
options build.nice
options build.jobs
+options build.asroot
commands build parallel_build
# defaults
+default build.asroot no
default build.dir {${workpath}/${worksrcdir}}
default build.cmd {[build_getmaketype]}
default build.nice {${buildnicevalue}}
@@ -133,13 +135,32 @@
}
proc build_start {args} {
- global UI_PREFIX
+ global UI_PREFIX build.asroot macportsuser euid egid
if {[string length [option build.target]]} {
ui_msg "$UI_PREFIX [format [msgcat::mc "Building %s with target %s"] [option portname] [option build.target]]"
} else {
ui_msg "$UI_PREFIX [format [msgcat::mc "Building %s"] [option portname]]"
}
+
+ # start gsoc08-privileges
+ if { [tbool build.asroot] } {
+ # if port is marked as needing root
+ if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
+ # if started with sudo but have dropped the privileges
+ ui_debug "Can't run install on this port without elevated privileges."
+ ui_debug "Going to escalate privileges back to root."
+ setegid $egid
+ seteuid $euid
+ ui_debug "euid changed to: [geteuid]. egid changed to: [getegid]."
+ }
+
+ if { [getuid] != 0 } {
+ return -code error "You can not run this port without elevated privileges. You need to re-run with 'sudo port'.";
+ }
+ }
+ # end gsoc08-privileges
+
}
proc build_main {args} {
Modified: branches/gsoc08-privileges/base/src/port1.0/portconfigure.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portconfigure.tcl 2008-07-15 20:52:31 UTC (rev 38324)
+++ branches/gsoc08-privileges/base/src/port1.0/portconfigure.tcl 2008-07-15 20:58:33 UTC (rev 38325)
@@ -52,6 +52,9 @@
default xmkmf.dir {${worksrcpath}}
default use_configure yes
+options configure.asroot
+default configure.asroot no
+
# Configure special environment variables.
# We could have m32/m64/march/mtune be global configurable at some point.
options configure.m32 configure.m64 configure.march configure.mtune
@@ -137,9 +140,28 @@
set_ui_prefix
proc configure_start {args} {
- global UI_PREFIX
+ global UI_PREFIX macportsuser euid egid
ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option portname]]"
+
+ # start gsoc08-privileges
+ if { [tbool configure.asroot] } {
+ # if port is marked as needing root
+ if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
+ # if started with sudo but have dropped the privileges
+ ui_debug "Can't run install on this port without elevated privileges."
+ ui_debug "Going to escalate privileges back to root."
+ setegid $egid
+ seteuid $euid
+ ui_debug "euid changed to: [geteuid]. egid changed to: [getegid]."
+ }
+
+ if { [getuid] != 0 } {
+ return -code error "You can not run this port without elevated privileges. You need to re-run with 'sudo port'.";
+ }
+ }
+ # end gsoc08-privileges
+
}
# internal function to determine canonical system name for configure
Modified: branches/gsoc08-privileges/base/src/port1.0/portdestroot.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portdestroot.tcl 2008-07-15 20:52:31 UTC (rev 38324)
+++ branches/gsoc08-privileges/base/src/port1.0/portdestroot.tcl 2008-07-15 20:58:33 UTC (rev 38325)
@@ -42,7 +42,7 @@
# define options
options destroot.target destroot.destdir destroot.clean destroot.keepdirs destroot.umask
-options destroot.violate_mtree
+options destroot.violate_mtree destroot.asroot
options startupitem.create startupitem.requires startupitem.init
options startupitem.name startupitem.start startupitem.stop startupitem.restart
options startupitem.type startupitem.executable
@@ -51,6 +51,7 @@
commands destroot
# Set defaults
+default destroot.asroot no
default destroot.dir {${build.dir}}
default destroot.cmd {${build.cmd}}
default destroot.pre_args {${destroot.target}}
@@ -87,7 +88,7 @@
proc destroot_start {args} {
global UI_PREFIX prefix portname destroot portresourcepath os.platform destroot.clean
- global destroot::oldmask destroot.umask macportsuser euid egid
+ global destroot::oldmask destroot.umask destroot.asroot macportsuser euid egid
ui_msg "$UI_PREFIX [format [msgcat::mc "Staging %s into destroot"] ${portname}]"
@@ -101,6 +102,10 @@
seteuid $euid
ui_debug "euid changed to: [geteuid]. egid changed to: [getegid]."
}
+
+ if { [tbool destroot.asroot] && [getuid] != 0 } {
+ return -code error "You can not run this port without elevated privileges. You need to re-run with 'sudo port'.";
+ }
# end gsoc08-privileges
set oldmask [umask ${destroot.umask}]
Modified: branches/gsoc08-privileges/base/src/port1.0/portinstall.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portinstall.tcl 2008-07-15 20:52:31 UTC (rev 38324)
+++ branches/gsoc08-privileges/base/src/port1.0/portinstall.tcl 2008-07-15 20:58:33 UTC (rev 38325)
@@ -44,20 +44,36 @@
}
target_prerun ${org.macports.install} install_start
+# define options
+options install.asroot
+
+# Set defaults
+default install.asroot yes
+
set_ui_prefix
proc install_start {args} {
- global UI_PREFIX portname portversion portrevision variations portvariants macportsuser euid egid
+ global UI_PREFIX portname portversion portrevision variations portvariants
+ global macportsuser euid egid install.asroot
ui_msg "$UI_PREFIX [format [msgcat::mc "Installing %s @%s_%s%s"] $portname $portversion $portrevision $portvariants]"
# start gsoc08-privileges
- if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
- # if started with sudo but have dropped the privileges
- ui_debug "Can't run install without elevated privileges."
- ui_debug "Going to escalate privileges back to root."
- setegid $egid
- seteuid $euid
- ui_debug "euid changed to: [geteuid]. egid changed to: [getegid]."
+ ui_msg [tbool install.asroot]
+
+ if { [tbool install.asroot] } {
+ # if port isn't marked as not needing root
+ if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
+ # if started with sudo but have dropped the privileges
+ ui_debug "Can't run install on this port without elevated privileges."
+ ui_debug "Going to escalate privileges back to root."
+ setegid $egid
+ seteuid $euid
+ ui_debug "euid changed to: [geteuid]. egid changed to: [getegid]."
+ }
+
+ if { [getuid] != 0 } {
+ return -code error "You can not run this port without elevated privileges. You need to re-run with 'sudo port'.";
+ }
}
# end gsoc08-privileges
Modified: branches/gsoc08-privileges/base/src/port1.0/portpatch.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portpatch.tcl 2008-07-15 20:52:31 UTC (rev 38324)
+++ branches/gsoc08-privileges/base/src/port1.0/portpatch.tcl 2008-07-15 20:58:33 UTC (rev 38325)
@@ -41,13 +41,16 @@
# Add command patch
commands patch
+
+options patch.asroot
# Set up defaults
+default patch.asroot no
default patch.dir {${worksrcpath}}
default patch.cmd patch
default patch.pre_args -p0
proc patch_main {args} {
- global UI_PREFIX
+ global UI_PREFIX patch.asroot macportsuser euid egid
# First make sure that patchfiles exists and isn't stubbed out.
if {![exists patchfiles]} {
@@ -55,6 +58,24 @@
}
ui_msg "$UI_PREFIX [format [msgcat::mc "Applying patches to %s"] [option portname]]"
+
+ # start gsoc08-privileges
+ if { [tbool patch.asroot] } {
+ # if port is marked as needing root
+ if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
+ # if started with sudo but have dropped the privileges
+ ui_debug "Can't run install on this port without elevated privileges."
+ ui_debug "Going to escalate privileges back to root."
+ setegid $egid
+ seteuid $euid
+ ui_debug "euid changed to: [geteuid]. egid changed to: [getegid]."
+ }
+
+ if { [getuid] != 0 } {
+ return -code error "You can not run this port without elevated privileges. You need to re-run with 'sudo port'.";
+ }
+ }
+ # end gsoc08-privileges
foreach patch [option patchfiles] {
set patch_file [getdistname $patch]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080715/d3549180/attachment-0001.html
More information about the macports-changes
mailing list