--- /dev/null
+// $Id$ --*- c -*--
+
+// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef H_UTIL_VSERVER_COMPAT_C99_H
+#define H_UTIL_VSERVER_COMPAT_C99_H
+
+#if defined(__GNUC__) && __GNUC__ < 3 || (__GNUC__==3 && __GNUC_MINOR__<3)
+# warning Enabling hacks to make it compilable with non-C99 compilers
+# define BS { do {} while (0)
+# define BE } do {} while (0)
+#else
+# define BS do {} while (0)
+# define BE do {} while (0)
+#endif
+
+#endif // H_UTIL_VSERVER_COMPAT_C99_H
--- /dev/null
+## $Id$ --*- makefile -*--
+
+## Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 2 of the License.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+src_testsuite_check_active_PRGS = src/testsuite/vunify-functest
+src_testsuite_check_passive_PRGS = src/testsuite/rpm-fake-test
+
+
+src_testsuite_check_PRGS = $(src_testsuite_check_passive_PRGS) \
+ $(src_testsuite_check_active_PRGS)
+
+src_testsuite_check_src_SCRPTS = src/testsuite/vunify-test.sh
+src_testsuite_check_gen_SCRPTS =
+
+src_testsuite_check_SCRPTS = $(src_testsuite_check_src_SCRPTS) \
+ $(src_testsuite_check_gen_SCRPTS)
+
+src_testsuite_TSTS = $(src_testsuite_check_active_PRGS) \
+ $(src_testsuite_check_SCRPTS)
+
+src_testsuite_XTRAS = $(src_testsuite_check_src_SCRPTS)
+
+
+src_testsuite_rpm_fake_test_SOURCES = src/testsuite/rpm-fake-test.c
+
+src_testsuite_vunify_functest_SOURCES = src/testsuite/vunify-functest.c \
+ src/vunify-matchlist.c
+
+src_testsuite_vunify_functest_CPPFLAGS= $(AM_CPPFLAGS) $(src_testsuite_CPPFLAGS)
+
+
+src_testsuite_CPPFLAGS = -I $(top_srcdir)/src -D ENSC_TESTSUITE
--- /dev/null
+Proot
+Groot
+Pbar
+Gbar
+Pfoo
+Gfoo
+Pnobody
+Gnobody
+Cp
+Cg
+Pfoo
+Gfoo
+Pnobody
+Gnobody
--- /dev/null
+P(root) = 0
+G(root) = 0
+P(bar) = 501
+G(bar) = 501
+P(foo) = 500
+G(foo) = 500
+P(nobody) = (null)
+G(nobody) = (null)
+P(foo) = 500
+G(foo) = 500
+P(nobody) = (null)
+G(nobody) = (null)
+s_context: 49171 [ -16365]
--- /dev/null
+// $Id$ --*- c -*--
+
+// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "src/wrappers.h"
+
+#include <grp.h>
+#include <pwd.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int wrapper_exit_code = 1;
+
+int main(int argc, char *argv[])
+{
+ char buf[1000];
+
+ while (true) {
+ char *ptr = buf;
+ char c;
+ do {
+ if (read(0, &c, 1)==0) break;
+ if (c=='\n') break;
+ *ptr++ = c;
+ } while (ptr<buf+sizeof(buf));
+ *ptr = '\0';
+ if (ptr==buf) break;
+
+ switch (buf[0]) {
+ case 'P' : {
+ struct passwd *pw;
+
+ pw = getpwnam(buf+1);
+ printf("P(%s) = ", buf+1);
+ if (pw) printf("%u\n", pw->pw_uid);
+ else printf("(null)\n");
+
+ break;
+ }
+
+ case 'G' : {
+ struct group *gr;
+
+ gr = getgrnam(buf+1);
+ printf("G(%s) = ", buf+1);
+ if (gr) printf("%u\n", gr->gr_gid);
+ else printf("(null)\n");
+
+ break;
+ }
+
+ case 'C' :
+ switch (buf[1]) {
+ case 'g' : endgrent(); break;
+ case 'p' : endpwent(); break;
+ default : abort(); break;
+ }
+ break;
+
+ default :
+ abort();
+ }
+ }
+
+ {
+ char const * cmd[] = { "/bin/grep", "^s_context", "/proc/self/status", 0 };
+ Eexecv(cmd[0], cmd);
+ }
+}
--- /dev/null
+#! /bin/bash
+
+: ${srcdir=.}
+: ${srctestsuitedir=./src/testsuite}
+: ${srcdatadir=$srctestsuitedir/data}
+: ${tmptopdir=/var/tmp}
+
+DEBUG='strace -E'
+
+set -e
+
+tmpdir=$(mktemp -d /var/tmp/rpm-fake-test.XXXXXX)
+trap "rm -rf $tmpdir" EXIT
+
+mkdir -p $tmpdir/{etc,bin}
+cat <<EOF >$tmpdir/etc/passwd
+root:x:0:0:root:/root:/bin/bash
+foo:x:500:500:foo:/:/bin/false
+bar:x:501:501:bar:/:/bin/false
+EOF
+
+cat <<EOF >$tmpdir/etc/group
+root:x:0:root
+foo:x:500:foo
+bar:x:501:bar
+EOF
+
+chmod +rx $tmpdir
+
+RPM_FAKE_RESOLVER_UID=1000 \
+RPM_FAKE_RESOLVER_GID=1000 \
+RPM_FAKE_CTX=-1 \
+RPM_FAKE_RESOLVER=$srcdir/src/rpm-fake-resolver \
+RPM_FAKE_CHROOT=$tmpdir \
+RPM_FAKE_NAMESPACE_MOUNTS=/proc \
+LD_PRELOAD=$srcdir/src/rpm-fake.so \
+./src/testsuite/rpm-fake-test <$srcdir/src/testsuite/data/rpm-fake-test.inp
--- /dev/null
+// $Id$ --*- c -*--
+
+// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "vunify-matchlist.h"
+
+extern void PathInfo_test();
+
+int main()
+{
+ PathInfo_test();
+}
--- /dev/null
+#! /bin/bash
+
+: ${srcdir=.}
+: ${tmptopdir=/var/tmp}
+
+set -e
+
+tmpdir=$(mktemp -d /var/tmp/vunify-test.XXXXXX)
+trap "rm -rf $tmpdir" EXIT
+
+function createFiles
+{
+ local base=$1
+ shift
+
+ local idx=0
+ local i
+ for i; do
+ echo $i >$base$idx
+ let ++idx
+ done
+}
+
+function createSet
+{
+ local base=$1
+
+ createFiles a/$base a b c d
+ createFiles b/$base a b c
+ createFiles c/$base XX XX
+
+ ln a/${base}3 b/${base}3
+}
+
+pushd $tmpdir &>/dev/null
+ mkdir -p {a,b,c}{/etc/sysconfig,/usr/lib,/usr/local/lib/foobar,/var/run}
+
+ createSet etc/CFG
+ createSet etc/sysconfig/CFG
+
+ createSet usr/PROG
+ createSet usr/lib/PROG
+
+ createSet usr/local/lib/LOCAL
+ createSet usr/local/lib/foobar/LOCAL
+
+ createSet var/TEMP
+ createSet var/run/TEMP
+popd &>/dev/null
+
+
+$D $srcdir/src/vunify $tmpdir/a $tmpdir/b
+$D $srcdir/src/vunify $tmpdir/a $tmpdir/c