[37888] branches/gsoc08-privileges/base
pmagrath at macports.org
pmagrath at macports.org
Fri Jun 27 15:33:57 PDT 2008
Revision: 37888
http://trac.macosforge.org/projects/macports/changeset/37888
Author: pmagrath at macports.org
Date: 2008-06-27 15:33:57 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Move macportsuser variable (user to drop privileges to during fetch, configure, build, etc) to macports.conf. Allow setting of macportsuser variable with configure switch --with-macports-user=USER.
Modified Paths:
--------------
branches/gsoc08-privileges/base/aclocal.m4
branches/gsoc08-privileges/base/configure
branches/gsoc08-privileges/base/configure.ac
branches/gsoc08-privileges/base/doc/macports.conf.in
branches/gsoc08-privileges/base/src/port1.0/portmain.tcl
branches/gsoc08-privileges/base/src/port1.0/portutil.tcl
Modified: branches/gsoc08-privileges/base/aclocal.m4
===================================================================
--- branches/gsoc08-privileges/base/aclocal.m4 2008-06-27 20:42:04 UTC (rev 37887)
+++ branches/gsoc08-privileges/base/aclocal.m4 2008-06-27 22:33:57 UTC (rev 37888)
@@ -329,7 +329,25 @@
])
+# MP_CHECK_RUNUSER
+#-------------------------------------------------
+AC_DEFUN([MP_CHECK_RUNUSER],[
+ dnl if with user specifies --with-macports-user,
+ dnl use it. otherwise default to platform defaults
+ AC_REQUIRE([MP_PATH_MPCONFIGDIR])
+ AC_ARG_WITH(install-user, [AC_HELP_STRING([--with-macports-user=USER], [Specify user to drop privileges to, if possible, during compiles,etc.])], [ RUNUSR=$withval ] )
+
+ AC_MSG_CHECKING([for macports user])
+ if test "x$RUNUSR" = "x" ; then
+ RUNUSR=`id -un`
+ fi
+
+ AC_MSG_RESULT([$RUNUSR])
+ AC_SUBST(RUNUSR)
+])
+
+
# MP_SHARED_DIRECTORY
#-------------------------------------------------
AC_DEFUN([MP_SHARED_DIRECTORY],[
Modified: branches/gsoc08-privileges/base/configure
===================================================================
--- branches/gsoc08-privileges/base/configure 2008-06-27 20:42:04 UTC (rev 37887)
+++ branches/gsoc08-privileges/base/configure 2008-06-27 22:33:57 UTC (rev 37888)
@@ -729,6 +729,7 @@
DSTUSR
DSTGRP
TCL_PACKAGE_DIR
+RUNUSR
DSTMODE
MPAPPLICATIONSDIR
MPFRAMEWORKSDIR
@@ -1403,6 +1404,9 @@
Specify user ownership of installed files
--with-install-group=GROUP
Specify group ownership of installed files
+ --with-macports-user=USER
+ Specify user to drop privileges to, if possible,
+ during compiles,etc.
--with-directory-mode=MODE
Specify directory mode of installed directories
--with-shared-directory Use 0775 permissions for installed directories
@@ -6844,6 +6848,26 @@
+# Check whether --with-install-user was given.
+if test "${with_install_user+set}" = set; then
+ withval=$with_install_user; RUNUSR=$withval
+fi
+
+
+ { echo "$as_me:$LINENO: checking for macports user" >&5
+echo $ECHO_N "checking for macports user... $ECHO_C" >&6; }
+ if test "x$RUNUSR" = "x" ; then
+ RUNUSR=`id -un`
+ fi
+
+ { echo "$as_me:$LINENO: result: $RUNUSR" >&5
+echo "${ECHO_T}$RUNUSR" >&6; }
+
+
+
+
+
+
# Check whether --with-directory-mode was given.
if test "${with_directory_mode+set}" = set; then
withval=$with_directory_mode; DSTMODE=$withval
@@ -13241,6 +13265,7 @@
DSTUSR!$DSTUSR$ac_delim
DSTGRP!$DSTGRP$ac_delim
TCL_PACKAGE_DIR!$TCL_PACKAGE_DIR$ac_delim
+RUNUSR!$RUNUSR$ac_delim
DSTMODE!$DSTMODE$ac_delim
MPAPPLICATIONSDIR!$MPAPPLICATIONSDIR$ac_delim
MPFRAMEWORKSDIR!$MPFRAMEWORKSDIR$ac_delim
@@ -13293,7 +13318,7 @@
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 66; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 67; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
Modified: branches/gsoc08-privileges/base/configure.ac
===================================================================
--- branches/gsoc08-privileges/base/configure.ac 2008-06-27 20:42:04 UTC (rev 37887)
+++ branches/gsoc08-privileges/base/configure.ac 2008-06-27 22:33:57 UTC (rev 37888)
@@ -140,6 +140,7 @@
# Check for install ownership
MP_CHECK_INSTALLUSER
MP_CHECK_INSTALLGROUP
+MP_CHECK_RUNUSER
MP_DIRECTORY_MODE
MP_SHARED_DIRECTORY
Modified: branches/gsoc08-privileges/base/doc/macports.conf.in
===================================================================
--- branches/gsoc08-privileges/base/doc/macports.conf.in 2008-06-27 20:42:04 UTC (rev 37887)
+++ branches/gsoc08-privileges/base/doc/macports.conf.in 2008-06-27 22:33:57 UTC (rev 37888)
@@ -4,6 +4,9 @@
# Set the directory in which to install ports
prefix @prefix_expanded@
+# Set the user to run MacPorts compiles, etc as when privileges are dropped during an install
+macportsuser @RUNUSR@
+
# Where to store MacPorts working data
portdbpath @localstatedir_expanded@/macports
Modified: branches/gsoc08-privileges/base/src/port1.0/portmain.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portmain.tcl 2008-06-27 20:42:04 UTC (rev 37887)
+++ branches/gsoc08-privileges/base/src/port1.0/portmain.tcl 2008-06-27 22:33:57 UTC (rev 37888)
@@ -41,7 +41,7 @@
target_state ${org.macports.main} no
# define options
-options prefix name version revision epoch categories maintainers
+options prefix macportsuser name version revision epoch categories maintainers
options long_description description homepage
options worksrcdir filesdir distname portdbpath libpath distpath sources_conf os.platform os.version os.major os.arch os.endian platforms default_variants install.user install.group macosx_deployment_target
options universal_variant os.universal_supported
@@ -58,6 +58,7 @@
default workpath {[getportworkpath_from_buildpath $portbuildpath]}
default worksymlink {[file join $portpath work]}
default prefix /opt/local
+default macportsuser {[uid_to_name [getuid]]}
default x11prefix /usr/X11R6
default applications_dir /Applications/MacPorts
default frameworks_dir /Library/Frameworks
Modified: branches/gsoc08-privileges/base/src/port1.0/portutil.tcl
===================================================================
--- branches/gsoc08-privileges/base/src/port1.0/portutil.tcl 2008-06-27 20:42:04 UTC (rev 37887)
+++ branches/gsoc08-privileges/base/src/port1.0/portutil.tcl 2008-06-27 22:33:57 UTC (rev 37888)
@@ -1379,12 +1379,9 @@
# 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
+ global altprefix macportsuser euid egid usealtworkpath env applications_dir
# start gsoc08-privileges
-
- # TODO: move the macportsuser setting to macports.conf
- set macportsuser "[uid_to_name [getuid]]"
# descalate privileges - only ran if macports stated with sudo
if { [geteuid] == 0 } {
@@ -1413,12 +1410,16 @@
ui_debug "Privilege desclation not attempted as not running as root."
}
- # if unable to write to workpath, implies running without root privileges so use ~/.macports
+ # if unable to write to workpath, implies running without root privileges
+ # or a shared directory owned by the group so use ~/.macports
if { ![file writable $workpath] } {
-
- if { [getuid] !=0 } {
+
+ set userid [getuid]
+ set username [uid_to_name $userid]
+
+ if { $userid !=0 } {
ui_msg "Insufficient privileges to perform action for all users."
- ui_msg "Action will be performed for current user only."
+ ui_msg "Action will be performed for current user (${username}) only."
ui_msg "Install actions should be executed using sudo."
}
@@ -1431,7 +1432,7 @@
set userhome "$env(HOME)"
} else {
# the environment var isn't set, make an educated guess
- set userhome "/Users/[uid_to_name [getuid]]"
+ set userhome "/Users/${username}"
}
# set alternative prefix global variables
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080627/4c90ac5f/attachment.html
More information about the macports-changes
mailing list