[arch-commits] Commit in xbill/trunk (PKGBUILD xbill-wrapper.c xbill.install)

Eric Bélanger eric at archlinux.org
Tue Dec 16 06:16:27 UTC 2008


    Date: Tuesday, December 16, 2008 @ 01:16:27
  Author: eric
Revision: 21759

upgpkg: xbill 2.1-5
    Rebuilt against xaw3d 1.5E, Added libxaw makedepends, Moved score file in correct location with games group ownership, Added wrapper taken from Slackware because gtk apps refuse to run if there are setgid

Added:
  xbill/trunk/xbill-wrapper.c
  xbill/trunk/xbill.install
Modified:
  xbill/trunk/PKGBUILD

-----------------+
 PKGBUILD        |   33 ++++++++++++++++-----
 xbill-wrapper.c |   82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 xbill.install   |   25 ++++++++++++++++
 3 files changed, 132 insertions(+), 8 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2008-12-16 06:09:56 UTC (rev 21758)
+++ PKGBUILD	2008-12-16 06:16:27 UTC (rev 21759)
@@ -4,18 +4,35 @@
 
 pkgname=xbill
 pkgver=2.1
-pkgrel=4
+pkgrel=5
 pkgdesc="Xbill is a game that tests you reflexes as you seek and destroy all forms of Bill"
-depends=('gtk' 'xaw3d' 'lesstif')
-source=(http://www.xbill.org/download/$pkgname-$pkgver.tar.gz)
-license=('GPL')
 arch=('i686' 'x86_64')
 url="http://www.xbill.org/"
-md5sums=('585e4866b15255a24203db9959407b2f')
+license=('GPL')
+depends=('gtk' 'xaw3d>=1.5E' 'lesstif')
+makedepends=('libxaw')
+install=xbill.install
+source=(http://www.xbill.org/download/$pkgname-$pkgver.tar.gz xbill-wrapper.c)
+md5sums=('585e4866b15255a24203db9959407b2f' '9f299e482623999b03ce7585413bc182')
 
 build() {
-  cd $startdir/src/$pkgname-$pkgver
-  ./configure --prefix=/usr
+  cd $srcdir/$pkgname-$pkgver
+  ./configure --prefix=/usr --mandir=/usr/share/man --localstatedir=/var/games || return 1
   make || return 1
-  make prefix=$startdir/pkg/usr install
+  make DESTDIR=$pkgdir install || return 1
+
+# Build wrapper script from Slackware to use setgid for score file
+  mv $pkgdir/usr/bin/xbill $pkgdir/usr/bin/xbill-bin
+  gcc -Wall ../xbill-wrapper.c -o $pkgdir/usr/bin/xbill || return 1
+
+# set appropriate permissions and destinations
+  chown root:games $pkgdir/usr/bin/xbill
+  chmod 4755 $pkgdir/usr/bin/xbill
+  chown root:games $pkgdir/var/games
+  chmod 775 $pkgdir/var/games
+  chown root:games $pkgdir/var/games/xbill
+  chmod 775 $pkgdir/var/games/xbill
+
+# Handle the scores file creation in the install script
+  rm $pkgdir/var/games/xbill/scores
 }

Added: xbill-wrapper.c
===================================================================
--- xbill-wrapper.c	                        (rev 0)
+++ xbill-wrapper.c	2008-12-16 06:16:27 UTC (rev 21759)
@@ -0,0 +1,82 @@
+/* Written by Menno E. Duursma for use with xbill */
+
+/*
+ * This program is free software. It comes without any warranty.
+ * Granted WTFPL, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/wtfpl/COPYING for more details.
+ */
+
+/*
+ * Per default xbill sets its score file world writable
+ * which obviously allows cheating ones hi-score :-(
+ * Probably this came about since GTK+ doesn't allow setgid?
+ * 
+ * In the install-script we move xbill to xbill-bin and install
+ * this here wrapper thing as xbill, with setuid and video group
+ * executable filesystem perms. Here we change groups to games.
+ *
+ * We should now be able make /var/xbill group-writable only...
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <grp.h>
+
+int main(int argc, char *argv[], char *envp[])
+{
+
+	/*
+         * hardcoded path/program to exec
+	 * and group to run under
+	 */
+        char prog[] = "/usr/bin/xbill-bin";
+	char grpname[] = "games";
+
+	struct group *grp;
+	errno = 0;
+
+	/* get our gid */
+	grp = getgrnam(grpname);
+	if (grp == NULL) {
+		fprintf(stderr, "Error: getgrnam(%s) - %s\n",
+			grpname,
+			strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+
+	/* drop to the gid */
+	if (setgid(grp->gr_gid)) {
+		fprintf(stderr, "Error: setgid(%d) - %s\n",
+			grp->gr_gid,
+			strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+		
+
+        /* drop back to calling uid */
+	if (setuid(getuid())) {
+		fprintf(stderr, "Error: setuid(%d) - %s\n",
+			getuid(),
+			strerror(errno));
+		exit(EXIT_FAILURE);
+		}
+
+        /* tell the viewers wat is going to happen */
+        fprintf(stderr, "Starting %s with uid = %d, gid = %d\n",
+		prog,
+		getuid(),
+		getgid());
+
+	/* fire it up */
+	if (execve(prog, argv, envp) == -1) {
+		fprintf(stderr, "Error: execve(%s, argv, envp) - %s\n",
+			prog,
+			strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+
+	return EXIT_SUCCESS;
+}

Added: xbill.install
===================================================================
--- xbill.install	                        (rev 0)
+++ xbill.install	2008-12-16 06:16:27 UTC (rev 21759)
@@ -0,0 +1,25 @@
+pre_install() {
+  if [ ! -e var/games/xbill/scores ]; then
+    [ -e usr/var/xbill/scores ] && mv usr/var/xbill/scores var/games/xbill/scores
+  fi
+}
+
+post_install() {
+  touch var/games/xbill/scores
+  chown root:games var/games/xbill/scores
+  chmod 664 var/games/xbill/scores
+}
+
+pre_upgrade() {
+  pre_install $1
+}
+
+post_upgrade() {
+  post_install $1
+}
+
+post_remove() {
+  if [ -e var/games/xbill/scores ]; then
+    mv var/games/xbill/scores var/games/xbill/scores.pacsave
+  fi
+}




More information about the arch-commits mailing list