Author: vcheng Date: 2014-05-12 07:48:52 +0000 (Mon, 12 May 2014) New Revision: 15083
Added: packages/trunk/slashem/debian/recover-all packages/trunk/slashem/debian/slashem-common.service Modified: packages/trunk/slashem/debian/changelog packages/trunk/slashem/debian/control packages/trunk/slashem/debian/rules packages/trunk/slashem/debian/slashem-common.init Log: Add systemd support for slashem (based off of nethack patch provided by Josh Triplett) Modified: packages/trunk/slashem/debian/changelog =================================================================== --- packages/trunk/slashem/debian/changelog 2014-05-12 06:53:45 UTC (rev 15082) +++ packages/trunk/slashem/debian/changelog 2014-05-12 07:48:52 UTC (rev 15083) @@ -5,6 +5,15 @@ [ Vincent Cheng ] * Update my email address. + * Add native systemd support. + - Factor out the recovery logic from the slashem-common init script into a + new script /usr/lib/games/slashem/recover-all. + - Add a slashem-common.service invoking recover-all. This service uses + ConditionPathExistsGlob to only launch when files exist to recover, + avoiding any extra processes at startup in the common case. + - Build-Depends: debhelper (>= 9.20130504) for systemd support in + dh_installinit. + - Changes based on Josh Triplett's patchset for nethack systemd support. -- Vincent Cheng <[email protected]> Sun, 11 May 2014 23:52:38 -0700 Modified: packages/trunk/slashem/debian/control =================================================================== --- packages/trunk/slashem/debian/control 2014-05-12 06:53:45 UTC (rev 15082) +++ packages/trunk/slashem/debian/control 2014-05-12 07:48:52 UTC (rev 15083) @@ -6,7 +6,7 @@ Build-Depends: bison, bsdmainutils, - debhelper (>= 9), + debhelper (>= 9.20130504), flex, groff-base, libgtk2.0-dev, Added: packages/trunk/slashem/debian/recover-all =================================================================== --- packages/trunk/slashem/debian/recover-all (rev 0) +++ packages/trunk/slashem/debian/recover-all 2014-05-12 07:48:52 UTC (rev 15083) @@ -0,0 +1,38 @@ +#!/bin/sh +set -e + +cd /var/games/slashem +for file in *.0; do + # Note "$file" is always explicitly quoted to avoid attack. + # If there are no files, then "$file" = "*.0", which doesn't + # exist, so we skip once through this loop and exit. + # Also, the way this is written, some of the files may + # disappear before we look at them. + + # Also check -L--there shouldn't be any symlinks, but if there + # are, we aren't going to process them. + + if [ -f "$file" ] && [ ! -L "$file" ]; then + # Use 'find' to reliably determine the file's owner user name. + owner="$(find "$file" -maxdepth 0 -printf '%u')" + + # Refuse to recover root's slashem files. + if [ "xroot" = "x$owner" ]; then + echo "Ignoring root's slashem unrecovered save file." + else + echo "Recovering slashem save files owned by $owner: " + + # "$owner" is explicitly quoted to avoid attack. + # In particular, if the "find" command above fails, + # so will the 'su' command below. + + # There really isn't a good safe way to pass a filename to + # a child shell through 'su -c', so instead we use a helper + # script running as the user which recovers everything + # owned by that user. This avoids the issue of quoting + # filenames passed through the shell entirely. + + su --shell=/bin/sh -c /usr/lib/games/slashem/recover-helper "$owner" + fi + fi +done Modified: packages/trunk/slashem/debian/rules =================================================================== --- packages/trunk/slashem/debian/rules 2014-05-12 06:53:45 UTC (rev 15082) +++ packages/trunk/slashem/debian/rules 2014-05-12 07:48:52 UTC (rev 15083) @@ -50,6 +50,10 @@ cp util/recover debian/tmp/usr/lib/games/slashem/recover chown root:games debian/tmp/usr/lib/games/slashem/recover chmod 02755 debian/tmp/usr/lib/games/slashem/recover + install -m 0755 -o root -g root debian/recover-helper \ + debian/nethack-common/usr/lib/games/nethack/recover-helper + install -m 0755 -o root -g root debian/recover-all \ + debian/nethack-common/usr/lib/games/nethack/recover-all mkdir -p debian/tmp/etc cp debian/slashemrc.x11 debian/tmp/etc/slashemrc.x11 chown root:games debian/tmp/usr/lib/games/slashem/slashem Modified: packages/trunk/slashem/debian/slashem-common.init =================================================================== --- packages/trunk/slashem/debian/slashem-common.init 2014-05-12 06:53:45 UTC (rev 15082) +++ packages/trunk/slashem/debian/slashem-common.init 2014-05-12 07:48:52 UTC (rev 15083) @@ -7,67 +7,27 @@ # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Should-Stop: -# Short-Description: Nethack variant daemon +# Short-Description: Slashem save-file recovery script for Debian +# Description: Recovers Slashem save-files on start ### END INIT INFO -RECOVER=/usr/lib/games/slashem/recover-helper +. /lib/lsb/init-functions -test -x $RECOVER || exit 0 +PATH=/bin:/usr/bin:/sbin:/usr/sbin -cd /var/games/slashem || exit 1 - set -e + case "$1" in start) - for file in *.0; do - - # Note "$file" is always explicitly quoted to avoid attack. - # If there are no files, then "$file" = "*.0", which doesn't - # exist, so we skip once through this loop and exit. - # Also, the way this is written, some of the files may - # disappear before we look at them. - - # Also check -L--there shouldn't be any symlinks, but if there - # are, we aren't going to process them. - - if [ -f "$file" ] && [ ! -L "$file" ]; then - - # Use 'find' to reliably determine the file's owner user name. - owner="$(find "$file" -maxdepth 0 -printf '%u')" - - # Refuse to recover root's slashem files. - if [ "xroot" = "x$owner" ]; then - echo "Ignoring root's Slash'EM unrecovered save file." - else - echo "Recovering Slash'EM save files owned by $owner: " - - # "$owner" is explicitly quoted to avoid attack. - # In particular, if the "find" command above fails, - # so will the 'su' command below. - - # There really isn't a good safe way to pass a filename to - # a child shell through 'su -c', so instead we use a helper - # script running as the user which recovers everything - # owned by that user. This avoids the issue of quoting - # filenames passed through the shell entirely. - - su "$owner" -c /usr/lib/games/slashem/recover-helper - fi - fi - done - + # Has the nethack package been removed? + test -x /usr/lib/games/slashem/recover-all || exit 0 + exec /usr/lib/games/slashem/recover-all ;; - stop|restart|reload|force-reload) + stop|reload|restart|force-reload|status) ;; *) - N=/etc/init.d/$NAME - # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $N start" >&2 + N=/etc/init.d/slashem-common + echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac - -exit 0 - - - Added: packages/trunk/slashem/debian/slashem-common.service =================================================================== --- packages/trunk/slashem/debian/slashem-common.service (rev 0) +++ packages/trunk/slashem/debian/slashem-common.service 2014-05-12 07:48:52 UTC (rev 15083) @@ -0,0 +1,12 @@ +[Unit] +Description=Recover slashem save files +Documentation=man:recover(6) man:slashem(6) +RequiresMountsFor=/var/games/slashem +ConditionPathExistsGlob=/var/games/slashem/*.0 + +[Service] +Type=oneshot +ExecStart=/usr/lib/games/slashem/recover-all + +[Install] +WantedBy=multi-user.target _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

