[79025] trunk/base

jmr at macports.org jmr at macports.org
Mon May 30 14:42:22 PDT 2011


Revision: 79025
          http://trac.macports.org/changeset/79025
Author:   jmr at macports.org
Date:     2011-05-30 14:42:19 -0700 (Mon, 30 May 2011)
Log Message:
-----------
create RUNUSR at install time and default to 'macports'

Modified Paths:
--------------
    trunk/base/Makefile.in
    trunk/base/Mk/macports.autoconf.mk.in
    trunk/base/aclocal.m4
    trunk/base/configure
    trunk/base/configure.ac
    trunk/base/portmgr/dmg/postflight

Modified: trunk/base/Makefile.in
===================================================================
--- trunk/base/Makefile.in	2011-05-30 20:12:43 UTC (rev 79024)
+++ trunk/base/Makefile.in	2011-05-30 21:42:19 UTC (rev 79025)
@@ -37,6 +37,31 @@
 	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 macports-pubkey.pem  $(DESTDIR)${datadir}/macports/
 # Only run these scripts when not building in a destroot
 ifeq ($(DESTDIR),)
+# create run user if it doesn't exist
+	@if test -n "${DSCL}" -a -n "${DSEDITGROUP}" ; then \
+        if ! ${DSEDITGROUP} -q -o read ${RUNUSR} > /dev/null 2>&1 ; then \
+            if test $$USER = root; then \
+                echo "Creating group \"${RUNUSR}\"" ; \
+                ${DSEDITGROUP} -q -o create -n . ${RUNUSR} ; \
+            else \
+                echo "Not creating group \"${RUNUSR}\" (not root)" ; \
+            fi ; \
+        fi ; \
+        if ! ${DSCL} -q . -list /Users/${RUNUSR} > /dev/null 2>&1 ; then \
+            if test $$USER = root; then \
+                echo "Creating user \"${RUNUSR}\"" ; \
+                ${DSCL} -q . -create /Users/${RUNUSR} Password * ; \
+                ${DSCL} -q . -create /Users/${RUNUSR} UniqueID $(($(${DSCL} . -list /Users UniqueID | /usr/bin/awk '{print $2}' | sort -ug | tail -1)+1)) ; \
+                ${DSCL} -q . -create /Users/${RUNUSR} PrimaryGroupID $(${DSCL} -q . -read /Groups/${RUNUSR} PrimaryGroupID | /usr/bin/awk '{print $2}') ; \
+                ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory /dev/null ; \
+                ${DSCL} -q . -create /Users/${RUNUSR} UserShell /usr/bin/false ; \
+            else \
+                echo "Not creating user \"${RUNUSR}\" (not root)" ; \
+            fi ; \
+        fi ; \
+    else \
+        echo "Can't find ${DSCL} / ${DSEDITGROUP}, not creating user \"${RUNUSR}\"" ; \
+    fi
 # Add [default] tag to the central MacPorts repository, if it isn't already
 	$(TCLSH) src/upgrade_sources_conf_default.tcl "${prefix}"
 # Convert image directories (and direct mode installs) to image archives

Modified: trunk/base/Mk/macports.autoconf.mk.in
===================================================================
--- trunk/base/Mk/macports.autoconf.mk.in	2011-05-30 20:12:43 UTC (rev 79024)
+++ trunk/base/Mk/macports.autoconf.mk.in	2011-05-30 21:42:19 UTC (rev 79025)
@@ -52,11 +52,13 @@
 TCL_PACKAGE_DIR		= @TCL_PACKAGE_DIR@
 macports_tcl_dir	= @macports_tcl_dir@
 
+DSCL			= @DSCL@
+DSEDITGROUP		= @DSEDITGROUP@
 DSTUSR			= @DSTUSR@
 DSTGRP			= @DSTGRP@
 DSTMODE			= @DSTMODE@
+RUNUSR			= @RUNUSR@
 
-
 prefix			= @prefix@
 sysconfdir		= @sysconfdir@
 exec_prefix		= @exec_prefix@

Modified: trunk/base/aclocal.m4
===================================================================
--- trunk/base/aclocal.m4	2011-05-30 20:12:43 UTC (rev 79024)
+++ trunk/base/aclocal.m4	2011-05-30 21:42:19 UTC (rev 79025)
@@ -354,7 +354,7 @@
 	
 	AC_MSG_CHECKING([for macports user])
 	if test "x$RUNUSR" = "x" ; then
-	   RUNUSR=nobody
+	   RUNUSR=macports
 	fi
 
 	AC_MSG_RESULT([$RUNUSR])

Modified: trunk/base/configure
===================================================================
--- trunk/base/configure	2011-05-30 20:12:43 UTC (rev 79024)
+++ trunk/base/configure	2011-05-30 21:42:19 UTC (rev 79025)
@@ -709,6 +709,7 @@
 CVS
 BZR
 FILE
+DSEDITGROUP
 DSCL
 DIFF
 CPIO
@@ -4392,6 +4393,46 @@
 fi
 
 
+# Extract the first word of "dseditgroup", so it can be a program name with args.
+set dummy dseditgroup; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_DSEDITGROUP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $DSEDITGROUP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_DSEDITGROUP="$DSEDITGROUP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_DSEDITGROUP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+DSEDITGROUP=$ac_cv_path_DSEDITGROUP
+if test -n "$DSEDITGROUP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSEDITGROUP" >&5
+$as_echo "$DSEDITGROUP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
 # Extract the first word of "file", so it can be a program name with args.
 set dummy file; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -7762,7 +7803,7 @@
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for macports user" >&5
 $as_echo_n "checking for macports user... " >&6; }
 	if test "x$RUNUSR" = "x" ; then
-	   RUNUSR=nobody
+	   RUNUSR=macports
 	fi
 
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUNUSR" >&5

Modified: trunk/base/configure.ac
===================================================================
--- trunk/base/configure.ac	2011-05-30 20:12:43 UTC (rev 79024)
+++ trunk/base/configure.ac	2011-05-30 21:42:19 UTC (rev 79025)
@@ -92,6 +92,7 @@
 AC_PATH_PROG(CPIO, [cpio], [])
 AC_PATH_PROG(DIFF, [diff], [])
 AC_PATH_PROG(DSCL, [dscl], [])
+AC_PATH_PROG(DSEDITGROUP, [dseditgroup], [])
 AC_PATH_PROG(FILE, [file], [])
 AC_PATH_PROG(BZR, [bzr], [])
 AC_PATH_PROG(CVS, [cvs], [])

Modified: trunk/base/portmgr/dmg/postflight
===================================================================
--- trunk/base/portmgr/dmg/postflight	2011-05-30 20:12:43 UTC (rev 79024)
+++ trunk/base/portmgr/dmg/postflight	2011-05-30 21:42:19 UTC (rev 79025)
@@ -45,6 +45,8 @@
 MANPAGES=${PREFIX}/share/man
 MACPORTS_TCL_DIR=${PREFIX}/share/macports/Tcl
 REG1DIR=${MACPORTS_TCL_DIR}/registry1.0
+DSCL=/usr/bin/dscl
+RUNUSR=macports
 TCLSH=/usr/bin/tclsh
 TCL_PACKAGE_DIR=/Library/Tcl
 TIMESTAMP=$(date +"%Y-%m-%d_at_%H:%M:%S")
@@ -128,6 +130,28 @@
 	fi
 }
 
+# create the user to use for privilege dropping
+function create_run_user {
+    DSEDITGROUP=/usr/sbin/dseditgroup
+    if test -n "${DSCL}" -a -n "${DSEDITGROUP}" ; then
+        if ! ${DSEDITGROUP} -q -o read ${RUNUSR} > /dev/null 2>&1 ; then
+            echo "Creating group \"${RUNUSR}\""
+            ${DSEDITGROUP} -q -o create -n . ${RUNUSR}
+        fi
+        if ! ${DSCL} -q . -list /Users/${RUNUSR} > /dev/null 2>&1 ; then
+            echo "Creating user \"${RUNUSR}\""
+            ${DSCL} -q . -create /Users/${RUNUSR} Password *
+            ${DSCL} -q . -create /Users/${RUNUSR} UniqueID $(($(${DSCL} . -list /Users UniqueID | /usr/bin/awk '{print $2}' | sort -ug | tail -1)+1))
+            ${DSCL} -q . -create /Users/${RUNUSR} PrimaryGroupID $(${DSCL} -q . -read /Groups/${RUNUSR} PrimaryGroupID | /usr/bin/awk '{print $2}')
+            ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory /dev/null
+            ${DSCL} -q . -create /Users/${RUNUSR} UserShell /usr/bin/false
+        fi
+    else
+        echo "Can't find ${DSCL} / ${DSEDITGROUP}, unable to create user \"${RUNUSR}\""
+        exit 1
+    fi
+}
+
 echo "The MacPorts Project, postflight script version ${VERSION}: checking the shell environment for user \"${USER}\"."
 
 # Set up config files
@@ -141,7 +165,7 @@
 
 # Determine the user's shell, in order to choose an appropriate configuration file we'll be tweaking.
 # Exit nicely if the shell is any other than bash or tcsh, as that's considered non-standard.
-USHELL=$(dscl . -read /users/${USER} shell | awk -F'/' '{print $NF}') || {
+USHELL=$(${DSCL} . -read /Users/${USER} shell | awk -F'/' '{print $NF}') || {
     echo "An attempt to determine your shell name failed! Please set your MacPorts compatible environment manually."
     update_macports
     exit 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110530/479a6ff5/attachment-0001.html>


More information about the macports-changes mailing list