[SCM] xbmc packaging branch, master, updated. upstream/9.11.svn24886.deb1-49-g5d53154

ceros-guest at users.alioth.debian.org ceros-guest at users.alioth.debian.org
Wed Dec 2 04:06:54 UTC 2009


The following commit has been merged in the master branch:
commit 2b692d28caaf550bf85caf2191b7b0d36a6c35ac
Author: Andres Mejia <mcitadel at gmail.com>
Date:   Tue Dec 1 23:01:41 2009 -0500

    Import changes for xbmc-live postinst and postrm script from upstream.
    This implements functionality to update /etc/sudoers and to add the default
    xbmc-live user with a password.

diff --git a/debian/xbmc-live.postinst b/debian/xbmc-live.postinst
index 0ef3284..ce83b46 100755
--- a/debian/xbmc-live.postinst
+++ b/debian/xbmc-live.postinst
@@ -14,7 +14,12 @@ case "$1" in
 	# Add the 'xbmc' user if the primary one is missing
 	xbmcUser=$(getent passwd 1000 | sed -e 's/\:.*//')
 	if [ ! -n "$xbmcUser" ]; then
-		adduser --gecos "XBMC Live User" xbmc
+		clearTextPWD=xbmc
+		encryptedPWD=$(echo $clearTextPWD | mkpasswd -s)
+
+		adduser --disabled-password --gecos "XBMC Live User" xbmc
+		usermod -p $encryptedPWD xbmc
+
 		xbmcUser=xbmc
 	fi
 
@@ -50,6 +55,48 @@ case "$1" in
 		fi
 	done
 
+	SUDOERS="$(cat /etc/sudoers)"
+
+	XBMC_ENTRIES="### XBMC-specific configuration ###
+	# XBMC
+	Cmnd_Alias SHUTDOWN_CMDS = /sbin/shutdown, /sbin/reboot, /sbin/halt # XBMC
+	Cmnd_Alias MOUNT_CMDS = /bin/mount, /bin/umount # XBMC
+	$xbmcUser ALL=(ALL) ALL # XBMC
+	$xbmcUser ALL=NOPASSWD: SHUTDOWN_CMDS, MOUNT_CMDS # XBMC"
+
+	SUDOERS_TEMPFILE=$(mktemp -q)
+
+	# Add xbmc to the sudoers file (if not already done)
+	# Here we make use of perl to check the current sudoers file and create one
+	# for us in case we need to add the xbmc specific entries.
+	if ! perl -e '$sudoers=$ARGV[0]; $entries=$ARGV[1];' \
+	    -e '$entries =~ s/^\s*?(\S)/$1/msg;' \
+	    -e '($sudoers =~ m/$entries/ms) ? exit 0 : exit 1;' \
+	    "$SUDOERS" "$XBMC_ENTRIES"; then
+
+	    # First write a sudoers file to a tempfile.
+	    perl -e '$sudoers=$ARGV[0]; $entries=$ARGV[1];' \
+		-e '$entries =~ s/^\s*?(\S)/$1/msg;' \
+		-e '$sudoers =~ s/\Q### XBMC-specific configuration ###\E\n//g;' \
+		-e '$sudoers =~ s/\n.*# XBMC.*//g;' \
+		-e 'chomp $sudoers;' \
+		-e 'print "$sudoers\n\n$entries\n";' \
+		"$SUDOERS" "$XBMC_ENTRIES" >$SUDOERS_TEMPFILE
+
+	    # Check if sudoers file is ok with visudo and write to /etc/sudoers if
+	    # it is ok, else display a message to the user.
+	    if visudo -c -f $SUDOERS_TEMPFILE >/dev/null 2>&1; then
+		cat $SUDOERS_TEMPFILE >/etc/sudoers
+	    else
+		# TODO: Use debconf for this message.
+		echo "Couldn't edit /etc/sudoers, must be manually edited."
+		echo "Please edit /etc/sudoers using 'visudo' and add the following"
+		echo "entries:"
+		echo "$XBMC_ENTRIES"
+	    fi
+	fi
+	rm $SUDOERS_TEMPFILE
+
 	# Our set of PolicyKit actions
 
 	# This is a list of actions that the 'xbmc' user should be allowed to
diff --git a/debian/xbmc-live.postrm b/debian/xbmc-live.postrm
index 2bc1ba3..f067ad3 100755
--- a/debian/xbmc-live.postrm
+++ b/debian/xbmc-live.postrm
@@ -4,8 +4,40 @@
 # see: dh_installdeb(1)
 
 set -e
-if [ "$1" = "purge" ]                                                    
-then                            
+if [ "$1" = "purge" ]; then
+	SUDOERS="$(cat /etc/sudoers)"
+
+	SUDOERS_TEMPFILE=$(mktemp -q)
+
+	# Check if there are XBMC specific entries in /etc/sudoers and remove
+	# them if so. This makes use of perl for checking and writing a sudoers
+	# file
+	if perl -e '$sudoers=$ARGV[0]; $entries=$ARGV[1];' \
+	    -e '($sudoers =~ m/$entries/ms) ? exit 0 : exit 1;' \
+	    "$SUDOERS" "### XBMC-specific configuration ###"; then
+
+	    # First write a sudoers file to a tempfile.
+	    perl -e '$sudoers=$ARGV[0];' \
+		-e '$sudoers =~ s/\Q### XBMC-specific configuration ###\E\n//g;' \
+		-e '$sudoers =~ s/\n.*# XBMC.*//g;' \
+		-e 'chomp $sudoers;' \
+		-e 'print "$sudoers\n";' \
+		"$SUDOERS" >$SUDOERS_TEMPFILE
+
+	    # Check if sudoers file is ok with visudo and write to /etc/sudoers if
+	    # it is ok, else display a message to the user.
+	    if visudo -c -f $SUDOERS_TEMPFILE >/dev/null 2>&1; then
+		cat $SUDOERS_TEMPFILE >/etc/sudoers
+	    else
+		# TODO: Use debconf for this message.
+		echo "Couldn't edit /etc/sudoers, must be manually edited."
+		echo "Please edit /etc/sudoers using 'visudo' and add the following"
+		echo "entries:"
+		echo "$XBMC_ENTRIES"
+	    fi
+	fi
+	rm $SUDOERS_TEMPFILE
+
 	POLKIT_ACTIONS="org.freedesktop.hal.dockstation.undock
 		org.freedesktop.hal.wol.enabled
 		org.freedesktop.hal.wol.enable
@@ -43,7 +75,10 @@ then
 		org.freedesktop.hal.power-management.cpufreq
 		org.freedesktop.hal.power-management.lcd-panel
 		org.freedesktop.hal.power-management.light-sensor
-		org.freedesktop.hal.power-management.keyboard-backlight"
+		org.freedesktop.hal.power-management.keyboard-backlight
+		org.freedesktop.devicekit.power.suspend
+		org.freedesktop.devicekit.power.Hibernate
+		org.freedesktop.consolekit.system.stop"
 
 	# Grant the 'xbmc' user each action from the list if not done already
 	for ACTION in $POLKIT_ACTIONS; do

-- 
xbmc packaging



More information about the pkg-multimedia-commits mailing list