[PC-BSD Commits] r9739 - in pcbsd/current/src-sh/pbi-manager: . man module-examples/firefox module-examples/gimp port-files

svn at pcbsd.org svn at pcbsd.org
Mon Mar 21 11:48:50 PDT 2011


Author: kris
Date: 2011-03-21 11:48:49 -0700 (Mon, 21 Mar 2011)
New Revision: 9739

Added:
   pcbsd/current/src-sh/pbi-manager/man/pbi_update_hashdir.1
Modified:
   pcbsd/current/src-sh/pbi-manager/install.sh
   pcbsd/current/src-sh/pbi-manager/module-examples/firefox/pbi.conf
   pcbsd/current/src-sh/pbi-manager/module-examples/gimp/pbi.conf
   pcbsd/current/src-sh/pbi-manager/pbi-manager
   pcbsd/current/src-sh/pbi-manager/port-files/Makefile
   pcbsd/current/src-sh/pbi-manager/port-files/pkg-plist
Log:

Large update to pbi-manager:

* Added framework to install PBIs as a user in the "operators" group, in
  addition to regular root installs
* Updated PBID to merge user/root data into correct hash-dirs, with
  correct runtime permissions
* Added field to meta-files which indicates an application must be installed
  as root
* Added variable to pbi.conf modules, which can be set to indicate that root
  is required for installation
* Added security checks, to ensure users can only update their own applications
* Updated pbi_icon command to allow installing XDG data as root or user
* Enabled support for auto-updating as a user process (pbid)
* Enabled support for cleaning/merging into hashdir as user process (pbid)
* Updated install script to set correct permissions at install time
* Updated module-examples
* Updated port files



Modified: pcbsd/current/src-sh/pbi-manager/install.sh
===================================================================
--- pcbsd/current/src-sh/pbi-manager/install.sh	2011-03-20 09:22:10 UTC (rev 9738)
+++ pcbsd/current/src-sh/pbi-manager/install.sh	2011-03-21 18:48:49 UTC (rev 9739)
@@ -31,6 +31,7 @@
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_metatool
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_patch
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_update
+ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi_update_hashdir
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbid
 ln -f ${LB}/sbin/pbi_create ${LB}/sbin/pbi-crashhandler
 
@@ -59,6 +60,9 @@
 fi
 chmod 755 /var/db/pbi/keys
 
+# Tickle the info command to setup default dirs
+/usr/local/sbin/pbi_info >/dev/null 2>/dev/null
+
 # Copy the ldconfig script / pbi.conf
 #mkdir -p ${LB}/etc/rc.d >/dev/null 2>/dev/null
 #cp ${DIR}/rc.d/ldpbiconfig ${LB}/etc/rc.d/ldpbiconfig

Modified: pcbsd/current/src-sh/pbi-manager/module-examples/firefox/pbi.conf
===================================================================
--- pcbsd/current/src-sh/pbi-manager/module-examples/firefox/pbi.conf	2011-03-20 09:22:10 UTC (rev 9738)
+++ pcbsd/current/src-sh/pbi-manager/module-examples/firefox/pbi.conf	2011-03-21 18:48:49 UTC (rev 9739)
@@ -29,4 +29,7 @@
 # Exclude some directories we don't want
 PBI_EXCLUDELIST="include man info"
 
-export PBI_MAKEOPTS PBI_PROGNAME PBI_PROGWEB PBI_PROGAUTHOR PBI_MKPORTBEFORE PBI_MKPORTAFTER PBI_PROGICON PBI_EXCLUDELIST
+# Does this PBI need to be installed as root (YES/NO)
+PBI_REQUIRESROOT="NO"
+
+export PBI_MAKEOPTS PBI_PROGNAME PBI_PROGWEB PBI_PROGAUTHOR PBI_MKPORTBEFORE PBI_MKPORTAFTER PBI_PROGICON PBI_EXCLUDELIST PBI_REQUIRESROOT

Modified: pcbsd/current/src-sh/pbi-manager/module-examples/gimp/pbi.conf
===================================================================
--- pcbsd/current/src-sh/pbi-manager/module-examples/gimp/pbi.conf	2011-03-20 09:22:10 UTC (rev 9738)
+++ pcbsd/current/src-sh/pbi-manager/module-examples/gimp/pbi.conf	2011-03-21 18:48:49 UTC (rev 9739)
@@ -24,4 +24,7 @@
 # Enter your custom make options here
 PBI_MAKEOPTS="WITH_CUPS=yes"
 
-export PBI_MAKEOPTS PBI_PROGNAME PBI_PROGWEB PBI_PROGAUTHOR PBI_MKPORTBEFORE PBI_MKPORTAFTER PBI_PROGICON
+# Does this PBI need to be installed as root (YES/NO)
+PBI_REQUIRESROOT="NO"
+
+export PBI_MAKEOPTS PBI_PROGNAME PBI_PROGWEB PBI_PROGAUTHOR PBI_MKPORTBEFORE PBI_MKPORTAFTER PBI_PROGICON PBI_REQUIRESROOT

Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2011-03-20 09:22:10 UTC (rev 9738)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2011-03-21 18:48:49 UTC (rev 9739)
@@ -197,6 +197,7 @@
   -t type  	-- Application interface type
 		   Example; Graphical, Text, Service
   -u url 	-- Application homepage URL
+  -r	 	-- Application must be installed as root
 
 EOF
 	exit_trap
@@ -488,6 +489,8 @@
           		-k) if [ $# -eq 1  ]; then usage_mt_add; fi
                        	    shift; PBI_MT_ADDKEYWORDS="$1"
 			    ;;
+          		-r) PBI_MT_REQUIRESROOT="YES"
+			    ;;
                          *) if [ $# -gt 1  ]; then usage_mt_add; fi
                        	    PBI_MT_METAFILE="$1"
                             ;;
@@ -1187,6 +1190,20 @@
 	if [ ! -d "${PBI_DBINDEXDIR}" ] ; then mkdir -p ${PBI_DBINDEXDIR} >/dev/null 2>/dev/null ; fi
 	if [ ! -d "${PBI_DBREPODIR}" ] ; then mkdir -p ${PBI_DBREPODIR} >/dev/null 2>/dev/null ; fi
 	if [ ! -d "${PBI_DBHASHQUEUEDIR}" ] ; then mkdir -p ${PBI_DBHASHQUEUEDIR} >/dev/null 2>/dev/null ; fi
+
+	# Set the permissions for directories if we are running as root
+	if [ `id -u` != "0" ] ; then return ; fi
+
+	for cDir in $PBI_APPDIR $PBI_DBAPPDIR $PBI_DBHASHQUEUEDIR
+	do	
+		chown root:${PBI_INSTALLGROUP} ${cDir}
+		chmod 775 ${cDir}
+	done
+
+	# Make sure the hash-dirty file can be written to by all
+	touch ${PBI_DBDIRTYFILE}
+	chown root:${PBI_INSTALLGROUP} ${PBI_DBDIRTYFILE}
+	chmod 664 ${PBI_DBDIRTYFILE}
 }
 
 # Get the absolute path of a dir
@@ -1210,7 +1227,11 @@
 	SYS_LOCALBASE="/usr/local"
 	PBI_APPDIR="/usr/pbi"
 	PBI_CHROOTFILE="${PBI_APPDIR}/.pbi-world.tbz"
-	PBI_HASHDIR="${PBI_APPDIR}/.hashdir"
+	if [ `id -u` = "0" ] ; then 
+		PBI_HASHDIR="${PBI_APPDIR}/.hashdir"
+	else
+		PBI_HASHDIR="${PBI_APPDIR}/.hashdir-`whoami`"
+	fi
 	PBI_RCDIR="${SYS_LOCALBASE}/etc/rc.d"
 	PBI_ETCCONF="${SYS_LOCALBASE}/etc/pbi.conf"
 	PCBSD_ETCCONF="${SYS_LOCALBASE}/etc/pcbsd.conf"
@@ -1219,8 +1240,9 @@
 	PBI_LDCONFIGFILE="${PROGBASE}/etc/ldpbiconfig"
 	PBI_LDCONFIGRC="${PROGBASE}/etc/rc.d/ldpbiconfig"
 	PROGVERSION="1.0"
-	PBIDSLEEP="900"		# Amount of time to sleep before waking up pbid
+	PBIDSLEEP="300"		# Amount of time to sleep before waking up pbid
 	PBI_LOG_LINES="500"
+	PBI_INSTALLGROUP="operator"
 
 	# What dirs do we build hash-lists of
 	HASH_SEARCH_DIRS="lib kde4/lib share include info man"
@@ -1567,6 +1589,32 @@
   fi 
 }
 
+# Confirm we are running as root or the proper group for installation
+require_root_or_group() {
+  if [ `id -u` = "0" ] ; then return 0 ; fi 
+  touch ${PBI_APPDIR}/.ptest.$$ >/dev/null 2>/dev/null
+  if [ "$?" = "0" ] ; then 
+	rm ${PBI_APPDIR}/.ptest.$$ >/dev/null 2>/dev/null
+	return 0
+  fi
+  exit_err "Must be run as root or a member of the $PBI_INSTALLGROUP group!"
+}
+
+# Function to get the username from a file
+get_username_from_file() {
+	if [ -f "${1}" ] ; then 
+		FILEUSER=`ls -al ${1} | awk '{print $3}'`
+		export FILEUSER
+		return 0
+	fi
+	if [ -d "${1}" ] ; then 
+		FILEUSER=`ls -al ${1} | grep -v "total" | head -n 1 | awk '{print $3}'`
+		export FILEUSER
+		return 0
+	fi
+	exit_err "Invalid file for usercheck!"
+}
+
 # Start the make patch process
 pbi_makepatch_init() {
   	require_root
@@ -1772,7 +1820,7 @@
 	do_pbi_mt_rem_app "${PBI_MT_ADDNAME}" "${PBI_MT_METAFILE}"
 
 	cp ${PBI_MT_METAFILE} ${PBI_TMPDIR}/.meta.$$
-	echo "App=${PBI_MT_ADDNAME};${PBI_MT_ADDCAT};${PBI_MT_ADDICON};${PBI_MT_ADDAUTHOR};${PBI_MT_ADDURL};${PBI_MT_ADDLIC};${PBI_MT_ADDTYPE};${PBI_MT_ADDKEYWORDS};${PBI_MT_ADDDESC};" \
+	echo "App=${PBI_MT_ADDNAME};${PBI_MT_ADDCAT};${PBI_MT_ADDICON};${PBI_MT_ADDAUTHOR};${PBI_MT_ADDURL};${PBI_MT_ADDLIC};${PBI_MT_ADDTYPE};${PBI_MT_ADDKEYWORDS};${PBI_MT_ADDDESC};$PBI_MT_REQUIRESROOT;" \
 	>> ${PBI_TMPDIR}/.meta.$$
 	sort ${PBI_TMPDIR}/.meta.$$ > "${PBI_MT_METAFILE}"
 	rm ${PBI_TMPDIR}/.meta.$$
@@ -1958,6 +2006,7 @@
 		aType=`echo $line | cut -d ';' -f 7`
 		aKeywords=`echo $line | cut -d ';' -f 8`
 		aDesc=`echo $line | cut -d ';' -f 9`
+		aRoot=`echo $line | cut -d ';' -f 10`
 
 		# Check for a translation to the description
 		get_meta_trans "App" "$cName" "${PBI_BROWSE_METAFILE}"
@@ -1982,6 +2031,11 @@
 			echo "Category: $catCheck"
 		fi
 		echo "Created: `echo $PBI_UPMDATE`"
+		if [ "$aRoot" = "YES" ] ; then
+			echo "RootInstall: YES"
+		else
+			echo "RootInstall: NO"
+		fi
 		echo "Arch: $aArch"
 		echo "Author: $aAuthor"
 		echo "URL: $aUrl"
@@ -1991,8 +2045,12 @@
 		echo "Icon: $aIcon"
 		echo "Description: $aDesc"
 		echo ""
-		echo "To install this PBI:"
-		echo "# pbi_add -r $aName --rArch $aArch --repoid $PBI_BROWSE_RID"
+		if [ "$aRoot" = "YES" ] ; then
+			echo "To install this PBI (As Root):"
+		else
+			echo "To install this PBI:"
+		fi
+		echo "# pbi_add --rArch $aArch --repo $PBI_BROWSE_RID -r $aName"
 		echo ""
 
 		
@@ -2058,13 +2116,14 @@
 
 # List repos in the db
 pbi_listrepo_init() {
-  	require_root
+  	require_root_or_group
 	parse_listrepo_pbi_cmdline "$@"
 
 	# List the repos
 	if [ -z "$PBI_LISTREPO_ID" ] ; then
 		list_all_pbi_repo
 	else
+		require_root
 		if [ ! -z "${PBI_LISTREPO_UP}" ]; then
 			move_repo_up "${PBI_LISTREPO_ID}" 
 			list_all_pbi_repo
@@ -2410,7 +2469,7 @@
 		exit_trap
 	fi
 
-  	require_root
+  	require_root_or_group
 
 	check_agree_lic
 	check_existing_pbi
@@ -2419,14 +2478,27 @@
 
 # Check if this PBI exists and exit if so
 check_existing_pbi() {
-	if [ "${PBI_FORCEADD}" = "YES" ] ; then return 0; fi
 	if [ "${PBI_EXTRACTONLY}" = "YES" ] ; then return 0; fi
 	get_dbdir
 	dir="${APPDBDIR}"
+
+	# See if this PBI is already installed
 	if [ -d "$dir" ]; then
+		get_username_from_file "${APPDBDIR}/pbi_name"
+		if [ "$FILEUSER" != `whoami` -a `id -u` != "0" ] ; then
+			exit_err "Permission denied to modify PBI installed by: $FILEUSER"     
+		fi
+
+		if [ "${PBI_FORCEADD}" = "YES" ] ; then return 0; fi
 		exit_err "${PBI_PROGNAME} ${PBI_PROGVERSION} is already installed! Use -f to force installation."
 	fi
+
 	if [ -e "${PBI_PROGDIRPATH}" ]; then
+		get_username_from_file "${PBI_PROGDIRPATH}"
+		if [ "$FILEUSER" != `whoami` -a `id -u` != "0" ] ; then
+			exit_err "Permission denied to modify PBI installed by: $FILEUSER"     
+		fi
+		if [ "${PBI_FORCEADD}" = "YES" ] ; then return 0; fi
 		exit_err "${PBI_PROGDIRPATH} already exists! Use -f to force installation."
 	fi
 
@@ -2481,6 +2553,17 @@
 		echo "PatchTarget: $PBI_PATCHTARGET"
 	fi
 
+	if [ ! -z "$PBI_INSTALLED_BY" ] ; then
+		echo "InstalledBy: $PBI_INSTALLED_BY"
+	fi
+
+	# Does this PBI need root to install?
+	if [ "$PBI_REQUIRESROOT" = "YES" ] ; then
+		echo "RootInstall: YES"
+	else
+		echo "RootInstall: NO"
+	fi
+
 	echo "Version: ${PBI_PROGVERSION}"
 	echo "Built: ${PBI_PROGMDATE}"
 	echo "Prefix: ${PBI_ORIGPROGDIRPATH}"
@@ -2654,6 +2737,7 @@
         PBI_PROGMDATE=""
         PBI_PROGWEB=""
 	PBI_REPO=""
+	PBI_REQUIRESROOT=""
 	PBI_SIGVALID=""
 
 	PBI_ORIGPROGDIRPATH="`cat ${1}/pbi_defaultpath`"
@@ -2672,6 +2756,11 @@
 	if [ -e "${1}/autoupdate-enable" ] ; then
 		PBI_ENABLEAUTOUPDATE="YES"
 	fi
+
+	# Does this PBI need to be installed as root
+	if [ -e "${1}/pbi_requiresroot" ] ; then
+		PBI_REQUIRESROOT="YES"
+	fi
 	
 	# Check if this is a patch file
 	if [ -e "${1}/pbi_patchfile" ] ; then
@@ -2884,20 +2973,8 @@
 		rm "${dir}/pbi_patchfile"
 	fi
 
-	# Remove any duplicate ldconfig entry
-        # KPM - 08172010 - Disable until we get a patch to BSD to support hints via path
-	#cat "${PBI_LDCONFIGFILE}" 2>/dev/null | grep "^${PBI_PROGDIRPATH}" >/dev/null 2>/dev/null
-	#if [ "$?" = "0" ] ; then
-	#	sed -i "\|^${PBI_PROGDIRPATH}\$|d" ${PBI_LDCONFIGFILE} 2>/dev/null
-	#fi
-
-	#echo "${PBI_PROGDIRPATH}" >>${PBI_LDCONFIGFILE}
-
         delete_header_tmp
 
-	# Re-gen the ldconfig hints files
-	#${PBI_LDCONFIGRC} onestart >/dev/null 2>/dev/null
-
 	echo "Installed: ${PBI_PROGNAME}-${PBI_PROGVERSION}"
 }
 
@@ -3522,7 +3599,9 @@
 
 	# Add the binary wrapper sym-links
         if [ -e "${PBI_STAGEDIR}/${PBI_FAKEBIN_DIR}/${PBI_INS_PATHSCRIPT}" ] ; then
-		echo "$PBI_PROGDIRPATH/${PBI_FAKEBIN_DIR}/${PBI_INS_PATHSCRIPT}" >>${insc}
+		echo 'if [ `id -u` = "0" ] ; then ' >>${insc}
+		echo "	$PBI_PROGDIRPATH/${PBI_FAKEBIN_DIR}/${PBI_INS_PATHSCRIPT}" >>${insc}
+		echo "fi" >>${insc}
 	fi
 
 	# Look for any XDG scripts
@@ -3547,7 +3626,9 @@
 
 	# Remove the binary wrapper sym-links
         if [ -e "${PBI_STAGEDIR}/${PBI_FAKEBIN_DIR}/${PBI_UNINS_PATHSCRIPT}" ] ; then
-		echo "$PBI_PROGDIRPATH/${PBI_FAKEBIN_DIR}/${PBI_UNINS_PATHSCRIPT}" >>${uisc}
+		echo 'if [ `id -u` = "0" ] ; then ' >>${uins}
+		echo "	$PBI_PROGDIRPATH/${PBI_FAKEBIN_DIR}/${PBI_UNINS_PATHSCRIPT}" >>${uisc}
+		echo "fi" >>${uins}
 	fi
 
 	# Look for any XDG scripts
@@ -3662,6 +3743,10 @@
 	echo "${PBI_PROGWEB}" > "${PBI_HEADERDIR}/pbi_web"
 	date "+%Y%m%d %H%M%S" > "${PBI_HEADERDIR}/pbi_mdate"
 
+	if [ "${PBI_REQUIRESROOT}" = "YES" ] ; then
+		touch ${PBI_HEADERDIR}/pbi_requiresroot
+	fi
+
 	# Do we have a license to accept?
 	if [ -e "${PBI_CONFDIR}/${PBI_LICENSEFILE}" ] ; then
 		cp "${PBI_CONFDIR}/${PBI_LICENSEFILE}" "${PBI_HEADERDIR}/${PBI_LICENSEFILE}"
@@ -3769,7 +3854,7 @@
 }
 
 pbi_delete_init() {
-  	require_root
+  	require_root_or_group
 	init_tmpdir
 	parse_delete_pbi_cmdline "$@"
 	do_pbi_delete
@@ -3780,6 +3865,11 @@
 	load_info_from_dir "${PBI_DBAPPDIR}/${PBI_DELETENAME}"
 	PBI_PROGDIRPATH="${PBI_ORIGPROGDIRPATH}"
 
+	get_username_from_file "${PBI_DBAPPDIR}/${PBI_DELETENAME}/pbi_name"
+	if [ "$FILEUSER" != `whoami` -a `id -u` != "0" ] ; then
+		exit_err "Permission denied to modify PBI installed by: $FILEUSER"
+	fi
+
 	# Set the dirty flag that we are removing this PBI
 	touch ${PBI_DBAPPDIR}/${PBI_DELETENAME}/.pbiDeleted
 
@@ -3900,9 +3990,6 @@
 	fi
 	rm -rf "${PBI_DBAPPDIR}/${PBI_DELETENAME}"
 
-	# Remove the ldconfig entry
-        # KPM - 08172010 - Disable until we get a patch to BSD to support hints via path
-	#sed -i "\|^${PBI_PROGDIRPATH}\$|d" ${PBI_LDCONFIGFILE} 2>/dev/null
 }
 
 # Check if we have a preinstall script we need to use
@@ -3940,28 +4027,28 @@
 		sh "${_appDir}/.xdg-desktop/${PBI_UNINS_DESKSCRIPT}"
 	fi
 	if [ "${PBI_MENUADD}" = "YES" ] ; then
-		require_root
+		require_root_or_group
 		if [ ! -e "${_appDir}/.xdg-menu/${PBI_INS_MENUSCRIPT}" ] ; then 
 			exit_err "No menu icons for this PBI"
 		fi
 		sh "${_appDir}/.xdg-menu/${PBI_INS_MENUSCRIPT}"
 	fi
 	if [ "${PBI_MENUDEL}" = "YES" ] ; then
-		require_root
+		require_root_or_group
 		if [ ! -e "${_appDir}/.xdg-menu/${PBI_UNINS_MENUSCRIPT}" ] ; then 
 			exit_err "No menu icons for this PBI"
 		fi
 		sh "${_appDir}/.xdg-menu/${PBI_UNINS_MENUSCRIPT}"
 	fi
 	if [ "${PBI_MIMEADD}" = "YES" ] ; then
-		require_root
+		require_root_or_group
 		if [ ! -e "${_appDir}/.xdg-mime/${PBI_INS_MIMESCRIPT}" ] ; then 
 			exit_err "No mime registration for this PBI"
 		fi
 		sh "${_appDir}/.xdg-mime/${PBI_INS_MIMESCRIPT}"
 	fi
 	if [ "${PBI_MIMEDEL}" = "YES" ] ; then
-		require_root
+		require_root_or_group
 		if [ ! -e "${_appDir}/.xdg-mime/${PBI_UNINS_MIMESCRIPT}" ] ; then 
 			exit_err "No mime registration for this PBI"
 		fi
@@ -3970,6 +4057,7 @@
 }
 
 pbid_init() {
+	require_root
 
 	parse_pbid_cmdline "$@"
 
@@ -4019,9 +4107,18 @@
 					continue
 				fi
 
+				# Get the username this PBI was installed as
+				get_username_from_file "${_hpbipath}"
+
 				# Lets start this hash merge
-				echo "Adding ${_hpbipath} to hash-dir: `date`" >> ${_pbid_log}
-				pbi_add_update_hashdir "${_hpbipath}" "${PBI_DBAPPDIR}/${_hpbi}/.pbiDeleted" >${_redir} 2>${_redir}
+				echo "Adding ${_hpbipath} to hash-dir ($FILEUSER): `date`" >> ${_pbid_log}
+
+				if [ "$FILEUSER" = "root" ];then
+					pbi_add_update_hashdir "${_hpbipath}" "${PBI_DBAPPDIR}/${_hpbi}/.pbiDeleted" >${_redir} 2>${_redir}
+				else
+					# Run hashdir command as a user
+					su $FILEUSER -c "pbi_update_hashdir \"${_hpbipath}\" \"${PBI_DBAPPDIR}/${_hpbi}/.pbiDeleted\"" >/tmp/output 2>/tmp/output #>${_redir} 2>${_redir}
+				fi
 				echo "Finished adding ${_hpbipath} to hash-dir: `date`" >> ${_pbid_log}
 				
 				# Now remove the trigger file
@@ -4085,9 +4182,13 @@
 			continue
 		fi
 		
+		# Get the username this PBI was installed as
+		get_username_from_file "${PBI_DBAPPDIR}/${PBI_UPDATEAPP}"
+
 		# Its Update Time!
-		echo "Starting Auto-Update of ${PBI_UPDATEAPP}: `date`" >>${_pbid_log}
-		start_pbi_updateapp "all" "${_pbid_log}" >/dev/null 2>/dev/null
+		echo "Starting Auto-Update of ${PBI_UPDATEAPP} ($FILEUSER): `date`" >>${_pbid_log}
+
+		su ${FILEUSER} -c "pbi_update ${PBI_UPDATEAPP}" >>${_pbid_log} 2>>${_pbid_log}
 		if [ "$?" = "0" ] ; then
 			echo "Success! Update of ${PBI_UPDATEAPP}: `date`" >>${_pbid_log}
 		else
@@ -4112,12 +4213,15 @@
 	# See if we have a new date trigger to do a cleaning
 	if [ "$_curDate" = "${_lastDate}" ]; then return; fi
 
-	init_tmpdir
-	echo "Cleaning hash-dir: `date`" >> ${1}
-	pbi_clean_hashdir >>${2} 2>>${2}
-	echo "Finished cleaning hash-dir: `date`" >> ${1}
-	echo "$_curDate" > ${PBI_DBDIRTYFILE}.last 2>/dev/null
-	rm_tmpdir
+	# Loop through and clean any hash-dirs as the appropriate user
+	for cHdir in `ls -d ${PBI_HASHDIR}*`
+	do
+		get_username_from_file "${cHdir}"
+		echo "Cleaning hash-dir ($FILEUSER): `date`" >> ${1}
+		su ${FILEUSER} -c "pbi_delete --clean-hdir" >>${2} 2>>${2}
+		echo "Finished cleaning hash-dir ($FILEUSER): `date`" >> ${1}
+		echo "$_curDate" > ${PBI_DBDIRTYFILE}.last 2>/dev/null
+	done
 }
 
 pbi_info_init() {
@@ -4144,6 +4248,8 @@
 			if [ -e "${PBI_DBAPPDIR}/${i}/pbi_name" ] ; then
 				if [ "$PBI_VERBOSE" = "YES" ] ; then
         				load_info_from_dir "${PBI_DBAPPDIR}/${i}"
+					get_username_from_file "${PBI_DBAPPDIR}/${i}"
+					PBI_INSTALLED_BY=$FILEUSER
 					pbi_display_info
 					pbi_display_gui "${PBI_DBAPPDIR}/${i}" ""
 					echo " "
@@ -4155,6 +4261,8 @@
 	else
 		# Start loading our variables
         	load_info_from_dir "${PBI_DBAPPDIR}/${PBI_INFONAME}"
+		get_username_from_file "${PBI_DBAPPDIR}/${PBI_INFONAME}"
+		PBI_INSTALLED_BY=$FILEUSER
 		pbi_display_info
 	fi
 }
@@ -4360,6 +4468,11 @@
 
 }
 
+# Start pbi_update_hashdir
+pbi_update_hashdir_init() {
+	pbi_add_update_hashdir "$1" "$2"
+}
+
 # Start pbi_update processing
 pbi_update_init() {
 
@@ -4376,7 +4489,7 @@
 	# Stop here if only doing update checks
 	if [ ! -z "${PBI_UPCHECK}" ]; then return 0 ; fi
 
-  	require_root
+  	require_root_or_group
 
 	do_pbi_update
 }
@@ -5951,6 +6064,7 @@
    pbi_metatool) pbi_mt_init "$@" ;;
    pbi_patch) pbi_patch_init "$@" ;;
    pbi_update) pbi_update_init "$@" ;;
+   pbi_update_hashdir) pbi_update_hashdir_init "$@" ;;
    pbi-crashhandler) pbi_crash_init "$@" ;;
    pbid) pbid_init "$@" ;;
    *) echo "Error: Called with invalid basename!" ; exit_trap ;;

Modified: pcbsd/current/src-sh/pbi-manager/port-files/Makefile
===================================================================
--- pcbsd/current/src-sh/pbi-manager/port-files/Makefile	2011-03-20 09:22:10 UTC (rev 9738)
+++ pcbsd/current/src-sh/pbi-manager/port-files/Makefile	2011-03-21 18:48:49 UTC (rev 9739)
@@ -24,6 +24,7 @@
 		pbi_icon.1 pbi_indextool.1 pbi_info.1 pbid.1 pbi_addrepo.1 \
 		pbi_listrepo.1 pbi_deleterepo.1 pbi_update.1 \
 		pbi_patch.1 pbi_makeport.1 \
+		pbi_update_hashdir.1 \
 		pbi_metatool.1 pbi_makepatch.1 pbi_makerepo.1 pbi.conf.1
 
 do-install:

Modified: pcbsd/current/src-sh/pbi-manager/port-files/pkg-plist
===================================================================
--- pcbsd/current/src-sh/pbi-manager/port-files/pkg-plist	2011-03-20 09:22:10 UTC (rev 9738)
+++ pcbsd/current/src-sh/pbi-manager/port-files/pkg-plist	2011-03-21 18:48:49 UTC (rev 9739)
@@ -15,6 +15,7 @@
 sbin/pbi_makerepo
 sbin/pbi_metatool
 sbin/pbi_update
+sbin/pbi_update_hashdir
 sbin/pbi_patch
 sbin/pbid
 etc/pbi.conf



More information about the Commits mailing list