+++ /dev/null
-.*-up-to-date
-.buexl
-.deps
-.fixups
-.gdb_history
-.pathconfig.h.pathsubst.stamp
-Build-*
-COPYING
-ChangeLog
-FEATURES.txt
-INSTALL
-Makefile
-Makefile.in
-aclocal.m4
-autom4te.cache
-autoscan.log
-compile
-config.cache
-config.guess
-config.h
-config.h.in
-config.log
-config.status
-config.sub
-configure
-configure.scan
-depcomp
-install-sh
-libtool
-linuxcaps.h
-ltmain.sh
-missing
-mkinstalldirs
-pathconfig.h
-releases
-stamp-h1
-stamp-h2
-tmp
-util-vserver*.diff*
-util-vserver*.patch*
-util-vserver-*.tar.bz2*
-util-vserver-*.tar.gz
-util-vserver.spec
-vserver.spec
-vserverx-*.tar.*
+++ /dev/null
-Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+++ /dev/null
-s!ensc@kosh.ultra.csn.tu-chemnitz.de!enrico.scholz@informatik.tu-chemnitz.de!g
+++ /dev/null
-## $Id$
-
-# Copyright (C) 2003,2004 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-#
-
-ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = . distrib
-
-CVS2CL_AMFLAGS = $(CVS2CL_TAG) -U cvsusers.map --show-dead
-CVS2CL_ALLFLAGS := $(CVS2CL_AMFLAGS) $(CVS2CL_FLAGS)
-
-confdir = $(sysconfdir)/vservers
-confdefaultsdir = $(confdir)/.defaults
-sbincfgdir = $(sbindir)
-legacydir = $(pkglibdir)/legacy
-
-include_HEADERS =
-noinst_HEADERS = $(ENSC_VECTOR_HDRS) \
- compat.h compat-c99.h
-
-noinst_LIBRARIES = $(ENSC_VECTOR_LIBS)
-lib_LIBRARIES =
-lib_LTLIBRARIES =
-pkglib_LTLIBRARIES =
-
-pkglib_SCRIPTS =
-pkglib_DATA = FEATURES.txt
-pkglib_PROGRAMS =
-legacy_SCRIPTS =
-legacy_PROGRAMS =
-
-sbin_SCRIPTS =
-sbin_PROGRAMS =
-noinst_PROGRAMS =
-noinst_DATA =
-
-initrd_SCRIPTS =
-sysconf_DATA =
-
-DIETPROGS = $(LIBENSCVECTOR_DIET)
-
-BUILT_SOURCES = pathconfig.h linuxvirtual.h \
- .fixups
-
-man_MANS =
-
-kernel_HDRS = kernel/context.h \
- kernel/cvirt.h \
- kernel/debug.h \
- kernel/dlimit.h \
- kernel/inode.h \
- kernel/legacy.h \
- kernel/limit.h \
- kernel/namespace.h \
- kernel/network.h \
- kernel/sched.h \
- kernel/signal.h \
- kernel/switch.h \
- kernel/xid.h
-
-EXTRA_PROGRAMS =
-EXTRA_DIST = pathconfig.h.pathsubst \
- util-vserver.spec \
- THANKS REQUIREMENTS \
- $(kernel_HDRS)
-
-check_PROGRAMS =
-check_SCRIPTS =
-
-TESTS_DEBUG = no
-TESTS =
-TESTS_ENVIRONMENT = ensc_use_expensive_tests="$(ENSC_USE_EXPENSIVE_TESTS)" \
- ensc_test_debug="$(TESTS_DEBUG)"
-
-AM_CPPFLAGS = -I $(top_srcdir)/lib -I $(top_srcdir)/ensc_wrappers \
- -D_GNU_SOURCE -D_REENTRANT $(RELEASE_CPPFLAGS)
-
-CLEANFILES = $(BUILT_SOURCES) \
- .*.pathsubst.stamp */.*.pathsubst.stamp */*/.*.pathsubst.stamp \
- pathconfig.h .fixups
-
-DISTCLEANFILES = FEATURES.txt
-
-
-AM_INSTALLCHECK_STD_OPTIONS_EXEMPT =
-
-if USE_DIETLIBC
-DIET = diet
-DIET_FLAGS =
-DIET_CC := $(DIET) $(DIET_FLAGS) $(CC)
-VSERVER_LDFLGS := -static
-else
-VSERVER_LDFLGS :=
-endif
-
-if USE_DIETLIBC_COMPAT
-DIET_COMPAT_LDADDS = -lcompat
-else
-DIET_COMPAT_LDADDS =
-endif
-
-VSERVER_LDADDS = $(LIBVSERVER) $(DIET_COMPAT_LDADDS)
-
-silent.%: FORCE
- @t=$$(mktemp /tmp/build.XXXXXX) && \
- $(MAKE) '$*' -s 2>$$t >/dev/null && \
- ( cat $$t | \
- grep -v ': In function' | \
- grep -v 'your code still has assertions enabled' | \
- grep -v ' is obsoleted' | \
- grep -v 'warning: #warning'; \
- rm -f $$t || : )
-
-
-linuxvirtual.h:
-if ENSC_ENABLE_INTERNAL_HEADERS
- ln -sf '$(top_srcdir)/lib/virtual.h' '$@'
-else
- ln -sf '$(kernelincludedir)/linux/virtual.h' '$@' && test -e '$@' || \
- ln -sf '$(top_srcdir)/lib/virtual.h' '$@'
-endif
-
-pathsubst_RULES = s!@'PKGLIBDIR'@!$(pkglibdir)!g; \
- s!@'LEGACYDIR'@!$(legacydir)!g; \
- s!@'SBINDIR'@!$(sbindir)!g; \
- s!@'CONFDIR'@!$(confdir)!g; \
- s!@'SYSCONFDIR'@!$(sysconfdir)!g; \
- s!@'PKGSTATEDIR'@!$(pkgstatedir)!g; \
- s!@'PKGSTATEREVDIR'@!$(pkgstaterevdir)!g; \
- s!@'VSERVERDIR'@!$(vserverdir)!g; \
- s!@'VSERVERPKGDIR'@!$(vserverpkgdir)!g; \
- s!@'VSERVERPKGDIR'@!$(vserverpkgdir)!g; \
- s!@'VSHELPERSTATEDIR'@!$(vshelperstatedir)!g; \
- s!@'INITRDDIR'@!$(initrddir)!g; \
- s!@'LIBDIR'@!$(libdir)!g; \
- s!@'MANDIR'@!$(mandir)!g; \
- s!@'INCLUDEDIR'@!$(includedir)!g; \
- s!@'PACKAGE'@!$(PACKAGE)!g; \
- s!@'PACKAGE_BUGREPORT'@!$(PACKAGE_BUGREPORT)!g; \
- s!@'PACKAGE_NAME'@!$(PACKAGE_NAME)!g; \
- s!@'PACKAGE_STRING'@!$(PACKAGE_STRING)!g; \
- s!@'PACKAGE_TARNAME'@!$(PACKAGE_TARNAME)!g; \
- s!@'PACKAGE_VERSION'@!$(PACKAGE_VERSION)!g; \
- s!@'ENSC_HAVE_C99_COMPILER_TRUE'@!\@ENSC_HAVE_C99_COMPILER_TRUE@ !g; \
- s!@'ENSC_HAVE_C99_COMPILER_FALSE'@!\@ENSC_HAVE_C99_COMPILER_FALSE@ !g; \
- s!@'ENSC_HAVE_CXX_COMPILER_TRUE'@!\@ENSC_HAVE_CXX_COMPILER_TRUE@ !g; \
- s!@'ENSC_HAVE_CXX_COMPILER_FALSE'@!\@ENSC_HAVE_CXX_COMPILER_FALSE@ !g; \
- $(ENSC_PATHPROG_SED)
-
-pathconfig.h: .pathconfig.h.pathsubst.stamp
-.%.pathsubst.stamp: %.pathsubst Makefile
- @mkdir -p $$(dirname '$@')
- @echo "$(SED) -e '...' $*.pathsubst >$*"
- @$(SED) -e '$(pathsubst_RULES)' '$<' >'$@.tmp'
- @-chmod --reference='$<' '$@.tmp'
- @if cmp -s '$@.tmp' '$*'; then \
- echo "... no changes, reusing old version"; \
- rm -f '$@.tmp'; \
- else \
- rm -f '$*'; mv '$@.tmp' '$*'; \
- fi
- @chmod a-w '$*'
- @touch '$@'
-
-pkgstatedir = $(localstatedir)/run/vservers
-pkgstaterevdir = $(confdefaultsdir)/run.rev
-vserverpkgdir = $(vserverdir)/.pkg
-vshelperstatedir = $(localstatedir)/run/vshelper
-
-fix_SCRPTS = $(addprefix $(pkglibdir)/, $(notdir $(pkglib_SCRIPTS))) \
- $(addprefix $(legacydir)/, $(notdir $(legacy_SCRIPTS))) \
- $(addprefix $(sbindir)/, $(notdir $(sbin_SCRIPTS))) \
- $(addprefix $(initrddir)/, $(notdir $(initrd_SCRIPTS)))
-
-update-doc: doc
- $(top_srcdir)/update-doc
-
-install-data-hook: install-fix-script-paths install-create-dirs
-
-install-create-dirs:
- $(mkinstalldirs) -m 755 $(DESTDIR)$(pkgstatedir) $(DESTDIR)$(pkgstatedir).rev $(DESTDIR)$(vshelperstatedir)
- $(mkinstalldirs) -m 755 $(DESTDIR)$(confdefaultsdir)
- f=$(DESTDIR)$(confdefaultsdir)/vdirbase; test -e "$$f" || ln -sf '$(vserverdir)' "$$f"
- f=$(DESTDIR)$(pkgstaterevdir); test -e "$$f" || ln -sf '$(pkgstatedir).rev' "$$f"
-
-install-fix-script-paths:
- test "/usr/lib/util-vserver" = "$(pkglibdir)" || \
- for i in $(fix_SCRPTS); do \
- f="$(DESTDIR)$$i"; \
- $(SED) -e 's!/usr/lib/util-vserver!$(pkglibdir)!g' "$$f" >"$$f.tmp"; \
- $(CMP) -s "$$f.tmp" "$$f" || cat "$$f.tmp" >"$$f"; \
- rm -f "$$f.tmp"; \
- done
-
-install-distribution: _install-vserverdir _install-vshelperlink
-
-_install-vshelperlink:
- $(mkinstalldirs) $(DESTDIR)/sbin
- ln -sf ..$(pkglibdir)/vshelper $(DESTDIR)/sbin/vshelper
-
-_install-vserverdir:
- $(mkinstalldirs) $(DESTDIR)$(vserverdir) $(DESTDIR)$(vserverpkgdir)
-
-.fixups: config.status util-vserver.spec
- chmod a-w util-vserver.spec
- touch $@
-
-if USE_DIETLIBC
-$(addsuffix $(EXEEXT), $(DIETPROGS)) \
-$(addsuffix $(OBJEXT), $(DIETPROGS)) \
- : CC=$(DIET_CC)
-else !USE_DIETLIBC
-nodist_lib_dietlibc_not_enabled_error_a_SOURCES = \
- lib-dietlibc-not-enabled-error.c
-endif
-
-include $(top_srcdir)/lib/Makefile-files
-include $(top_srcdir)/src/Makefile-files
-include $(top_srcdir)/doc/Makefile-files
-include $(top_srcdir)/man/Makefile-files
-include $(top_srcdir)/scripts/Makefile-files
-include $(top_srcdir)/tests/Makefile-files
-include $(top_srcdir)/sysv/Makefile-files
-include $(top_srcdir)/contrib/Makefile-files
-include $(top_srcdir)/ensc_vector/Makefile-files
-include $(top_srcdir)/ensc_wrappers/Makefile-files
-include $(top_srcdir)/ensc_fmt/Makefile-files
-include $(top_srcdir)/lib_internal/Makefile-files
-include $(top_srcdir)/vserver-start/Makefile-files
-
-include $(top_srcdir)/m4/gpgsig.am
-include $(top_srcdir)/m4/validate.am
-include $(top_srcdir)/m4/changelog.am
-include $(top_srcdir)/m4/pkgconfig.am
-
-.PHONY: FORCE update-doc
+++ /dev/null
-version 0.30.205
-================
-
- - large revamping...
-
-
-version 0.23.6
-==============
-
- - fixed '--level' option on 'vserver ... chkconfig'
+++ /dev/null
-Some common notes/FAQs:
-======================
-
-* when vserver startup/shutdown fails, or when you get
-
- | Error: /proc must be mounted
-
- errors, make sure, that 'vprocunhide' was executed. When installing
- 'util-vserver' with packagemanagement, an appropriate initscript
- should be installed
-
-* the name of old-style vservers is shown on 2.4 kernels only; the
- needed functionality is not implemented for 2.6 kernels.
-
-
-
-Some distribution specific notes:
-=================================
-
-Red Hat 7.3, Red Hat 9, Fedora Core 1&2
----------------------------------------
-* tested and running successfully as host and guest systems
-
-* it is *strongly* suggested to use the rpm packages which can be
- created from the tarball with
-
- | $ rpmbuild -tb util-vserver-<version>.tar.bz2
-
- For distributions below Fedora Core 2, additional
-
- | --without dietlibc --without xalan
-
- flags are required for the 'rpmbuild' command. Builds on Red Hat 7.3
- will require a
-
- | --nodeps
-
- also, since 'vconfig' is not available there. Since it is required
- for path-detection only and paths from RH systems will be assumed by
- default, this should not be a big problem.
-
-* guest systems can be created with the 'apt-rpm' or 'yum' build-methods.
- The first one requires the 'apt' package e.g. from http://fedora.us and
- the configuration of a near mirror in
-
- | /etc/vservers/.distributions/<id>/apt/sources.list
-
- (To avoid slashdotting by the masses of util-vserver-users, there
- does not exist a standard mirror).
-
- The 'yum' method uses the repository configuration shipped by the
- fedora-release package.
-
-* RH/FC uses the 'sysv' initstyle which is assumed by default
-
-* when having existing vservers with RH 9 or Fedora Core 1, the startup
- of the vserver will probably fail. You will have to add
-
- | true
-
- to etc/rc.d/rc (within the vserver root directory)
-
-* when having RH/FC guestsystems, it is *strongly* recommended to use
- a dietlibc linked version of 'rpm-fake-resolver'. Else, package
- installation with 'vrpm', 'vapt-get' or 'vyum' can fail since users
- can not be resolved.
-
-
-
-Debian Woody & Sarge
---------------------
-* tested and running successfully as guest systems on FC1/FC2 hosts
-
-* guest systems can be created with the 'debootstrap' method. When
- not already existing, the needed package will be downloaded
- automatically. Since it is updated very often, it can happen
- that a '404 Not found' error occurs; in this case look either
- for a newer util-vserver package, or configure the new URI e.g. with
-
- | echo 'http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_<version>_i386.deb' \
- | >/etc/vservers/.defaults/apps/debootstrap/uri
-
- You can download a local copy of this tarball also, and register it
- with
-
- | echo '/<path-to-the-tarball>' \
- | >/etc/vservers/.defaults/apps/debootstrap/uri
-
-* it is known, that warning messages will be created at startup and
- shutdown of guest servers. This is non fatal and can be ignored
-
-* Debian guest systems are running fine with the 'sysv' initstyle;
- success with 'plain' was reported also
-
-* no packages for Debian hosts are known at time of writing (May 2004)
-
-
-
-Gentoo
-------
-* Gentoo guest systems are very complicated and are requiring lots of
- modifications in the initscripts. Currently, no step-by-step guide
- can be provided
-
-* 'sysv' initstyle is probably not working for Gentoo guests (e.g. you
- will see messages about missing 'utmp' files); 'gentoo' should be
- used instead of:
-
- | echo 'gentoo' >/etc/vservers/<id>/apps/init/style
-
-* there does not exist a build-method for Gentoo guests; instead of,
- create a skeleton with
-
- | # vserver <id> build -m skeleton --initstyle gentoo <other-opts>*
-
- and fill the vserver directory at /etc/vservers/<id>/vdir/ manually.
-
-
-
-Notes for distributors:
-=======================
-
-To generate FHS compliant paths, call configure with
-
-| ./configure --prefix=/usr --mandir=/usr/share/man \
-| --sysconfdir=/etc --localstatedir=/var \
-| --with-vrootdir=<an FHS compliant path for /vservers>
-
-Except the '--with-vrootdir' option, rpm's '%configure' option will
-expand to this.
-
-
-There exists a 'make install-distribution' target which installs
-files outside of the configured 'prefix'. In particular, these files are:
-
-* the /sbin/vshelper symlink
-* the /vservers and related directories (or whatever you configured
- with '--with-vrootdir')
-
-Without this rule, 'make distcheck' would fail.
-
-
-It might be needed also, to call 'setattr --barrier /vservers' in an
-after-installation script.
-
-
-
-Which version shall I use?
-==========================
-
-As you probably know, two branches of 'util-vserver' are existing: the
-'stable' one, and the 'alpha' one. This terms are to be understood as
-a level of the featureset stability but not of the software stability.
-
-E.g. 'stable' is not really stable: it has huge security problems and
-missing functionality. But you can expect that the current configuration
-will work in future versions also. This version is untested on author's
-side and it will be hard to bring patches/fixes in, since it must be
-proofed that they will not break anything.
-
-In the opposite, the 'alpha' branch does not have known security issues
-and works well (at least on author's system ;)). But it may happen
-that some behavior or configuration options change.
-
-With 'alpha' you should be still able to use vservers created with the
-'stable' branch, but you may encounter some oddities -- especially on
-kernel 2.6 systems (e.g. 'vserver-stat' will not show the names of old
-vservers).
-
-
-So let me summarize:
-
-* when you have productive vservers running for some years already, stay
- at the 'stable' branch. A change to 'alpha' will need a completely
- rewritten configuration which must be perhaps changed again.
-
-* when you are new at vservers, use the 'alpha' branch. You will have
- to learn the principles of vserver configuration for both branches
- but 'alpha' makes some things easier.
-
-* when you have existing vservers and want all the new kernel 2.6
- functionality, use the 'alpha' branch.
-
-
-A last note: the 'alpha' branch works both with the stable 2.4 and the
-development 2.6 kernel patch.
-
-
-
-## $Id$
+++ /dev/null
-Build requirements:
-* iproute/iproute2
-* iptables
-* vconfig/vlan (see http://www.candelatech.com/~greear/vlan.html)
-* wget
-
-Recommended build environment:
-* gcc >= 3
-* beecrypt-devel
-* dietlibc >= 0.25
+++ /dev/null
-I want to thank
-
-Jacques Gelinas <jack@solucorp.qc.ca>,
- who wrote and maintains the 'vserver' package on which util-vserver
- is based on
-
-Sam Vilain,
- for providing man-pages and patches used in the Debian package
-
-Olivier Poitrey
- for his work on the XML/XSD based documentation format
-
-
-all the other people, who contributed to the original 'vserver' package
+++ /dev/null
-#! /bin/sh
-
-# Copyright (C) 2004 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.
-
-set -e
-
-confflags="-C --enable-maintainer-mode --prefix=/usr --sysconfdir=/etc --localstatedir=/var"
-configure="`pwd`/configure $confflags"
-make=eval\ "${CLEAN:+make -j2 silent.clean;} \
- echo -e \"== executing 'make all'...\" && \
- make -j2 ${SILENT:+-s silent.}all && \
- echo -e \"\n== executing 'make check'...\" && \
- make -j2 ${SILENT:+-s silent.}check"
-
-LANG=C
-CPPFLAGS='-D_FORTIFY_SOURCE=99'
-
-## Usage: xtermTitle <title>
-function xtermTitle
-{
- tty -s || return 0
- echo -ne "\e]0;$@\007"
-}
-
-## Usage: operate <dir> <configure-opts>*
-function operate()
-{
- d=$1
- shift
-
- echo "******************"
- echo $"** Operating in directory '$d'..."
- xtermTitle "Operating in directory '$d'... ($@)"
-
- mkdir -p $d && cd $d
-
- test -e Makefile || $configure "$@"
- $make
- cd -
-}
-
-case "$1" in
- dist)
- test -e Makefile || \
- CFLAGS='-O0 -g3' CXXFLAGS='-O0 -g3' CPPFLAGS=$CPPFLAGS \
- ./configure $confflags
- $make
- exit
- ;;
- debian-woody|debian-sarge|fc-1-90|fc-1|fc-2|fc-3)
- cat util-vserver-"$2".tar.bz2 | \
- ssh $1 "cd /tmp && rm -rf /tmp/util-vserver-* && \
- tar xjf - && cd util-vserver-$2 && \
- export PATH=/usr/lib/ccache:/usr/lib/ccache/bin:\$PATH && \
- ./configure && \
- make ${SILENT:+-s silent.}all && \
- echo -e '\n\n\n' &&
- make ${SILENT:+-s silent.}check"
- exit
- ;;
- *) test -z "$1" || {
- echo $"Unknown option '$1'" >&2
- exit 1
- }
-esac
-
-test -d "Build" || {
- d=$(mktemp -d /tmp/build-ensc.XXXXXX)
- rm -f Build
- ln -sf $d Build
-}
-
-operate Build/diet-noopt CPPFLAGS=$CPPFLAGS CFLAGS='-O0 -g3' CXXFLAGS='-O0 -g3'
-operate Build/diet-opt --enable-release CPPFLAGS=$CPPFLAGS
-operate Build/nodiet-noopt --disable-dietlibc CPPFLAGS=$CPPFLAGS CFLAGS='-O0 -g3' CXXFLAGS='-O0 -g3'
-operate Build/nodiet-opt --enable-release --disable-dietlibc CPPFLAGS=$CPPFLAGS
-operate Build/gcc32-opt --enable-release --disable-dietlibc CPPFLAGS=$CPPFLAGS CC='ccache gcc32' CXX='ccache g++'
-operate Build/gcc33-opt --enable-release --disable-dietlibc CPPFLAGS=$CPPFLAGS CC='ccache gcc33' CXX='ccache g++33'
+++ /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$ --*- 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_H
-#define H_UTIL_VSERVER_COMPAT_H
-
-#if defined(__dietlibc__) && !defined(ENSC_DIETLIBC_C99) && defined(__STRICT_ANSI__) && defined(__STDC_VERSION__)
-# include <sys/cdefs.h>
-# undef inline
-
-# undef __STRICT_ANSI__
-# include <stdint.h>
-# define __STRICT_ANSI__
-#endif
-
-#if defined(__dietlibc__)
-# define ENSC_FIX_IOCTL(X) do { if ((X)<-1) { errno=-(X); (X) = -1; } } while (0)
-#else
-# define ENSC_FIX_IOCTL(X) do { } while (0)
-#endif
-
-#if defined(__GNUC__)
-# define UNUSED __attribute__((__unused__))
-# define NORETURN __attribute__((__noreturn__))
-# define CONST __attribute__((__const__))
-# if __GNUC__*0x10000 + __GNUC_MINOR__*0x100 + __GNUC_PATCHLEVEL__ >= 0x30300
-# define NONNULL(ARGS) __attribute__((__nonnull__ ARGS))
-# define ALWAYSINLINE __attribute__((__always_inline__))
-# else
-# define NONNULL(ARGS)
-# define ALWAYSINLINE
-# define PURE
-# endif
-# if __GNUC__*0x10000 + __GNUC_MINOR__*0x100 + __GNUC_PATCHLEVEL__ >= 0x30303
-# define PURE __attribute__((__pure__))
-# else
-# define PURE
-# endif
-#else
-# define NONNULL(ARGS)
-# define UNUSED
-# define NORETURN
-# define ALWAYSINLINE
-# define PURE
-# define CONST
-#endif
-
- // shamelessly stolen from dietlibc
-#define LINK_WARNING(symbol,msg) \
- __asm__ (".section .gnu.warning." symbol "\n\t.string \"" msg "\"\n\t.previous")
-
-#if !defined(__builtin_expect) && (__GNUC__+0)<3
-# define __builtin_expect(foo,bar) (foo)
-#endif
-
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__<199901L)
-# define restrict
-#endif
-
-#if !defined(HAVE_DECL_MS_MOVE) || !(HAVE_DECL_MS_MOVE)
- // from <linux/fs.h>
-# define MS_MOVE 8192
-#endif
-
-#ifndef HAVE_XID_T
-#include <stdint.h>
-typedef uint32_t xid_t;
-#endif
-
-#ifndef HAVE_NID_T
-#include <stdint.h>
-typedef uint32_t nid_t;
-#endif
-
-
-#if defined(__dietlibc__)
- #define TEMP_FAILURE_RETRY(expression) \
- (__extension__ \
- ({ long int __result; \
- do __result = (long int) (expression); \
- while (__result == -1L && errno == EINTR); \
- __result; }))
-#endif
-
-#define FMT_PREFIX utilvserver_fmt_
-
-#endif // H_UTIL_VSERVER_COMPAT_H
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2003,2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2, or (at your option)
-dnl any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-dnl
-dnl
-dnl As a special exception to the GNU General Public License, if you
-dnl distribute this file as part of a program that contains a configuration
-dnl script generated by Autoconf, you may include it under the same
-dnl distribution terms that you use for the rest of that program.
-dnl
-
-AC_PREREQ(2.57)
-AC_INIT(util-vserver, 0.30.205, enrico.scholz@informatik.tu-chemnitz.de)
-AC_CONFIG_SRCDIR([src/capchroot.c])
-AC_CONFIG_HEADER([config.h])
-
-AM_INIT_AUTOMAKE([1.9 gnits dist-bzip2 subdir-objects])
-AM_MAINTAINER_MODE
-
-AC_CANONICAL_BUILD
-AC_CANONICAL_HOST
-
-AC_SUBST(GPG_KEY, "0xFFD316AC53ACA43A!")
-
-# Checks for programs.
-AC_PROG_CXX
-AC_PROG_CC
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AM_PROG_CC_C_O
-ENSC_CXXCOMPILER
-ENSC_C99COMPILER
-
-ENSC_SET_SEARCHPATH([$PATH:/sbin:/usr/sbin:/usr/local/sbin])
-ENSC_PATHPROG_STANDARD_TOOLS
-
-ENSC_PATHPROG(IP, ip,, [Usually, this tool is shipped in the 'iproute' or 'iproute2' package of your distribution])
-ENSC_PATHPROG(IPTABLES, iptables)
-ENSC_PATHPROG(MODPROBE, modprobe)
-ENSC_PATHPROG(NAMEIF, nameif)
-ENSC_PATHPROG(RMMOD, rmmod)
-ENSC_PATHPROG(VCONFIG, vconfig,, [See http://www.candelatech.com/~greear/vlan.html; usually this tool is shipped in the 'vconfig' or 'vlan' package of your distribution])
-ENSC_PATHPROG(WGET, wget)
-
-ENSC_PATHPROG(DOXYGEN, doxygen, [:])
-ENSC_PATHPROG(XSLTP, xsltp, [:])
-ENSC_PATHPROG(XSLTPROC, xsltproc, [:])
-
-
-AM_CONDITIONAL(HAVE_XSLTP, test "$XSLTP" != ':')
-AM_CONDITIONAL(HAVE_XSLTPROC, test "$XSLTPROC" != ':')
-
-
-ENSC_CHECK_CC_FLAG([-std=c99 -Wall -pedantic -W])
-ENSC_CHECK_CXX_FLAG([-ansi -Wall -pedantic -W -fmessage-length=0])
-
-ENSC_FPIC_SYSCALL
-
-
-AC_MSG_CHECKING([whether to enable debug-code in library])
-AC_ARG_ENABLE([lib-debug],
- [AC_HELP_STRING([--enable-lib-debug],
- [enable additional debug code in library (default: no)])],
- [case "$enableval" in
- yes) use_lib_debug=1;;
- no) use_lib_debug=;;
- *) AC_MSG_ERROR(['$enableval' is not a valid value for '--enable-lib-debug']);;
- esac],
- [ use_lib_debug= ])
-
-if test x"$use_lib_debug" = x; then
- AC_SUBST(LIB_DEBUG_CPPFLAGS, [-DNDEBUG])
- AC_MSG_RESULT(no)
-else
- AC_SUBST(LIB_DEBUG_CPPFLAGS, [])
- AC_MSG_RESULT(yes)
-fi
-
-AC_MSG_CHECKING([whether to enable expensive tests])
-AC_ARG_ENABLE([expensive-tests],
- [AC_HELP_STRING([--disable-expensive-tests],
- [disable tests which might be expensive on some systems (default: no)])],
- [case "$enableval" in
- (yes|no) use_expensive_tests=$enableval;;
- (*) AC_MSG_ERROR(['$enableval' is not a valid value for '--disable-expensive-tests']);;
- esac],
- [ use_expensive_tests=yes ])
-AC_MSG_RESULT($use_expensive_tests)
-
-AC_SUBST(ENSC_USE_EXPENSIVE_TESTS, "$use_expensive_tests")
-
-
-AC_ARG_VAR(CC, [The C compiler])
-
-ENSC_INITRDDIR(initrddir)
-ENSC_RELEASE(RELEASE_CPPFLAGS)
-
-dnl ###########################
-dnl
-dnl {some dietlibc related tests
-dnl
-ENSC_ENABLE_DIETLIBC(USE_DIETLIBC, [0.25])
-
-if test x"$ensc_have_dietlibc" = xno; then
- AC_MSG_WARN([*** ***])
- AC_MSG_WARN([*** it is strongly recommended to link util-vserver against ***])
- AC_MSG_WARN([*** dietlibc; glibc's NSS functions are very unreliable in ***])
- AC_MSG_WARN([*** chroot() environments, so you have to expect problems ***])
- AC_MSG_WARN([*** there. ***])
- AC_MSG_WARN([*** ***])
- AM_CONDITIONAL(USE_DIETLIBC_COMPAT, false)
-else
- # HACK: libtool does not have cmdline options to build only
- # dynamic libraries; this can be done with the
- # '--disable-static' ./configure option only. As our static
- # libraries will be build with dietlibc, we have to do set
- # this option which is evaluated by 'AC_PROG_LIBTOOL'
- # below. Therefore, this macro must not be called earlier.
- enable_static=no
-
- ENSC_DIETLIBC_SANITYCHECK
- ENSC_DIETLIBC_NEED_COMPAT(USE_DIETLIBC_COMPAT)
-fi
-
-# HACK: see comments at 'enable_static' above
-AC_PROG_LIBTOOL
-dnl
-dnl dietlibc stuff ends here}
-dnl
-dnl ##########################
-
-
-ENSC_KERNEL_HEADERS(kernelincludedir)
-ENSC_UV_VROOTDIR(vserverdir)
-ENSC_CHANGELOG([trunk])
-
-
-dnl ##########################
-dnl
-dnl {Check whether to use external kernel headers
-dnl
-AC_MSG_CHECKING([whether to use internal kernel headers])
-AC_ARG_ENABLE([internal-headers],
- [AC_HELP_STRING([--disable-internal-headers],
- [use vserver specific headers from the kernel instead of the shipped versions (default: no)])],
- [case "$enableval" in
- (yes|no) ;;
- (*) AC_MSG_ERROR(['$i' is not a supported value for '--disable-internal-headers']);;
- esac],
- [enable_internal_headers=yes])
-
-AM_CONDITIONAL(ENSC_ENABLE_INTERNAL_HEADERS, [test x"$enable_internal_headers" = xyes])
-AC_MSG_RESULT([$enable_internal_headers])
-dnl
-dnl the check regarding external kernel headers ends here}
-dnl
-dnl ##########################
-
-dnl ##########################
-dnl
-dnl {Check for the APIs to be used
-dnl
-AC_MSG_CHECKING([for supported APIs])
-AC_ARG_ENABLE([apis],
- [AC_HELP_STRING([--enable-apis=APIS],
- [enable support for the given apis; possible values are: legacy,compat,v11,v13,fscompat,net,ALL (default: all except 'legacy')])],
- [],
- [enable_apis=compat,v11,v13,fscompat,net])
-
-test x"$enable_apis" != xALL || enable_apis='legacy,compat,v11,v13,fscompat,net'
-enable_api_oldproc=
-enable_api_olduts=
-old_IFS=$IFS
-IFS=,;
-for i in $enable_apis; do
- case "$i" in
- (compat) AC_DEFINE(VC_ENABLE_API_COMPAT, 1, [Enable support for compatibility syscall API])
- enable_api_oldproc=1
- enable_api_olduts=1
- ;;
- (legacy) AC_DEFINE(VC_ENABLE_API_LEGACY, 1, [Enable support for old, /proc parsing API])
- enable_api_old_proc=1
- enable_api_olduts=1
- ;;
- (v11) AC_DEFINE(VC_ENABLE_API_V11, 1, [Enable support for API of vserver 1.1.x])
- enable_api_oldproc=1
- enable_api_olduts=1
- ;;
- (v13) AC_DEFINE(VC_ENABLE_API_V13, 1, [Enable support for API of vserver 1.3.x]);;
- (net) AC_DEFINE(VC_ENABLE_API_NET, 1, [Enable support for network context API]);;
- (fscompat) AC_DEFINE(VC_ENABLE_API_FSCOMPAT, 1, [Enable support for filesystem compatibility API]);;
- (*) AC_MSG_ERROR(['$i' is not a supported API]);;
- esac
-done
-IFS=$old_IFS
-if test x"$enable_api_oldproc" != x; then
- AC_DEFINE(VC_ENABLE_API_OLDPROC, 1, [Enable API for a backward compatible /proc parsing])
- enable_apis="$enable_apis,oldproc"
-fi
-if test x"$enable_api_olduts" != x; then
- AC_DEFINE(VC_ENABLE_API_OLDUTS, 1, [Enable API for a backward compatible uts handling])
- enable_apis="$enable_apis,olduts"
-fi
-AC_MSG_RESULT([$enable_apis])
-dnl
-dnl the check for used APIs ends here}
-dnl
-dnl ##########################
-
-
-ENSC_SYSCALLNR(vserver,273)
-ENSC_SYSCALL
-ENSC_CHECK_EXT2FS_HEADER
-AC_CHECK_FUNCS([vserver])
-AC_CHECK_DECLS(MS_MOVE,,,[#include <linux/fs.h>])
-AC_CHECK_TYPES(xid_t,,,[#include <sys/types.h>])
-AC_CHECK_TYPES(nid_t,,,[#include <sys/types.h>])
-
-AC_CHECK_HEADERS([sys/capability.h])
-
-
-dnl ########################
-dnl
-dnl {check for beecrypt
-dnl
-if test x"$ensc_cv_c99_c99compiler" = xyes; then
- ensc_have_beecrypt=yes
-
- if test x"$ensc_have_beecrypt" = xyes; then
- AC_CHECK_HEADER([beecrypt/beecrypt.h], [ : ],
- [ ensc_have_beecrypt=no ])
- fi
-
- if test x"$ensc_have_beecrypt" = xyes; then
- AC_CHECK_LIB(beecrypt, hashFunctionContextInit, [ : ],
- [ ensc_have_beecrypt=no ])
- fi
-
- if test x"$ensc_have_beecrypt" != xyes; then
- AC_MSG_WARN([
-****
-**** 'beecrypt' could not be found;
-**** this will disable the build of 'vhashify'
-****])
- fi
-else
- ensc_have_beecrypt=no
-fi
-
-AM_CONDITIONAL(ENSC_HAVE_BEECRYPT, test x"$ensc_have_beecrypt" = xyes)
-AM_CONDITIONAL(ENSC_CAN_BEECRYPT_WITH_DIETLIBC, false)
-dnl
-dnl beecrypt stuff ends here}
-dnl
-dnl ########################
-
-
-dnl BIG HACK! Do some autodetection here!
-AC_DEFINE(UTMP_GID, [22], [The utmp gid-number])
-
-if false; then
- AC_DEFINE(HAVE_GROWING_STACK, [1], [Define to 1 if the stack is on growing addresses])
-fi
-
-AC_DEFINE(_FILE_OFFSET_BITS, [64], [Use 64bit interface for filesystem operations])
-
-dnl ########################
-dnl
-dnl {The final info-page
-dnl
-ensc_cxx_affected=" (affected: vbuild, vcheck)"
-ensc_c99_affected=" (affected: vunify, vcopy, vhashify, vdlimit)"
-ensc_diet_msg=" (you have been warned)"
-ensc_diet_version_msg=" ($ensc_version_dietlibc)"
-ensc_diet_compat_msg=" (using -lcompat)"
-test x"$ensc_cv_cxx_cxxcompiler" = xno || ensc_cxx_affected=
-test x"$ensc_cv_c99_c99compiler" = xno || ensc_c99_affected=
-test x"$ensc_have_dietlibc" = xno || ensc_diet_msg=
-test x"$ensc_version_dietlibc" != x || ensc_diet_version_msg=
-test x"$ensc_have_dietlibc$ensc_cv_c_dietlibc_compat" = xyesyes || ensc_diet_compat_msg=
-
-AH_BOTTOM([#include "compat.h"
-])
-AC_CONFIG_COMMANDS_PRE([
- FEATURES_TXT="\
-Features:
- CC: $CC, $($CC --version | sed -e '1p;d')
- CXX: $CXX, $($CXX --version | sed -e '1p;d')
- CPPFLAGS: '$CPPFLAGS'
- CFLAGS: '$CFLAGS'
- CXXFLAGS: '$CXXFLAGS'
- build/host: $build/$host
- Use dietlibc: $ensc_have_dietlibc$ensc_diet_version_msg$ensc_diet_msg$ensc_diet_compat_msg
- Build C++ programs: $ensc_cv_cxx_cxxcompiler$ensc_cxx_affected
- Build C99 programs: $ensc_cv_c99_c99compiler$ensc_c99_affected
- Available APIs: $enable_apis
- ext2fs Source: $ensc_cv_test_ext2fs_header
- syscall(2) invocation: $with_syscall
- vserver(2) syscall#: $ensc_cv_value_syscall_vserver
-
-Paths:
- prefix: $prefix
- sysconf-Directory: $sysconfdir
- cfg-Directory: $sysconfdir/vservers
- initrd-Directory: $initrddir
- pkgstate-Directory: $localstatedir/run/vservers
- Kernelheaders: $kernelincludedir
- vserver-Rootdir: $vserverdir
-"
- echo "$FEATURES_TXT" >FEATURES.txt
- ])
-dnl
-dnl final info-page ends here}
-dnl
-dnl ########################
-
-AC_CONFIG_FILES([util-vserver.spec Makefile distrib/Makefile lib/apidoc/Doxyfile])
-AC_OUTPUT
-
-AC_MSG_NOTICE([
-
-$PACKAGE_STRING
-
-$FEATURES_TXT])
+++ /dev/null
-.manifest.dat.pathsubst.stamp
-manifest.dat
+++ /dev/null
-## $Id$ -*- makefile -*-
-
-## Copyright (C) 2004 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; either version 2, or (at your option)
-## any later version.
-##
-## 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.
-##
-
-
-contrib_gen_DTA = contrib/manifest.dat
-contrib_subst_SRCS = contrib/manifest.dat.pathsubst
-
-
-noinst_DATA += $(contrib_gen_DTA)
-CLEANFILES += $(contrib_gen_DTA)
-
-EXTRA_DIST += $(contrib_subst_SRCS) \
- contrib/make-manifest
-
-contrib/manifest.dat: contrib/.manifest.dat.pathsubst.stamp
+++ /dev/null
-#! /bin/bash
-
-# Copyright (C) 2004 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.
-
-## Usage: make-manifest <basename> <destdir> <datfile>
-
-name=$1
-dest=$2
-data=$3
-
-for i in $name-{core,devel,base,build,legacy,lib,sysv}.list; do
- echo '%defattr(-,root,root,-)' >$i
-done
-
-sed -e "s!@CONFIG@!$MANIFEST_CONFIG!g;
- s!@CONFIG_NOREPLACE@!$MANIFEST_CONFIG_NOREPLACE!g" \
- $data | \
-while read style file; do
- test "$file" || continue
- case "$style" in
- (\#*) continue;;
- esac
- echo "$file" >>$name-$style.list
-done
+++ /dev/null
-lib @LIBDIR@/libvserver.so.*
-devel @LIBDIR@/libvserver.a
-devel @LIBDIR@/libvserver.so
-base @PKGLIBDIR@/functions
-build @PKGLIBDIR@/vserver-build.apt-rpm
-build @PKGLIBDIR@/vserver-build.skeleton
-build @PKGLIBDIR@/vserver-build.debootstrap
-build @PKGLIBDIR@/vserver-build.yum
-build @PKGLIBDIR@/vserver-build.rpm
-build @PKGLIBDIR@/vserver-build.functions
-build @PKGLIBDIR@/vserver-build.functions.apt
-build @PKGLIBDIR@/vserver-build.functions.rpm
-build @PKGLIBDIR@/vserver-build.functions.yum
-build @PKGLIBDIR@/vserver-build.functions.pkgmgmt
-build @PKGLIBDIR@/vserver-setup.functions
-base @PKGLIBDIR@/vserver.functions
-base @PKGLIBDIR@/vserver.start
-@ENSC_HAVE_C99_COMPILER_TRUE@base @PKGLIBDIR@/vserver.start.bin
-base @PKGLIBDIR@/vserver.stop
-base @PKGLIBDIR@/vserver.suexec
-core @PKGLIBDIR@/util-vserver-vars
-build @PKGLIBDIR@/rpm-fake.so
-legacy @LEGACYDIR@/save_s_context
-legacy @LEGACYDIR@/vps
-legacy @LEGACYDIR@/vserver
-legacy @LEGACYDIR@/vserverkillall
-legacy @LEGACYDIR@/distrib-info
-legacy @LEGACYDIR@/ifspec
-legacy @LEGACYDIR@/listdevip
-legacy @LEGACYDIR@/parserpmdump
-legacy @LEGACYDIR@/rebootmgr
-legacy @LEGACYDIR@/rootshell
-legacy @LEGACYDIR@/showperm
-legacy @LEGACYDIR@/vreboot
-core @PKGLIBDIR@/FEATURES.txt
-base @PKGLIBDIR@/defaults/mtab
-base @PKGLIBDIR@/defaults/vprocunhide-files
-build @PKGLIBDIR@/defaults/fstab
-build @PKGLIBDIR@/defaults/debootstrap.uri
-@ENSC_HAVE_C99_COMPILER_TRUE@build @PKGLIBDIR@/defaults/vunify-exclude
-base @PKGLIBDIR@/capchroot
-base @PKGLIBDIR@/chain-echo
-core @PKGLIBDIR@/chcontext-compat
-base @PKGLIBDIR@/check-unixfile
-base @PKGLIBDIR@/chroot-cat
-base @PKGLIBDIR@/chroot-rm
-base @PKGLIBDIR@/exec-ulimit
-base @PKGLIBDIR@/fakerunlevel
-base @PKGLIBDIR@/filetime
-base @PKGLIBDIR@/lockfile
-base @PKGLIBDIR@/keep-ctx-alive
-base @PKGLIBDIR@/mask2prefix
-build @PKGLIBDIR@/pkgmgmt
-base @PKGLIBDIR@/readlink
-build @PKGLIBDIR@/rpm-fake-resolver
-base @PKGLIBDIR@/save_ctxinfo
-base @PKGLIBDIR@/secure-mount
-base @PKGLIBDIR@/sigexec
-base @PKGLIBDIR@/start-vservers
-build @PKGLIBDIR@/vapt-get-worker
-build @PKGLIBDIR@/vyum-worker
-@ENSC_HAVE_CXX_COMPILER_TRUE@build @PKGLIBDIR@/vbuild
-@ENSC_HAVE_CXX_COMPILER_TRUE@build @PKGLIBDIR@/vcheck
-build @PKGLIBDIR@/vpkg
-base @PKGLIBDIR@/vprocunhide
-build @PKGLIBDIR@/vrpm-preload
-build @PKGLIBDIR@/vrpm-worker
-build @PKGLIBDIR@/vserver-build
-sysv @PKGLIBDIR@/vserver-wrapper
-base @PKGLIBDIR@/vshelper
-base @PKGLIBDIR@/vshelper-sync
-sysv @PKGLIBDIR@/vsysvwrapper
-@ENSC_HAVE_C99_COMPILER_TRUE@build @PKGLIBDIR@/vcopy
-@ENSC_HAVE_C99_COMPILER_TRUE@build @PKGLIBDIR@/vunify
-@ENSC_HAVE_C99_COMPILER_TRUE@build @PKGLIBDIR@/vhashify
-base @PKGLIBDIR@/vservers.grabinfo.sh
-build @PKGLIBDIR@/distributions
-devel @LIBDIR@/pkgconfig/util-vserver.pc
-core @SBINDIR@/chbind
-core @SBINDIR@/chcontext
-core @SBINDIR@/chxid
-base @SBINDIR@/exec-cd
-core @SBINDIR@/lsxid
-core @SBINDIR@/reducecap
-core @SBINDIR@/setattr
-core @SBINDIR@/showattr
-build @SBINDIR@/vapt-get
-build @SBINDIR@/vyum
-core @SBINDIR@/vattribute
-core @SBINDIR@/vcontext
-core @SBINDIR@/vdlimit
-core @SBINDIR@/vnamespace
-base @SBINDIR@/vdu
-@ENSC_HAVE_CXX_COMPILER_TRUE@build @SBINDIR@/vfiles
-core @SBINDIR@/vkill
-core @SBINDIR@/vlimit
-base @SBINDIR@/vps
-base @SBINDIR@/vpstree
-build @SBINDIR@/vrpm
-core @SBINDIR@/vrsetup
-core @SBINDIR@/vsched
-base @SBINDIR@/vserver
-build @SBINDIR@/vserver-copy
-core @SBINDIR@/vserver-info
-base @SBINDIR@/vserver-stat
-base @SBINDIR@/vsomething
-base @SBINDIR@/vtop
-core @SBINDIR@/vuname
-devel @INCLUDEDIR@/vserver.h
-core @MANDIR@/*/chbind*
-core @MANDIR@/*/chcontext*
-core @MANDIR@/*/reducecap*
-legacy @MANDIR@/*/distrib-info*
-build @MANDIR@/*/vserver-copy*
-legacy @MANDIR@/*/rebootmgr*
-legacy @MANDIR@/*/vps.*
-base @MANDIR@/*/vpstree.*
-base @MANDIR@/*/vserver-stat*
-base @MANDIR@/*/vserver.*
-base @MANDIR@/*/vtop*
-legacy @CONFIG@ @INITRDDIR@/v_gated
-legacy @CONFIG@ @INITRDDIR@/v_httpd
-legacy @CONFIG@ @INITRDDIR@/v_named
-legacy @CONFIG@ @INITRDDIR@/v_portmap
-legacy @CONFIG@ @INITRDDIR@/v_sendmail
-legacy @CONFIG@ @INITRDDIR@/v_smb
-legacy @CONFIG@ @INITRDDIR@/v_sshd
-legacy @CONFIG@ @INITRDDIR@/v_xinetd
-sysv @CONFIG@ @INITRDDIR@/vprocunhide
-sysv @CONFIG@ @INITRDDIR@/vservers-default
-legacy @CONFIG@ @INITRDDIR@/rebootmgr
-legacy @CONFIG@ @INITRDDIR@/vservers-legacy
-legacy @CONFIG_NOREPLACE@ @SYSCONFDIR@/vservers.conf
-build @CONFIG_NOREPLACE@ @CONFDIR@/.distributions/*/apt/sources.list
+++ /dev/null
-ensc:Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+++ /dev/null
-Makefile
-Makefile.in
+++ /dev/null
-## $Id$
-
-## 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.
-
-confdir = $(sysconfdir)/vservers
-defaultsdir = $(pkglibdir)/defaults
-distribdir = $(pkglibdir)/distributions
-confdistribdir = $(confdir)/.distributions
-confdefaultsdir = $(confdir)/.defaults
-
-defaults_DATA = misc/debootstrap.uri \
- misc/fstab \
- misc/mtab \
- misc/vprocunhide-files \
- misc/vunify-exclude
-
-nobase_distrib_SCRIPTS = redhat/initpost \
- redhat/initpre \
- redhat/rc.sysinit
-
-nobase_distrib_DATA = defaults/devs \
- defaults/apt.conf \
- defaults/rpm/macros \
- defaults/apt/apt.conf \
- template/initpost template/initpre \
- rh9/apt/rpmpriorities rh9/pkgs/01 rh9/pkgs/02 \
- fc1/apt/rpmpriorities fc1/pkgs/01 fc1/pkgs/02 \
- fc2/apt/rpmpriorities fc2/pkgs/01 fc2/pkgs/02 \
- fc3/apt/rpmpriorities fc3/pkgs/01 fc3/pkgs/02 fc3/pkgs/03 \
- fc3/yum/yum.conf $(wildcard fc3/yum.repos.d/fedora*.repo) \
- $(wildcard fc3/rpmlist.d/*.lst) $(wildcard fc3/rpmlist.d/*.opt) \
- suse91/apt/rpmpriorities suse91/pkgs/01 suse91/pkgs/02 \
- suse91/rpm/macros
-
-nobase_confdistrib_DATA = rh9/apt/sources.list \
- fc1/apt/sources.list \
- fc2/apt/sources.list \
- fc3/apt/sources.list \
- suse91/apt/sources.list
-
-AM_INSTALLCHECK_STD_OPTIONS_EXEMPT \
- = $(nobase_distrib_SCRIPTS)
-
-EXTRA_DIST = $(nobase_distrib_DATA) \
- $(nobase_distrib_SCRIPTS) \
- $(nobase_confdistrib_DATA) \
- $(defaults_DATA)
-
-redhat_style = rh9 fc1 fc2
-
-
-install-data-hook:
- l="$(redhat_style)"; for i in $$l; do \
- ln -sf ../redhat/initpost $(DESTDIR)$(distribdir)/$$i/ && \
- ln -sf ../redhat/initpre $(DESTDIR)$(distribdir)/$$i/; \
- done
- $(mkinstalldirs) $(DESTDIR)$(confdir) \
- $(DESTDIR)$(confdistribdir)/.common/pubkeys \
- $(DESTDIR)$(confdefaultsdir) \
- $(DESTDIR)$(confdefaultsdir)/apps/vunify/hash \
- $(DESTDIR)$(confdefaultsdir)/files
+++ /dev/null
-RPM {
- Ignore { "gpg-pubkey"; };
-}
+++ /dev/null
-// Do not remove 'autogenerated' tags and keep them on an own line
-// which can be commented out
-
-Dir {
- Etc "@APTETCDIR@"; // @autogenerated@: APTETCDIR
-}
+++ /dev/null
-null c 1 3 666
-zero c 1 5 666
-full c 1 7 666
-random c 1 8 644
-urandom c 1 9 644
-tty c 5 0 666
-ptmx c 5 2 666
+++ /dev/null
-# Because of https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=52725
-# you have to use at least one language beside 'C'
-%_install_langs C:de:en:es:fr
-%_netsharedpath /dev:/etc/rc.d/init.d/halt:/sbin/new-kernel-pkg:/usr/bin/rhgb-client
+++ /dev/null
-Essential:
- basesystem
- coreutils
- filesystem
- glibc
- setup
+++ /dev/null
-# rpm http://ftp.ultra.csn.tu-chemnitz.de/pub/mirror/fedora/core/.apt 1/i386 os patches updates
-# rpm-src http://ftp.ultra.csn.tu-chemnitz.de/pub/mirror/fedora/core/.apt 1/i386 os patches updates
-
-# rpm ftp://ftp.ussg.iu.edu/pub/linux/fedora/fedora/fedora 1/i386 os updates
-# rpm ftp://ftp.tu-chemnitz.de/pub/linux/fedora/fedora 1/i386 os updates
-# rpm http://mirrors.usc.edu/pub/linux/fedora/fedora 1/i386 os updates
-# rpm http://sunsite.informatik.rwth-aachen.de/ftp/pub/Linux/fedora/fedora 1/i386 os updates
-# rpm http://download.fedora.us/fedora/fedora 1/i386 os updates
+++ /dev/null
---reinstall
-
-filesystem
+++ /dev/null
-Essential:
- basesystem
- coreutils
- filesystem
- glibc
- setup
+++ /dev/null
-# rpm http://ftp.ultra.csn.tu-chemnitz.de/pub/mirror/fedora/core/.apt 2/i386 os patches updates
-# rpm-src http://ftp.ultra.csn.tu-chemnitz.de/pub/mirror/fedora/core/.apt 2/i386 os patches updates
-
-# rpm ftp://ftp.ussg.iu.edu/pub/linux/fedora/fedora/fedora 2/i386 os updates
-# rpm ftp://ftp.tu-chemnitz.de/pub/linux/fedora/fedora 2/i386 os updates
-# rpm http://mirrors.usc.edu/pub/linux/fedora/fedora/fedora 2/i386 os updates
-# rpm http://sunsite.informatik.rwth-aachen.de/ftp/pub/Linux/fedora/fedora 2/i386 os updates
-# rpm http://download.fedora.us/fedora/fedora 2/i386 os updates
+++ /dev/null
---reinstall
-
-filesystem
+++ /dev/null
-Essential:
- basesystem
- coreutils
- filesystem
- glibc
- setup
+++ /dev/null
-# rpm http://ftp.ultra.csn.tu-chemnitz.de/pub/mirror/fedora/core/.apt 3/i386 os patches updates
-
-# rpm ftp://ftp.ussg.iu.edu/pub/linux/fedora/fedora/fedora 3/i386 os updates
-# rpm ftp://ftp.tu-chemnitz.de/pub/linux/fedora/fedora 3/i386 os updates
-# rpm http://mirrors.usc.edu/pub/linux/fedora/fedora/fedora 3/i386 os updates
-# rpm http://sunsite.informatik.rwth-aachen.de/ftp/pub/Linux/fedora/fedora 3/i386 os updates
-# rpm http://download.fedora.us/fedora/fedora 3/i386 os updates
+++ /dev/null
---reinstall
-
-filesystem
-coreutils
+++ /dev/null
-coreutils
-setup
+++ /dev/null
-filesystem-*.rpm
-setup-*.rpm
-tzdata-*.rpm
-glibc-common-*.rpm
+++ /dev/null
-[development]
-name=Fedora Core 3 - Development Tree
-#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/development/$basearch/
-mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-core-rawhide
-enabled=0
+++ /dev/null
-[updates-testing]
-name=Fedora Core 3 - $basearch - Test Updates
-#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/testing/3/$basearch/
-mirrorlist=http://fedora.redhat.com/download/mirrors/updates-testing-fc3
-enabled=0
-gpgcheck=1
+++ /dev/null
-[updates-released]
-name=Fedora Core 3 - $basearch - Released Updates
-#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/3/$basearch/
-mirrorlist=http://fedora.redhat.com/download/mirrors/updates-released-fc3
-enabled=1
-gpgcheck=1
+++ /dev/null
-[base]
-name=Fedora Core 3 - $basearch - Base
-#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/3/$basearch/os/
-mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-core-3
-enabled=1
-gpgcheck=1
+++ /dev/null
-[main]
-cachedir=@YUMCACHEDIR@
-reposdir=@YUMETCDIR@/yum.repos.d
-debuglevel=1
-logfile=@YUMLOGDIR@/log
-pkgpolicy=newest
-distroverpkg=redhat-release
+++ /dev/null
-http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_0.2.45_i386.deb
+++ /dev/null
-none /proc proc defaults 0 0
-none /tmp tmpfs size=16m,mode=1777 0 0
-none /dev/pts devpts gid=5,mode=620 0 0
+++ /dev/null
-/dev/hdv1 / ufs defaults 0 0
+++ /dev/null
-/proc/net/
--/proc/net/rpc/
-/proc/sys/
--/proc/sys/debug/
--/proc/sys/dev/
-/proc/sysvipc/
-/proc/tty/
-/proc/cmdline
-/proc/cpuinfo
-/proc/crypto
-/proc/devices
-/proc/execdomains
-/proc/filesystems
-/proc/interrupts
-/proc/iomem
-/proc/ioports
-/proc/kcore
-/proc/kmsg
-/proc/ksyms
-/proc/loadavg
-/proc/locks
-/proc/meminfo
-/proc/misc
-/proc/modules
-/proc/pci
-/proc/slabinfo
-/proc/stat
-/proc/swaps
-/proc/uptime
-/proc/version
+++ /dev/null
-/.rpmdb
-/dev
-~/etc/shadow
-~/etc/passwd
-~/etc/group
-+/etc/termcap
-+/etc/gconf
-+/etc/gconf/schemas
-/etc/gconf/*
-/etc/*
-/home
-/proc
-/mnt
-+/root/.ssh
-~/root/.ssh/id*
--/root/.ssh/*
-+/root/.gnupg
-~/root/.gnupg/secring*
--/root/.gnupg/*
--/root/*
-/selinux
-/sys
-~/tmp/*
-/tmp
-~/var/tmp/*
-/var
+++ /dev/null
-#! /bin/bash
-
-# 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.
-
-## HACK: this script is full of races...
-
-vdir=$1/vdir
-. "$2"
-
-function relink
-{
- test ! -e "$2" -o -L "$2" || mv -f "$2"{,.orig}
- ln -s "$1" "$2"
-}
-
-## Usage: subst <file> <regexp>
-function subst
-{
- sed -e "$2" "$1" | $_CHROOT_CAT "$1".tmp
- cmp -s "$1".tmp "$1" || cat "$1".tmp | $_CHROOT_CAT "$1"
- rm -f "$1".tmp
-}
-
-pushd "$vdir"/etc/init.d &>/dev/null ||
- pushd "$vdir"/etc/rc.d/init.d &>/dev/null || exit 1
-
- for i in *; do
- test -e "$i" || continue
- case "$i" in
- functions|halt|killall|single) ;;
- syslog) ;;
- *)
- $_VSERVER ----insecure "$1" chkconfig "$i" off
- ;;
- esac
- done
-
- relink /bin/true halt
-popd >/dev/null
-
-pushd "$vdir"/sbin &>/dev/null
- relink /bin/true new-kernel-pkg
-popd >/dev/null
-
-pushd "$vdir"/usr/bin &>/dev/null
- relink /bin/true rhgb-client
-popd >/dev/null
-
-pushd "$vdir"/etc &>/dev/null
- # TODO: remove race/symlink-attack
- echo 'NETWORKING=yes' >>sysconfig/network
-popd >/dev/null
-
-pushd "$vdir" &>/dev/null
- : | $_CHROOT_CAT /etc/sysctl.conf
- echo "none / none defaults" | $_CHROOT_CAT /etc/fstab
- cat "$__DISTRIBDIR"/redhat/rc.sysinit | $_CHROOT_CAT /etc/rc.d/rc.sysinit.vserver
- # TODO: remove race/symlink-attack
- chmod +x etc/rc.d/rc.sysinit.vserver
- subst etc/inittab 's!^\([^#].*:respawn:.* tty\)!#\1!;
- s!si::sysinit:/etc/rc.d/rc.sysinit!si::sysinit:/etc/rc.d/rc.sysinit.vserver!'
-popd >/dev/null
+++ /dev/null
-#! /bin/bash
-
-# 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.
-
-vdir=$1/vdir
-. "$2"
-
-## Fix/workaround the misclassification of %_netsharedpath's parent directories
-mkdir -p "$vdir"/{etc/rc.d/init.d,/sbin,/usr/bin,/usr/X11}
+++ /dev/null
-#! /bin/sh
-
-rm -f /var/lock/subsys/* /var/run/* /var/run/*/* 2>/dev/null
-true
+++ /dev/null
-Essential:
- basesystem
- coreutils
- filesystem
- glibc
- setup
+++ /dev/null
-# rpm http://ftp.ultra.csn.tu-chemnitz.de/pub/mirror/RedHat/.apt redhat/9 os errata
-# rpm-src http://ftp.ultra.csn.tu-chemnitz.de/pub/mirror/RedHat/.apt redhat/9 os errata
-
-# rpm ftp://ftp.tu-chemnitz.de/pub/linux/fedora/redhat 9/i386 os updates
-# rpm ftp://ftp.ussg.iu.edu/pub/linux/fedora/fedora/redhat 9/i386 os updates
-# rpm http://mirrors.usc.edu/pub/linux/fedora/redhat 9/i386 os updates
-# rpm http://sunsite.informatik.rwth-aachen.de/ftp/pub/Linux/fedora/redhat 9/i386 os updates
+++ /dev/null
---reinstall
-
-filesystem
+++ /dev/null
-Essential:
- aaa_base
+++ /dev/null
-# rpm http://ftp.tu-chemnitz.de/pub/linux/suse/apt/SuSE 9.1-i386 base
+++ /dev/null
-#! /bin/sh
-
-vdir=$1/vdir
-. "$2"
+++ /dev/null
---reinstall
-filesystem
-pam
+++ /dev/null
-# Because of https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=52725
-# you have to use at least one language beside 'C'
-%_install_langs C:de:en:es:fr
-%_netsharedpath /dev
+++ /dev/null
-#! /bin/bash
-
-# Copyright (C) 2005 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.
-
-## Called as: initpost <cfgdir> <path of util-vserver-vars>
-
-. "$2"
-
-true
+++ /dev/null
-#! /bin/bash
-
-# Copyright (C) 2005 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.
-
-## Called as: initpre <cfgdir> <path of util-vserver-vars>
-
-. "$2"
-
-true
+++ /dev/null
-compatibility.html
-configuration.html
+++ /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; either version 2, or (at your option)
-## any later version.
-##
-## 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.
-##
-
-doc_old_doc = doc/intro.txt
-
-XSLT_AMFLAGS = --stringparam confdir '$(sysconfdir)/vservers'
-XSLTP_AMFLAGS = -param confdir '$(sysconfdir)/vservers'
-
-doc_gen_DOCS = doc/configuration.html \
- doc/compatibility.html
-
-doc_configuration_SRCS = doc/configuration.xml \
- doc/configuration.xsd \
- doc/configuration.dtd \
- doc/configuration.css \
- doc/configuration-xhtml.xsl
-
-doc_compatibility_SRCS = doc/compatibility.xml \
- doc/compatibility.dtd \
- doc/compatibility-xhtml.xsl
-
-EXTRA_DIST += $(doc_compatibility_SRCS) \
- $(doc_configuration_SRCS) \
- $(doc_old_doc) \
- $(doc_gen_DOCS)
-
-CLEANFILES += doc/*.raw.html* doc/*.html.tmp
-
-doc/configuration.html: STYLESHEET=$(srcdir)/doc/configuration-xhtml.xsl
-doc/configuration.html: $(srcdir)/doc/configuration-xhtml.xsl
-
-doc/compatibility.html: STYLESHEET=$(srcdir)/doc/compatibility-xhtml.xsl
-doc/compatibility.html: $(srcdir)/doc/compatibility-xhtml.xsl
-
-doc: doc_doc
-doc_doc: $(doc_gen_DOCS)
-
-if HAVE_XSLTP
-CLEANFILES += $(doc_gen_DOCS)
-%.html: %.xml $(STYLESHEET)
- @-rm -f '$@.tmp' '$@'
- LANG=C $(XSLTP) $(XSLTP_AMFLAGS) -in '$<' -xsl $(STYLESHEET) -out '$@.tmp'
- @mv -f '$@.tmp' '$@'
-else !HAVE_XSLTP
-if HAVE_XSLTPROC
-CLEANFILES += $(doc_gen_DOCS)
-%.html: %.xml $(STYLESHEET)
- @-rm -f '$@.tmp' '$@'
- $(XSLTPROC) $(XSLT_FLAGS) $(XSLT_AMFLAGS) -o '$@.tmp' "$(STYLESHEET)" "$<"
- @mv -f '$@.tmp' '$@'
-endif HAVE_XSLTPROC
-endif !HAVE_XSLTP
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns="http://www.w3.org/1999/xhtml"
- version="1.0">
-
- <xsl:output method="xml"
- indent="yes"
- doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
- doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
-
- <xsl:template match="/">
- <html>
- <head>
- <title><xsl:apply-templates select="compatibility/title"/></title>
- <link rel="stylesheet" type="text/css" href="compatibility.css" />
- </head>
- <body>
- <h1><xsl:apply-templates select="compatibility/title"/></h1>
- <xsl:apply-templates select="compatibility/program">
- <xsl:sort select="compatibility/program/location"/>
- <xsl:sort select="compatibility/program[name]"/>
- </xsl:apply-templates>
- </body>
- </html>
- </xsl:template>
-
- <xsl:template name="compat">
- <xsl:variable name="name" select="name()"/>
- <xsl:variable name="descr">
- <xsl:choose>
- <xsl:when test="$name = 'clicompat'">
- <xsl:text>Command line interface compatibility</xsl:text>
- </xsl:when>
- <xsl:when test="$name = 'funccompat'">
- <xsl:text>Functional compatibility</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$name"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <div class="{$name}">
- <xsl:value-of select="$descr"/>: <xsl:value-of select="@status"/>
- <xsl:if test="text">
- <div class="text">
- <xsl:apply-templates select="text"/>
- </div>
- </xsl:if>
- </div>
- </xsl:template>
-
- <xsl:template match="clicompat|funccompat">
- <xsl:call-template name="compat" />
- </xsl:template>
-
- <xsl:template match="program">
- <div class="program">
- <div class="name">
- <xsl:value-of select="location"/>/<xsl:value-of select="@name"/>
- <xsl:if test="@status">
- <xsl:text> (</xsl:text>
- <xsl:value-of select="@status"/>
- <xsl:text>)</xsl:text>
- </xsl:if>
- </div>
- <xsl:apply-templates select="clicompat|funccompat"/>
- </div>
- </xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-div.program
-{
- margin: 0.5ex;
- padding: 0.5ex;
-}
-
-div.program div.name
-{
- font-weight: bold;
-}
-
-div.program div.name,
-div.program div.clicompat,
-div.program div.funccompat
-{
-}
-
-div.program div.clicompat,
-div.program div.funccompat
-{
- margin-left: 1em;
-}
-
-div.clicompat div.text,
-div.funccompat div.text
-{
- margin-left: 1em;
-}
+++ /dev/null
-<!ELEMENT compatibility (title,program*)>
-
-<!ELEMENT program (location,clicompat?,funccompat?)>
-<!ATTLIST program
- name CDATA #REQUIRED
- status (removed|rewritten|renamed|broken|new) #IMPLIED>
-
-<!ELEMENT location (#PCDATA)>
-
-<!ELEMENT clicompat (text?)>
-<!ATTLIST clicompat
- status (yes|no|limited) #REQUIRED>
-
-<!ELEMENT funccompat (text?)>
-<!ATTLIST funccompat
- status (yes|no|limited) #REQUIRED>
-
-<!ELEMENT text ANY>
-<!ELEMENT pref (#PCDATA)>
-
-<!ELEMENT title (#PCDATA)>
+++ /dev/null
-<?xml version="1.0"?>
-<!DOCTYPE compatibility SYSTEM "compatibility.dtd" []>
-
-<compatibility>
- <title>compatibility of util-vserver alpha branch</title>
-
- <program name="capchroot">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="distrib-info" status="removed">
- <location>LIBDIR</location>
- <clicompat status="no">
- <text>replaced by <pref>vpkg</pref></text>
- </clicompat>
- <funccompat status="no"/>
- </program>
-
- <program name="fakerunlevel">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="filetime">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="ifspec">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="install-*" status="removed">
- <location>LIBDIR</location>
- <clicompat status="no">
- <text>Replaced by more general build-methods which are building vservers from apt-repositories.</text>
- </clicompat>
- <funccompat status="no"/>
- </program>
-
- <program name="listdevip">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="parserpmdump">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="readlink">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="rootshell">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="sample.sh" status="removed">
- <location>LIBDIR</location>
- <clicompat status="no">
- <text>incompatible with recent configuration style.</text>
- </clicompat>
- <funccompat status="no"/>
- </program>
-
- <program name="save_s_context" status="removed">
- <location>LIBDIR</location>
- <clicompat status="no">
- <text>incompatible with recent configuration style; partially replaced by <pref>save_ctxinfo</pref>.</text>
- </clicompat>
- <funccompat status="yes"/>
- </program>
-
- <program name="setattr">
- <location>LIBDIR</location>
- <clicompat status="no">
- <text>Has been moved into SBINDIR. Lots of new option were added to support new functionality.</text>
- </clicompat>
- <funccompat status="no">
- <text>It is possible to recurse directories and it supports
- all vserver related attributes (admin, hide, watch, barrier,
- iunlink).</text>
- </funccompat>
- </program>
-
- <program name="showattr">
- <location>LIBDIR</location>
- <clicompat status="no">
- <text>Has been moved into SBINDIR. Lots of new option were added to support new functionality.</text>
- </clicompat>
- <funccompat status="no">
- <text>It is possible to recurse directories and it supports all
- vserver related attributes (admin, hide, watch, barrier,
- iunlink). The output has been changed: the flags are now in the
- first column and they are displayed in a symbolic manner.</text>
- </funccompat>
- </program>
-
- <program name="showperm">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="vbuild" status="broken">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="no">
- <text>will be removed/rewritten soon.</text>
- </funccompat>
- </program>
-
- <program name="vcheck" status="broken">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="no">
- <text>will be removed/rewritten soon.</text>
- </funccompat>
- </program>
-
- <program name="vprofile" status="removed">
- <location>LIBDIR</location>
- <clicompat status="no">
- <text>incompatible with recent configuration style.</text>
- </clicompat>
- <funccompat status="no"/>
- </program>
-
- <program name="vreboot">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="vserverkillall" status="removed">
- <location>LIBDIR</location>
- <clicompat status="no">
- <text><pref>vkill</pref> contains the needed functionality
- already.</text>
- </clicompat>
- <funccompat status="no"/>
- </program>
-
- <program name="vservers.grabinfo.sh">
- <location>LIBDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="vunify" status="rewritten">
- <location>LIBDIR</location>
- <clicompat status="no">
- <text>CLI has been changed to reflect new functionality. Now, it
- accepts either a single vserver, or (directory,excludelist)
- pairs as arguments. The old "refserver vserver1 vserver2 ..."
- syntax is gone.</text>
- </clicompat>
- <funccompat status="limited">
- <text>vunify allows to unify generic paths, or vservers with
- preconfigured reference vservers. The filelist is not taken from
- packagemanagement anymore, but every file which has a counterpart
- in the reference-path(s)/vserver(s) and is not in an excludelist
- will be unified. A part of the excludelist will be generated
- dynamically with information from the packagemanagement about
- configfiles.</text>
- </funccompat>
- </program>
-
- <program name="chbind">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="chcontext">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes">
- <text>Return code in '--disconnect' case is now more correctly.</text>
- </funccompat>
- </program>
-
- <program name="rebootmgr">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="reducecap">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="vdu">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="vfiles" status="broken">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="no">
- <text>will be removed/rewritten soon.</text>
- </funccompat>
- </program>
-
- <program name="vkill" status="rewritten">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="limited">
- <text>It uses native kernel interface now and is secure (in
- opposite to the old perl implementation).</text>
- </funccompat>
- </program>
-
- <program name="vps" status="rewritten">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="limited">
- <text>It has been rewritten into C and output might have been changed slightly.</text>
- </funccompat>
- </program>
-
- <program name="vpstree">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="vrpm" status="rewritten">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="limited">
- <text>It has been rewritten into a secure, native C
- implementation. Unpacking of files happens in host-ctx, but
- scriptlets are executed in vserver context. The rpm database
- will/can be hold outside of the vserver and there will never be
- access on it from the inside (neither direct, nor by
- scriptlets). This is implemented through an LD_PRELOAD wrapper
- which provides own, secure NSS functions too.</text>
- </funccompat>
- </program>
-
- <program name="vserver" status="rewritten">
- <location>SBINDIR</location>
- <clicompat status="limited">
- <text>It accepts all the old arguments, but adds lots of new
- ones. This program is intended as the basic vserver management
- tool; e.g. to unify a vserver you can execute "vserver XX unify",
- to install a package "vserver XX install PKG" and so on.</text>
- </clicompat>
- <funccompat status="limited">
- <text>This tool is rewritten to completely and is now resistant
- against symlink attacks. It uses the new configuration scheme
- and the iproute2 tools instead of ifconfig for network
- setup. Old-style vserver can be still started through this tool,
- but modifications/building of them is not possible
- anymore.</text>
- </funccompat>
- </program>
-
- <program name="vserver-copy" status="broken">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="no">
- <text>will be removed/rewritten soon.</text>
- </funccompat>
- </program>
-
- <program name="vserver-stat" status="rewritten">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes">
- <text>It has been rewritten to use the new libvserver API. The
- output has been changed slightly.</text>
- </funccompat>
- </program>
-
- <program name="vtop">
- <location>SBINDIR</location>
- <clicompat status="yes"/>
- <funccompat status="yes"/>
- </program>
-
- <program name="exec-cd" status="new">
- <location>SBINDIR</location>
- <funccompat status="yes">
- <text>changes into a directory in a secure manner and executes a
- program there.</text>
- </funccompat>
- </program>
-
- <program name="rpm-fake-resolver" status="new">
- <location>LIBDIR</location>
- <funccompat status="yes">
- <text>NSS resolver; used by <pref>vrpm</pref> and executed in
- vserver-ctx.</text>
- </funccompat>
- </program>
-
- <program name="rpm-fake.so" status="new">
- <location>LIBDIR</location>
- <funccompat status="yes">
- <text>LD_PRELOAD wrapper; used by <pref>vrpm</pref>.</text>
- </funccompat>
- </program>
-
- <program name="vapt-get-worker" status="new">
- <location>LIBDIR</location>
- <funccompat status="yes">
- <text>Helper script for <pref>vapt-get</pref>.</text>
- </funccompat>
- </program>
-
- <program name="vpkg" status="new">
- <location>LIBDIR</location>
- <funccompat status="yes">
- <text>Generic interface for package management; it allows
- to install, remove or query packages in a distribution
- independent manner. It can be seen as the successor of
- <pref>distrib-info</pref>.</text>
- </funccompat>
- </program>
-
- <program name="vrpm-preload" status="new">
- <location>LIBDIR</location>
- <funccompat status="yes">
- <text>Helper script for <pref>vrpm</pref>.</text>
- </funccompat>
- </program>
-
- <program name="vrpm-worker" status="new">
- <location>LIBDIR</location>
- <funccompat status="yes">
- <text>Helper script for <pref>vrpm</pref>.</text>
- </funccompat>
- </program>
-
- <program name="vserver-build" status="new">
- <location>LIBDIR</location>
- <funccompat status="yes">
- <text>Builds a vserver from scratch and allows to select the
- used method. It will be called by the "vserver XY build"
- command.</text>
- </funccompat>
- </program>
-
- <program name="vapt-get" status="new">
- <location>SBINDIR</location>
- <funccompat status="yes">
- <text>Wrapper for apt-get; currently only the apt-rpm port
- is supported. Metadata will/can be stored outside of the
- vserver. This program call <pref>vrpm</pref>.</text>
- </funccompat>
- </program>
-
-
- <program name="chxid" status="new">
- <location>SBINDIR</location>
- <funccompat status="yes">
- <text>This program assigns the associated context of an inode. It
- replaces parts of the vserver-quota tools.</text>
- </funccompat>
- </program>
-
- <program name="lsxid" status="new">
- <location>SBINDIR</location>
- <funccompat status="yes">
- <text>This program shows the associated context of an inode. It
- replaces parts of the vserver-quota tools.</text>
- </funccompat>
- </program>
-
- <program name="new-namespace" status="new">
- <location>SBINDIR</location>
- <funccompat status="yes">
- <text>This program starts a program within a new namespace which is
- created with CLONE_NEWNS. It is used e.g. by <pref>vrpm</pref> to
- map the rpm-database into the vserver in a secure manner.</text>
- </funccompat>
- </program>
-
- <program name="vlimit" status="new">
- <location>SBINDIR</location>
- <funccompat status="yes">
- <text>This is an interface to the rlimit syscalls which allow to
- limit resource-usage of contexts.</text>
- </funccompat>
- </program>
-
- <program name="vrsetup" status="new">
- <location>SBINDIR</location>
- <funccompat status="yes">
- <text>This program allows to setup vroot devices. It replaces
- vrsetup from the vr-tools</text>
- </funccompat>
- </program>
-</compatibility>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns="http://www.w3.org/1999/xhtml"
- version="1.0">
-
- <xsl:output method="xml"
- indent="yes"
- doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
- doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
-
- <xsl:param name="confdir"/>
-
- <xsl:template match="/">
- <html>
- <xsl:apply-templates/>
- </html>
- </xsl:template>
-
- <xsl:template match="database">
- <head>
- <title>The <xsl:value-of select="$confdir"/> directory</title>
- <link rel="stylesheet" title="gras" type="text/css" href="css/configuration-lsd.css"></link>
- <link rel="alternate stylesheet" title="gras1" type="text/css" href="css/configuration-lsd1.css"></link>
- <link rel="alternate stylesheet" title="flower" type="text/css" href="css/configuration-flower.css"></link>
- <link rel="alternate stylesheet" title="boring" type="text/css" href="configuration.css"></link>
- </head>
- <body>
- <h1>The content of the <xsl:value-of select="$confdir"/> directory</h1>
-
- <xsl:call-template name="collection">
- <xsl:with-param name="thisdir"><xsl:value-of select="$confdir"/></xsl:with-param>
- </xsl:call-template>
- </body>
- </xsl:template>
-
- <xsl:template name="collection">
- <xsl:param name="thisdir"/>
- <xsl:if test="count(scalar) + count(link) + count(program) + count(data) + count(hash) + count(list) + count(boolean) + count(collection)>0">
- <ul>
- <xsl:call-template name="dir-iterate">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- </xsl:call-template>
- </ul>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="dir-iterate">
- <xsl:param name="thisdir"/>
- <xsl:apply-templates select="scalar|link|program|data|hash|list|boolean">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:sort select="@name"/>
- </xsl:apply-templates>
-
- <xsl:apply-templates select="collection">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:sort select="@name"/>
- </xsl:apply-templates>
- </xsl:template>
-
- <xsl:template match="program">
- <xsl:param name="thisdir"/>
- <li>
- <xsl:call-template name="printname">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:with-param name="style">script</xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="printcontent"/>
- </li>
- </xsl:template>
-
- <xsl:template match="hash">
- <xsl:param name="thisdir"/>
- <li>
- <xsl:call-template name="printname">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:with-param name="style">hash</xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="printcontent"/>
- </li>
- </xsl:template>
-
- <xsl:template match="scalar">
- <xsl:param name="thisdir"/>
- <li>
- <xsl:call-template name="printname">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:with-param name="style">file</xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="printcontent"/>
- </li>
- </xsl:template>
-
- <xsl:template match="data">
- <xsl:param name="thisdir"/>
- <li>
- <xsl:call-template name="printname">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:with-param name="style">data</xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="printcontent"/>
- </li>
- </xsl:template>
-
- <xsl:template match="list">
- <xsl:param name="thisdir"/>
- <li>
- <xsl:call-template name="printname">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:with-param name="style">list</xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="printcontent"/>
- </li>
- </xsl:template>
-
- <xsl:template match="link">
- <xsl:param name="thisdir"/>
- <li>
- <xsl:call-template name="printname">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:with-param name="style">symlink</xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="printcontent"/>
- </li>
- </xsl:template>
-
- <xsl:template match="boolean">
- <xsl:param name="thisdir"/>
- <li>
- <xsl:call-template name="printname">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:with-param name="style">boolean</xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="printcontent"/>
- </li>
- </xsl:template>
-
- <xsl:template match="collection">
- <xsl:param name="thisdir"/>
- <li>
- <xsl:call-template name="printfullname">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/></xsl:with-param>
- <xsl:with-param name="style">directory</xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="printcontent"/>
-
- <xsl:call-template name="collection">
- <xsl:with-param name="thisdir"><xsl:value-of select="$thisdir"/>/<xsl:value-of select="@name"/></xsl:with-param>
- </xsl:call-template>
- </li>
- </xsl:template>
-
- <xsl:template match="collection" mode="printrpath">
- <xsl:text>/</xsl:text>
- <span class="{@type}">
- <xsl:value-of select="@name"/>
- </span>
- </xsl:template>
-
- <xsl:template match="elements">
- <div class="elements">
- <dl>
- <xsl:apply-templates select="element">
- <xsl:sort select="@name"/>
- </xsl:apply-templates>
- </dl>
- </div>
- </xsl:template>
-
- <xsl:template match="elements/element">
- <dt class="elements"><xsl:value-of select="@name"/></dt>
- <dd class="elements"><xsl:apply-templates select="description"/></dd>
- </xsl:template>
-
- <xsl:template name="printfullname">
- <xsl:param name="thisdir"/>
- <xsl:param name="style"/>
- <span class="{$style}">
- <xsl:value-of select="$confdir"/>
- <xsl:apply-templates select="ancestor-or-self::collection" mode="printrpath"/>
- </span>
- </xsl:template>
-
- <xsl:template name="printname">
- <xsl:param name="thisdir"/>
- <xsl:param name="style"/>
- <span class="{$style}" title="{$thisdir}/{@name}">
- <xsl:value-of select="@name"/>
- </span>
- </xsl:template>
-
- <xsl:template name="printcontent">
- <br/>
- <xsl:apply-templates select="description"/>
- <xsl:apply-templates select="elements"/>
- </xsl:template>
-
- <xsl:template match="description">
- <div class="description">
- <xsl:apply-templates/>
- </div>
- </xsl:template>
-
- <xsl:template match="ulink">
- <a href="{@url}"><xsl:apply-templates/></a>
- </xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-body {
- font-size: 12pt;
- background-color: white;
- margin: 10px;
-}
-
-span.directory {
- //text-decoration: underline;
-}
-
-
-span.symlink:after {
- content: " [symlink]";
- font-size: 8pt;
- font-style: normal;
-}
-
-span.symlink {
- text-decoration: none;
- font-style: italic;
-}
-
-span.script:after {
- content: " [script]";
- font-size: 8pt;
- font-style: normal;
-}
-
-span.script {
- color: gray;
-}
-
-span.symbolic:before { content: "<"; }
-span.symbolic:after { content: ">"; }
-
-span.symbolic {
- font-style: italic;
- text-decoration: none;
-}
-
-div.description {
- background-color: #ffffdd;
-}
-
-
-div.elements {
- padding-left: 1em;
-}
-
-dd.elements {
-}
-
-dt.elements {
-}
+++ /dev/null
-<!ELEMENT database (collection*)>
-
-<!ELEMENT collection (collection?,data?,link?,scalar?,program?,boolean?,list?,description?,hash?)*>
-<!ATTLIST collection
- name CDATA #REQUIRED
- type CDATA #IMPLIED
- use CDATA #IMPLIED
- since CDATA #IMPLIED>
-
-<!ELEMENT data (description?)>
-<!ATTLIST data
- name CDATA #REQUIRED>
-
-
-<!ELEMENT link (default?,description?)>
-<!ATTLIST link
- name CDATA #REQUIRED
- type CDATA #IMPLIED
- since CDATA #IMPLIED>
-<!ELEMENT default (#PCDATA)>
-
-
-<!ELEMENT scalar (default?,description?,restriction?)>
-<!ATTLIST scalar
- name CDATA #REQUIRED
- type CDATA #IMPLIED
- since CDATA #IMPLIED>
-
-
-<!ELEMENT description ANY>
-
-<!ELEMENT program (description?,parameterList?)>
-<!ATTLIST program
- name CDATA #REQUIRED
- type CDATA #IMPLIED
- since CDATA #IMPLIED>
-
-<!ELEMENT boolean (description?)>
-<!ATTLIST boolean
- name CDATA #REQUIRED
- default (on|off) #IMPLIED
- since CDATA #IMPLIED>
-
-<!ELEMENT list (description?,elements?)>
-<!ATTLIST list
- name CDATA #REQUIRED
- since CDATA #IMPLIED>
-
-
-<!ELEMENT parameterList (parameter*)>
-<!ELEMENT parameter (description?)>
-<!ATTLIST parameter
- name CDATA #REQUIRED
- since CDATA #IMPLIED>
-
-
-<!ELEMENT ulink (#PCDATA)>
-<!ATTLIST ulink
- url CDATA #REQUIRED
- since CDATA #IMPLIED>
-
-<!ELEMENT hash (description?,keys*)>
-<!ATTLIST hash
- name CDATA #REQUIRED
- since CDATA #IMPLIED>
-
-<!ELEMENT keys (key*)>
-<!ELEMENT key (description?)>
-<!ATTLIST key
- name CDATA #REQUIRED
- since CDATA #IMPLIED>
-
-
-<!ELEMENT elements (element*)>
-<!ELEMENT element (description?)>
-<!ATTLIST element
- name CDATA #REQUIRED
- since CDATA #IMPLIED>
-
-<!ELEMENT restriction (enumeration*)>
-<!ELEMENT enumeration EMPTY>
-<!ATTLIST enumeration
- value CDATA #REQUIRED
- since CDATA #IMPLIED>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE database SYSTEM "configuration.dtd" []>
-<!-- $Id$ -->
-
-<database xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="file:configuration.xsd">
-
- <!-- Global configuration -->
- <collection name=".defaults" use="optional">
- <collection name="init" type="fixed">
- <data name="mtab">
- <description>Default mtab file</description>
- </data>
- </collection>
-
- <link name="vdirbase">
- <default>/vservers</default>
- <description>A link to the default vserver rootdirectory.</description>
- </link>
-
-
- <boolean name="nonamespace">
- <description>
-Disable namespace usage globally. It can be overridden for a single
-vserver by setting the 'namespace' flag there.
-
-In this mode the /vservers directory must have the 'barrier'
-attribute. Else, common chroot(2) exploits are possible.
- </description>
- </boolean>
-
- <link name="run.rev">
- <description>
-Path of the vserver run reverse directory. This directory contains
-symlinks named with XID numbers which point back to the configuration
-directory of vservers. Under kernel 2.4 this is required for the XID
-to VSERVER mapping; Under kernel 2.6 it is unused.
-
-NOTE: this link exists in 0.30.202+ only; in previous versions it was
-a vserver specific setting.
- </description>
- </link>
-
- <collection name="apps">
- <collection name="pkgmgmt">
- <link name="base">
- <default>/vservers/.pkg</default>
- </link>
- <data name="apt.conf">
- <description>The default apt.conf which is going to be used. It is overridden by
-distribution specific configuration file.
- </description>
- </data>
- </collection>
-
- <collection name="debootstrap">
- <scalar name="mirror">
- <description>
-The Debian mirror to use with the 'debootstrap' program
- </description>
- </scalar>
- <scalar name="uri">
- <description>
-When the 'debootstrap' package is not installed; fetch it from this
-uri and install it at a temporary place.
- </description>
- </scalar>
- </collection>
-
- <collection name="vshelper">
- <link name="logfile">
- <description>
-The file where output will be logged to when 'vshelper' is invoked
-from the kernel. This should point somewhere e.g. into /var/log.
- </description>
- </link>
-
- <collection name="vshelper-methods">
- <program name="handler" type="symbolic">
- <description>
-See vshelper/action.
- </description>
- </program>
- </collection>
-
- <boolean name="disabled">
- <description>
-When existing, the vshelper functionality will be disabled for all
-vservers.
- </description>
- </boolean>
-
- <boolean name="debug">
- <description>
-When existing, the vshelper execution will be traced.
- </description>
- </boolean>
-
- <boolean name="warning-disabled">
- <description>
-When existing, sanity checks for the vshelper functionality will be
-skipped.
- </description>
- </boolean>
-
- </collection>
-
- <collection name="vprocunhide">
- <list name="files">
- <description>
-A list of files which will be made visibly by vprocunhide. Wildcards are
-allowed and anything ending in '/' will be processed recursively. When this file exists,
-it overrides the defaults in SYSDEFAULTDIR/vprocunhide-files. The entries there must be
-absolute filenames inclusive the leading '/proc'.
- </description>
- </list>
- </collection>
-
- <collection name="init">
- <link name="tty">
- <description>
-A symlink to the TTY device where input/output will be redirected from/to
-at startup via initscript.
- </description>
- </link>
- </collection>
-
- <collection name="vunify">
- <list name="exclude">
- <description>Static list of excluded files.</description>
- </list>
-
- <collection name="hash" since="0.30.205">
- <description>
-A directory which will be used as the storage place for the 'vhashify'
-command.
- </description>
- <link name="id" type="symbolic">
- <description>
-Points to a directory within the filesystems which are used for the
-vservers. There must be not more than one of such a directory per
-filesystem.
- </description>
- </link>
-
- <scalar name="method" since="0.30.299">
- <default>SHA1</default>
- <description>The used hash method.</description>
- </scalar>
- </collection>
-
- <boolean name="pkgmgmt-ignore" default="off" since="0.30.205">
- <description>
-When existing, information from packagemanagement will not be used to
-create dynamic exclude-lists.
- </description>
- </boolean>
-
- <boolean name="pgkmgmt-force" default="off" since="0.30.205">
- <description>
-When existing, information from packagemanagement will be used to
-create dynamic exclude-lists. This option requires that (a known)
-packagemanagement is configured for the vserver; else the requested
-operation will fail. Most tools assume 'on' as the default value.
- </description>
- </boolean>
-
- </collection>
- </collection>
- </collection>
-
- <collection name=".distributions" use="optional">
- <collection name="dist" type="symbolic">
- <scalar name="dev">
- <description></description>
- </scalar>
- <collection name="yum">
- <description>
-The default, yum-related content of the /etc directory.
- </description>
- <scalar name="yum.conf">
- <description>
-The master yum configuration file. It supports the @YUMETCDIR@,
-@YUMCACHEDIR@ and @YUMLOGDIR@ placeholder which will be replaced at
-'vserver ... build' time.
- </description>
- </scalar>
- </collection>
- <collection name="yum.repos.d">
- <description>A directory with yum repositories.</description>
- </collection>
- <data name="apt.conf">
- <description>
-The default apt.conf which is going to be used. It overrides the
-apt.conf from CONFDIR/.defaults/apps/pkgmgmt.
- </description>
- </data>
- <program name="initpre">
- <description>
-Script which will be executed before packages will be installed.
- </description>
- <parameterList>
- <parameter name="confdir">
- <description>
-The configuration directory of the vserver which is going to be set up.
- </description>
- </parameter>
- <parameter name="vserver">
- <description>
-The pathname of the vserver binary.
- </description>
- </parameter>
- </parameterList>
- </program>
- <program name="initpost">
- <description>
-Script which will be executed after packages are installed.
- </description>
- <parameterList>
- <parameter name="confdir">
- <description>
-The configuration directory of the vserver which is going to be set up.
- </description>
- </parameter>
- <parameter name="vserver">
- <description>
-The pathname of the vserver binary.
- </description>
- </parameter>
- </parameterList>
- </program>
-
- <collection name="pkgs">
- <description>
-Contains files with packages.
- </description>
- <list name="list">
- <description>
-File which contains the name of packages. On top of file the special
-keywords '--reinstall' and '--can-fail' are possible.
- </description>
- </list>
- </collection>
-
- <collection name="pubkeys">
- <description>
-Directory with GPG pubkeys which are used to sign the packages of this
-distribution.
- </description>
- </collection>
-
- <collection name="apt">
- <description>
-Default content of the /etc/apt/ directory.
- </description>
- </collection>
-
- <collection name="rpm">
- <description>
-Default content of the /etc/rpm directory.
- </description>
- </collection>
-
- <link name="rpmlib">
- <description>
-Directory which overrides /usr/lib/rpm.
- </description>
- </link>
- <link name="execdir">
- <description>
-Directory with all executables and libraries which are required for
-this distribution.
- </description>
- </link>
- </collection>
- </collection>
-
- <!-- Vserver configuration -->
- <collection name="vserver-name" type="symbolic">
- <description>
-The configuration directory for the vserver vserver-name.
- </description>
-
- <link name="vdir">
- <description>
-Path of the vserver root directory
- </description>
- </link>
-
- <link name="run">
- <description>
-Points to a file which will contain the XID of the running vserver. When
-the vserver is stopped, this can be a dangling symlink.
- </description>
- </link>
-
- <list name="bcapabilities">
- <description>
-[experimental; name is subject of possible change] Contains the system capabilities. See
-<ulink url="http://savannah.nongnu.org/cgi-bin/viewcvs/util-vserver/util-vserver/lib/bcaps-v13.c?rev=HEAD">lib/bcaps-v13.c</ulink>
-for possible values.
- </description>
- </list>
- <list name="ccapabilities">
- <description>
-[experimental; name is subject of possible change] Contains the
-context capabilities. See <ulink
-url="http://savannah.nongnu.org/cgi-bin/viewcvs/util-vserver/util-vserver/lib/ccaps-v13.c?rev=HEAD">lib/ccaps-v13.c</ulink>
-for possible values.
- </description>
- </list>
-
- <boolean name="namespace">
- <description>
-Overrides the global 'nonamespace' flag and enables namespace usage
-for the current vserver.
- </description>
- </boolean>
-
- <boolean name="nonamespace">
- <description>
-Disables namespace usage for the current vserver.
-
-In this mode the /vservers directory must have the 'barrier'
-attribute. Else, common chroot(2) exploits are possible.
- </description>
- </boolean>
-
- <hash name="schedule">
- <description>
-[experimental; name is subject of possible change] Contains the
-scheduler parameters, one per line.
-
-The Hard CPU limit uses a mechanism called a Token Bucket. the
-concept is simple: you have a bucket of a certain size which is
-filled with a specified amount R of tokens each interval T until the
-maximum is reached (excess tokens are spilled). At each timer tick,
-a running process consumes one token from the bucket, unless the
-bucket is empty. If the bucket is empty the process is put in the
-hold queue. When the bucket has been refilled to at least M tokens,
-all on hold processes are rescheduled.
- </description>
- <keys>
- <key name="fill-rate">
- <description>
-Amount of tokens append to the bucket each interval.
- </description>
- </key>
- <key name="interval">
- <description>
-The intervall between refills of amount 'fill_rate'. This value is
-express in ticks.
- </description>
- </key>
- <key name="tokens">
- <description>
-Initial bucket contents.
- </description>
- </key>
- <key name="tokens-min">
- <description>
-The minimum amount of tokens required to unhold processes
- </description>
- </key>
- <key name="tokens-max">
- <description>
-The bucket size.
- </description>
- </key>
- <key name="priority-bias">
- <description>
-???
- </description>
- </key>
- </keys>
- </hash>
- <scalar name="name">
- <description>
-Contains the name of the vserver. When not given, the basename of the directory
-will be assumed as this name.
- </description>
- </scalar>
- <scalar name="nice">
- <description>
-The nice-level on which the vserver will be started.
- </description>
- </scalar>
- <list name="capabilities">
- <description>
-Contains per line a capability. This file is used for the 2.4 kernel
-only; for 2.6 use 'bcapabilities'.
- </description>
- </list>
- <scalar name="shell">
- <description>
-Contains the pathname of the shell which will be used by the "vserver
-... enter" command.
- </description>
- </scalar>
- <list name="flags">
- <description>
-Contains per line a flag. See <ulink
-url="http://savannah.nongnu.org/cgi-bin/viewcvs/util-vserver/util-vserver/lib/cflags-v13.c?rev=HEAD">lib/cflags-v13.c</ulink>
-for possible values.
- </description>
- <elements>
- <element name="fakeinit">
- <description>
-The new process will believe it is process number 1. Useful to run a
-real /sbin/init in a vserver. Warning: this flag should not be used
-unless you know what you are doing. Often, it is better to use the
-'plain' initstyle.
- </description>
- </element>
- <element name="lock">
- <description>
-The new process is trapped and can't use chcontext anymore.
- </description>
- </element>
- <element name="sched">
- <description>
-The new process and its children will share a common
- </description>
- </element>
- <element name="nproc">
- <description>
-Limit the number of process in the vserver according to
-ulimit setting. Normally, ulimit is a per user thing.
-With this flag, it becomes a per vserver thing.
- </description>
- </element>
- <element name="private">
- <description>
-No one can join this security context once created.
- </description>
- </element>
- <element name="ulimit">
- <description>
-Apply the current ulimit to the whole context
- </description>
- </element>
- </elements>
- </list>
- <scalar name="context">
- <description>
-Contains the context which shall be used for the vserver.
- </description>
- </scalar>
- <data name="fstab">
- <description>
-The fstab file for the vserver. Entries in this file will be mounted
-within the network context of the vserver; this means that mount will
-be called as 'chbind <options> mount ...'. Use the 'fstab.local'
-file when you do not want this behavior, but in most cases the 'fstab'
-file should be used.
- </description>
- </data>
- <data name="fstab.local">
- <description>
-The fstab file for the vserver. In opposite to the normal 'fstab'
-file, the mounting happens in the local network context. Currently
-there is no way to mix entries of both files; 'fstab' will be always
-processed before 'fstab.local'.
- </description>
- </data>
-
- <collection name="apps">
- <collection name="init">
- <data name="mtab">
- <description>
-The initial-mtab which will be used for the vserver.
- </description>
- </data>
-
- <scalar name="style">
- <description>
-Contains the init-style.
- </description>
- <restriction>
- <enumeration value="sysv"/>
- <enumeration value="plain"/>
- <enumeration value="minit"/>
- <enumeration value="gento"/>
- </restriction>
- </scalar>
-
- <scalar name="runlevel">
- <description>The start runlevel.</description>
- </scalar>
-
- <scalar name="runlevel.start">
- <description>The start runlevel.</description>
- </scalar>
-
- <scalar name="runlevel.stop">
- <description>The stop runlevel.</description>
- </scalar>
-
- <scalar name="killseq">
- <description>
-Contains the 'signal [wait signal]*' sequence which is used to stop
-the vserver.
- </description>
- </scalar>
-
- <list name="cmd.start">
- <description>
-The command which is used to start the vserver. Each option must be on
-a separate line.
- </description>
- </list>
-
- <list name="cmd.start-sync">
- <description>
-The command which is used to wait on the vserver after it has been
-started. Each option must be on a separate line. This file will be
-ignored when the 'sync' does not exist and the '--sync' option was not
-used.
- </description>
- </list>
-
- <list name="cmd.stop">
- <description>
-The command which is used to stop the vserver. Each option must be on
-a separate line.
- </description>
- </list>
-
- <list name="cmd.stop-sync">
- <description>
-The command which is used to wait on the vserver after it has been
-stopped. Each option must be on a separate line. This file will be
-ignored when the 'sync' does not exist and the '--sync' option was not
-used.
- </description>
- </list>
-
- <list name="cmd.prepare">
- <description>
-The command which is used to setup the init-system (e.g. to set the
-runlevel in the utmp-file). Each option must be on a separate line.
- </description>
- </list>
-
- <boolean name="sync">
- <description>
-If this file is not present, all 'cmd.*-sync files will be ignored.
- </description>
- </boolean>
-
- <link name="tty">
- <description>
-A symlink to the TTY device where input/output will be redirected
-from/to at startup via initscript.
- </description>
- </link>
-
- <scalar name="mark">
- <description>
-This file is used to mark group of vservers which shall be started/stopped
-together by the initscript. Content is a simple string like 'default'.
- </description>
- </scalar>
-
- <list name="depends">
- <description>
-This file is used to configure vservers which must be running before
-the current vserver can be started. At shutdown, the current vserver
-will be stopped before its dependencies. Content of this file are
-vserver ids (one name per line).
- </description>
- </list>
- </collection>
-
- <collection name="vshelper">
- <scalar name="sync-timeout">
- <default>30</default>
- <description>
-The timeout in seconds which is used when synchronising vserver
-startup/shutdown with the vshelper. When no set, 30 seconds will be
-assumed.
- </description>
- </scalar>
-
- <scalar name="action">
- <default>restart</default>
- <description>
-The action which is going to be executed when a vshelper event occurs. The
-default value is 'restart', but there can be defined own methods by placing
-scripts into the 'vshelper-methods' directories. These scripts are fed with
-the same arguments as the 'vshelper' script.
- </description>
- </scalar>
-
- <program name="event" type="symbolic">
- <description>
-When existing. these scripts will be executed *instead* of the default
-handler defined in 'action'. Their name must match the event which
-caused the execution of 'vshelper'; e.g. 'restart' or 'poweroff'. See
-the vs_reboot() function in the kernel for more details.
- </description>
- <parameterList>
- <parameter name="xid">
- <description>
-The xid of the context calling the vshelper
- </description>
- </parameter>
- <parameter name="event">
- <description>
-The reboot-event.
- </description>
- </parameter>
- </parameterList>
- </program>
-
- <boolean name="disabled">
- <description>
-When existing, the vshelper functionality will be disabled for this
-vserver.
- </description>
- </boolean>
-
- <boolean name="debug">
- <description>
-When existing, the vshelper execution will be traced for this vserver.
- </description>
- </boolean>
-
- <boolean name="warning-disabled">
- <description>
-When existing, sanity checks for the vshelper functionality will be
-skipped.
- </description>
- </boolean>
-
- </collection>
-
- <collection name="vshelper-methods">
- <program name="handler" type="symbolic">
- <description>
-See vshelper/action.
- </description>
- </program>
- </collection>
-
- <collection name="vunify">
- <description>
-This directory contains configuration data required for vserver
-unification.
- </description>
-
- <list name="exclude">
- <description>
-Static list of excluded files. This list supports an rsync syntax:
-when a file is prefixed by '+', it is a candidate for unification;
-when there is no prefix or a '-' it will be excluded. Shell-wildcards
-are allowed for the filenames.
- </description>
- </list>
-
- <link name="refserver.X" type="symbolic">
- <description>
-These are symlinks to the configuration directory
-(e.g. CONFDIR/vservers/<id>) of a refserver. There may be
-multiple such symlinks but they must be prefixed by 'refserver.' and
-will be processed in alphanumerical order.
- </description>
- </link>
-
- <collection name="hash" since="0.30.205">
- <description>
-A directory which will be used as the storage place for the 'vhashify'
-command.
- </description>
- <link name="id" type="symbolic">
- <description>
-Points to a directory within the filesystems which are used for the
-vservers. There must be not more than one of such a directory per
-filesystem.
- </description>
- </link>
-
- <scalar name="method" since="0.30.299">
- <default>SHA1</default>
- <description>The used hash method.</description>
- </scalar>
- </collection>
-
- <boolean name="pkgmgmt-ignore" default="off" since="0.30.205">
- <description>
-When existing, information from packagemanagement will not be used to
-create dynamic exclude-lists.
- </description>
- </boolean>
-
- <boolean name="pgkmgmt-force" default="off" since="0.30.205">
- <description>
-When existing, information from packagemanagement will be used to
-create dynamic exclude-lists. This option requires that (a known)
-packagemanagement is configured for the vserver; else the requested
-operation will fail. Most tools assume 'on' as the default value.
- </description>
- </boolean>
-
- </collection>
- </collection>
-
- <collection name="scripts">
- <description>
-A directory for scripts. By default, when one of these scripts will be
-executed, the execution of defaultscripts (within .../.defaults/scripts)
-will be skipped. To execute them nevertheless, the $DONT_SKIP_DEFAULTS
-environment variable must be set by one of the in-shellcontext scripts
-(the non-executable ones).
- </description>
-
- <program name="prepre-start">
- <description>
-The scriptlet which will be executed before the network-interfaces are
-enabled and the directories are mounted."
- </description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>
-The configuration directory of the current vserver.
- </description>
- </parameter>
- <parameter name="vserver-name">
- <description>
-The name of the current vserver.
- </description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- <collection name="prepre-start.d">
- <description>
-Repository of prepre-start like scripts
- </description>
- <program name="script" type="symbolic">
- <description>See prepre-start.</description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>
-The configuration directory of the current vserver.
- </description>
- </parameter>
- <parameter name="vserver-name">
- <description>
-The name of the current vserver.
- </description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- </collection>
-
- <program name="pre-start">
- <description>
-The scriptlet which will be executed after network-interfaces were
-enabled and the directories mounted, but before the vserver itself has
-been started.
- </description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>
-The configuration directory of the current vserver.
- </description>
- </parameter>
- <parameter name="vserver-name">
- <description>
-The name of the current vserver.
- </description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- <collection name="pre-start.d">
- <description>
-Repository of pre-start like scripts
- </description>
- <program name="script" type="symbolic">
- <description>See pre-start.</description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>
-The configuration directory of the current vserver.
- </description>
- </parameter>
- <parameter name="vserver-name">
- <description>The name of the current vserver.</description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- </collection>
-
-
- <program name="post-start">
- <description>
-The scriptlet which will be executed after the vserver has been started.
- </description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>The configuration directory of the current vserver.</description>
- </parameter>
- <parameter name="vserver-name">
- <description>The name of the current vserver.</description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- <collection name="post-start.d">
- <description>Repository of post-start like scripts</description>
- <program name="script" type="symbolic">
- <description>See post-start.</description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>The configuration directory of the current vserver.</description>
- </parameter>
- <parameter name="vserver-name">
- <description>The name of the current vserver.</description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- </collection>
-
-
- <program name="pre-stop">
- <description>
-The scriptlet which will be executed before the vserver will be stopped.
- </description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>The configuration directory of the current vserver.</description>
- </parameter>
- <parameter name="vserver-name">
- <description>The name of the current vserver.</description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- <collection name="pre-stop.d">
- <description>
-Repository of pre-stop like scripts
- </description>
- <program name="script" type="symbolic">
- <description>See pre-stop.</description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>The configuration directory of the current vserver.</description>
- </parameter>
- <parameter name="vserver-name">
- <description>The name of the current vserver.</description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- </collection>
-
- <program name="post-stop">
- <description>
-The scriptlet which will be executed after the vserver has been
-stopped, but before the directories will be umounted and the the
-interfaces disabled.
- </description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>The configuration directory of the current vserver.</description>
- </parameter>
- <parameter name="vserver-name">
- <description>The name of the current vserver.</description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- <collection name="post-stop.d">
- <description>Repository of post-stop like scripts</description>
- <program name="script" type="symbolic">
- <description>See post-stop.</description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>The configuration directory of the current vserver.</description>
- </parameter>
- <parameter name="vserver-name">
- <description>The name of the current vserver.</description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- </collection>
-
- <program name="postpost-stop">
- <description>
-The scriptlet which will be executed after the vserver has been stopped
-completely.
- </description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>The configuration directory of the current vserver.</description>
- </parameter>
- <parameter name="vserver-name">
- <description>The name of the current vserver.</description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- <collection name="postpost-stop.d">
- <description>Repository of postpost-stop like scripts</description>
- <program name="script" type="symbolic">
- <description>See postpost-stop.</description>
- <parameterList>
- <parameter name="vserver-dir">
- <description>The configuration directory of the current vserver.</description>
- </parameter>
- <parameter name="vserver-name">
- <description>The name of the current vserver.</description>
- </parameter>
- <parameter name="action">
- <description>
-The fixed value of the current action (e.g. 'prepre-start', 'post-stop'...).
- </description>
- </parameter>
- </parameterList>
- </program>
- </collection>
- </collection>
-
- <collection name="interfaces">
- <scalar name="bcast">
- <description>The default broadcast address.</description>
- </scalar>
- <scalar name="dev">
- <description>The default network device.</description>
- </scalar>
- <scalar name="prefix">
- <description>The default network prefix-length.</description>
- </scalar>
- <scalar name="mask">
- <description>The default network mask.</description>
- </scalar>
- <scalar name="scope">
- <description>The default scope of the network interfaces.</description>
- </scalar>
-
- <collection name="iface" type="symbolic">
- <description>
-'iface' is an arbitrary name for the interface; the value itself is
-not important but may be interesting regarding interface-creation and
-usage with 'chbind'. Both happens in alphabetical order and numbers
-like '00' are good names for these directories.
- </description>
-
- <boolean name="disabled">
- <description>When this file exists, this interface will be ignored.</description>
- </boolean>
-
- <scalar name="ip">
- <description>The ip which will be assigned to this interface.</description>
- </scalar>
- <scalar name="bcast">
- <description>The broadcast address.</description>
- </scalar>
- <scalar name="dev">
- <description>The network device.</description>
- </scalar>
- <scalar name="prefix">
- <description>The network prefix-length.</description>
- </scalar>
- <scalar name="mask">
- <description>The network mask.</description>
- </scalar>
- <scalar name="scope">
- <description>The scope of the network interface.</description>
- </scalar>
- <scalar name="name">
- <description>
-When this file exists, the interface will be named with the text in this
-file. Without such an entry, the IP will not be shown by 'ifconfig' but
-by 'ip addr ls' only. Such a labeled interface is known as an "alias"
-also (e.g. 'eth0:foo').
- </description>
- </scalar>
- <boolean name="nodev">
- <description>
-When this file exists, the interface will be assumed to exist
-already. This can be used to assign primary interfaces which are
-created by the host or another vserver.
- </description>
- </boolean>
- </collection>
- </collection>
-
- <collection name="ulimits">
- <description>
-A directory with ulimits. Possible resources are cpu, data, fsize,
-locks, memlock, nofile, nproc, rss and/or stack. This configuration
-will be honored for kernel 2.4 only.
- </description>
- <scalar name="resource" type="symbolic">
- <description>
-A file which contains the hard- and soft-limit of the given resource
-in the first line. The special keyword 'inf' is recognized.
- </description>
- </scalar>
- <scalar name="resource.hard" type="symbolic">
- <description>
-A file which contains the hard- of the given resource in the first
-line. The special keyword 'inf' is recognized.
- </description>
- </scalar>
- <scalar name="resource.soft" type="symbolic">
- <description>
-A file which contains the soft- of the given resource in the first
-line. The special keyword 'inf' is recognized.
- </description>
- </scalar>
- </collection>
-
- <collection name="rlimits">
- <description>
-A directory with resource limits. Possible resources are cpu, fsize,
-data, stack, core, rss, nproc, nofile, memlock, as and locks. This
-configuration will be honored for kernel 2.6 only.
- </description>
- <scalar name="resource" type="symbolic">
- <description>
-A file which contains the hard- and soft-limit of the given resource
-in the first line. The special keyword 'inf' is recognized.
- </description>
- </scalar>
- <scalar name="resource.hard" type="symbolic">
- <description>
-A file which contains the hard- of the given resource in the first
-line. The special keyword 'inf' is recognized.
- </description>
- </scalar>
- <scalar name="resource.soft" type="symbolic">
- <description>
-A file which contains the soft- of the given resource in the first
-line. The special keyword 'inf' is recognized.
- </description>
- </scalar>
- <scalar name="resource.min" type="symbolic">
- <description>
-A file which contains the guaranted minimum of the given resource in
-the first line. The special keyword 'inf' is recognized.
- </description>
- </scalar>
- </collection>
-
- <collection name="uts">
- <scalar name="context">
- <description>
-The context-name of the vserver. This file is listed for completeness
-only; the 'context' name is used and set internally by the util-vserver
-tools and can *not* be modified.
- </description>
- </scalar>
- <scalar name="sysname">
- <description>The sysname of the vserver</description>
- </scalar>
- <scalar name="nodename">
- <description>The node-/hostname of the vserver</description>
- </scalar>
- <scalar name="release">
- <description>The OS-release of the vserver</description>
- </scalar>
- <scalar name="version">
- <description>The OS-version of the vserver</description>
- </scalar>
- <scalar name="machine">
- <description>The machine-type of the vserver</description>
- </scalar>
- <scalar name="domainname">
- <description>The NIS domainname of the vserver</description>
- </scalar>
- </collection>
- </collection>
- </database>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
-<xsd:annotation>
- <xsd:documentation xml:lang="en">
- Filesystem Database schema writen by Olivier Poitrey on 4/20/2004
- Version $Id$
- </xsd:documentation>
-</xsd:annotation>
-
-<xsd:group name="commonElements">
- <xsd:sequence>
- <xsd:element name="description" type="xsd:normalizedString" minOccurs="0"/>
- </xsd:sequence>
-</xsd:group>
-
-<xsd:attributeGroup name="commonAttributes">
- <xsd:attribute name="name" type="xsd:token" use="required"/>
- <xsd:attribute name="type" default="fixed">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="fixed"/>
- <xsd:enumeration value="symbolic"/>
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:attribute>
- <xsd:attribute name="use" default="required">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="optional"/>
- <xsd:enumeration value="required"/>
- <xsd:enumeration value="prohibited"/>
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:attribute>
-</xsd:attributeGroup>
-
-<xsd:simpleType name="quantityType">
- <xsd:union memberTypes="xsd:unsignedInt">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="unbounded"/>
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:union>
-</xsd:simpleType>
-
-<xsd:complexType name="baseItem" abstract="true">
- <xsd:sequence>
- <xsd:group ref="commonElements"/>
- </xsd:sequence>
- <xsd:attributeGroup ref="commonAttributes"/>
-</xsd:complexType>
-
-<xsd:complexType name="baseNode" abstract="true">
- <xsd:sequence>
- <xsd:group ref="commonElements"/>
- <xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element name="collection" type="collectionType">
- <xsd:unique name="collection">
- <xsd:annotation>
- <xsd:documentation xml:lang="en">
- Avoid duplicate element with same name attribute on the same level tree
- </xsd:documentation>
- </xsd:annotation>
- <xsd:selector xpath="*"/>
- <xsd:field xpath="@name"/>
- </xsd:unique>
- </xsd:element>
- <xsd:element name="scalar" type="scalarType"/>
- <xsd:element name="list" type="listType"/>
- <xsd:element name="hash" type="hashType"/>
- <xsd:element name="boolean" type="booleanType"/>
- <xsd:element name="data" type="dataType"/>
- <xsd:element name="link" type="linkType"/>
- <xsd:element name="program" type="programType"/>
- </xsd:choice>
- </xsd:sequence>
-</xsd:complexType>
-
-<xsd:complexType name="collectionType">
- <xsd:complexContent>
- <xsd:extension base="baseNode">
- <xsd:attributeGroup ref="commonAttributes"/>
- </xsd:extension>
- </xsd:complexContent>
-</xsd:complexType>
-
-<xsd:complexType name="scalarType">
- <xsd:complexContent>
- <xsd:extension base="baseItem">
- <xsd:sequence>
- <xsd:element name="default" type="xsd:normalizedString" minOccurs="0"/>
- <xsd:element name="restriction" minOccurs="0">
- <xsd:complexType>
- <xsd:choice>
- <xsd:element name="enumeration" minOccurs="0" maxOccurs="unbounded">
- <xsd:complexType>
- <xsd:attribute name="value" type="xsd:normalizedString"/>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
-</xsd:complexType>
-
-<xsd:complexType name="listType">
- <xsd:complexContent>
- <xsd:extension base="baseItem">
- <xsd:sequence>
- <xsd:element name="minElements" type="quantityType" minOccurs="0" default="0"/>
- <xsd:element name="maxElements" type="quantityType" minOccurs="0" default="unbounded"/>
- <xsd:element name="elements" minOccurs="0">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="element" minOccurs="0" maxOccurs="unbounded">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:group ref="commonElements"/>
- <xsd:element name="default" type="xsd:boolean" minOccurs="0" default="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:normalizedString" use="required"/>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
-</xsd:complexType>
-
-<xsd:complexType name="hashType">
- <xsd:complexContent>
- <xsd:extension base="baseItem">
- <xsd:sequence>
- <xsd:element name="keys" minOccurs="0">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="key" minOccurs="0" maxOccurs="unbounded">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:group ref="commonElements"/>
- <xsd:element name="default" type="xsd:normalizedString" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:normalizedString" use="required"/>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
-</xsd:complexType>
-
-<xsd:complexType name="booleanType">
- <xsd:complexContent>
- <xsd:extension base="baseItem">
- <xsd:sequence>
- <xsd:element name="default" type="xsd:boolean" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
-</xsd:complexType>
-
-<xsd:complexType name="dataType">
- <xsd:complexContent>
- <xsd:extension base="baseItem">
- <xsd:sequence>
- <xsd:element name="default" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
-</xsd:complexType>
-
-<xsd:complexType name="linkType">
- <xsd:complexContent>
- <xsd:extension base="baseItem">
- <xsd:sequence>
- <xsd:element name="default" type="xsd:token" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
-</xsd:complexType>
-
-<xsd:complexType name="programType">
- <xsd:complexContent>
- <xsd:extension base="baseItem">
- <xsd:sequence>
- <xsd:element name="parameterList" minOccurs="0">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:group ref="commonElements"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:normalizedString" use="required"/>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
-</xsd:complexType>
-
-<!-- root element -->
-<xsd:element name="database">
- <xsd:complexType>
- <xsd:complexContent>
- <xsd:extension base="baseNode"/>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:unique name="database">
- <xsd:annotation>
- <xsd:documentation xml:lang="en">
- Avoid duplicate element with same name attribute on the same level tree
- </xsd:documentation>
- </xsd:annotation>
- <xsd:selector xpath="*"/>
- <xsd:field xpath="@name"/>
- </xsd:unique>
-</xsd:element>
-
-</xsd:schema>
+++ /dev/null
-
- 1. [1]Introduction [new.gif]
- 1.1 [2]Who needs that [new.gif]
- 2. [3]Principles [new.gif]
- 2.1 [4]Non reversible isolation [new.gif]
- 2.2 [5]Isolation areas [new.gif]
- 2.3 [6]New system calls [new.gif]
- 2.4 [7]Limiting super-user: The capabilities system [new.gif]
- 2.5 [8]Enhancing the capability system [new.gif]
- 2.6 [9]Playing with the new system calls [new.gif]
- 2.6.1 [10]Playing with /usr/sbin/chcontext [new.gif]
- 2.6.2 [11]Playing with /usr/sbin/chcontext as root [new.gif]
- 2.6.3 [12]Playing with /usr/sbin/chbind [new.gif]
- 2.6.4 [13]Playing with /usr/sbin/reducecap [new.gif]
- 2.7 [14]Unification [new.gif]
- 3. [15]Applications [new.gif]
- 3.1 [16]Virtual server [new.gif]
- 3.2 [17]Per user fire-wall [new.gif]
- 3.3 [18]Secure server/Intrusion detection [new.gif]
- 3.4 [19]Fail over servers [new.gif]
- 4. [20]Installation [new.gif]
- 4.1 [21]The packages [new.gif]
- 4.2 [22]Setting a virtual server [new.gif]
- 4.3 [23]Basic configuration of the virtual server [new.gif]
- 4.4 [24]Entering the virtual server [new.gif]
- 4.5 [25]Configuring the services [new.gif]
- 4.6 [26]Starting/Stopping the virtual server [new.gif]
- 4.7 [27]Starting/Stopping all the virtual servers [new.gif]
- 4.8 [28]Restarting a virtual server from inside [new.gif]
- 4.9 [29]Executing tasks at vserver start/stop time [new.gif]
- 4.10 [30]Issues [new.gif]
- 4.11 [31]How real is it ? [new.gif]
- 5. [32]Features [new.gif]
- 6. [33]Future directions [new.gif]
- 6.1 [34]User controlled security box [new.gif]
- 6.2 [35]Kernel enhancements [new.gif]
- 6.2.1 [36]Per context disk quota [new.gif]
- 6.2.2 [37]Global limits [new.gif]
- 6.2.3 [38]Scheduler [new.gif]
- 6.2.4 [39]Security issues [new.gif]
- 6.2.4.1 [40]/dev/random [new.gif]
- 6.2.4.2 [41]/dev/pts [new.gif]
- 6.2.4.3 [42]Network devices [new.gif]
- 7. [43]Alternative technologies [new.gif]
- 7.1 [44]Virtual machines [new.gif]
- 7.2 [45]Partitioning [new.gif]
- 7.3 [46]Limitation of those technologies [new.gif]
- 8. [47]Conclusion [new.gif]
- 9. [48]Download [new.gif]
- 10. [49]References [new.gif]
-
- Virtual private servers and security contexts
-
- Running independent Linux servers inside a single PC is now possible.
- They offer many advantages, including higher security, flexibility and
- cost reduction.
-
- NEW
-
-Introduction
-
- Linux computers are getting faster every day. So we should probably
- end up with less, more powerful servers. Instead we are seeing more
- and more servers. While there are many reasons for this trend (more
- services offered), the major issue is more related to security and
- administrative concerns.
-
- Is it possible to split a Linux server into virtual ones with as much
- isolation as possible between each one, looking like real servers, yet
- sharing some common tasks (monitoring, backup, ups, hardware
- configuration, ...) ?
-
- We think so ... NEW
-
-Who needs that
-
- The short answer is everybody, or everybody managing a server. Here
- are some applications:
-
- * Hosting: Complete general purpose hosting (Running many
- independent servers in one box).
- * Experimentation: You are toying with a new services and do not
- want to impact the production services on the same machine.
- * Education: Each student has its own server with root password.
- * Personal security box: Run un-trusted applications with complete
- control over their interaction with the rest of the computer and
- the network.
- * Managing several "versions" of the same server/project and turning
- on/off each version independantly.
-
- Just think about all the viruses and worms out there, you end up with
- a big everybody using a computer needs this. :-) NEW
-
-Principles
-
- NEW
-
-Non reversible isolation
-
- Unix and Linux have always had the chroot() system call. This call was
- used to trap a process into a sub-directory. After the system-call,
- the process is led to believe that the sub-directory is now the root
- directory. This system call can't be reversed. In fact, the only thing
- a process can do is trap itself further and further in the file-system
- (calling chroot() again).
-
- The strategy is to introduce new system calls trapping the processes
- in other areas within the server. NEW
-
-Isolation areas
-
- A virtual server is isolated from the rest of the server in 5 areas:
-
- * File system
- The vserver is trapped into a sub-directory of the main server and
- can't escape. This is done by the standard chroot() system call
- found on all Unix and Linux boxes.
- * Processes
- The vserver can only see the processes in the same security
- context. Even the root server can't see the processes in vservers,
- making the root server less "dangerous" to use. A special
- mechanism (context number 1) exists to view all processes though
- (Limited to root in the root server).
- * Networking
- The vserver is assigned a host name and an IP number. The server
- can only use this IP number to establish services and client
- connection. Further, this restriction is transparent.
- * Super user capabilities
- The super user running in a vserver has less privileges than the
- normal Linux root user. For example, it can't reconfigure the
- networking and many aspect of the system. It can't mount devices,
- can't access block devices and so on.
- Roughly. the vserver super-user has full control over all files
- and processes in the vserver and that's pretty much it.
- * System V inter process communications
- Sysv IPC resources are private to each vserver. The security
- context is used as an extra key to select and assign resources.
-
- Those facilities are used together to create a runtime environment for
- virtual servers. But they can be used independently to achieve various
- goals. NEW
-
-New system calls
-
- The new system calls, as well as the existing chroot() system call are
- sharing one common feature: Their effect can't be reversed. Once you
- have executed one of those system call (chroot, new_s_context,
- set_ipv4root), you can't get back. This affects the current process
- and all the child processes. The parent process is not influenced.
-
- * new_s_context (int ctx)
- This system call sets a new security context for the current
- process. It will be inherited by all child processes. The security
- context is just an id, but the system call makes sure a new unused
- one is allocated.
- A process can only see other processes sharing the same security
- context. When the system boot, the original security context is 0.
- But this one is not privileged in anyway. Processes member of the
- security context 0 can only interact (and see) processes member of
- context 0.
- This system call isolates the processes space.
- * Setting the capabilities ceiling
- This is handle by the new_s_context system call as well. This
- reduces the ceiling capabilities of the current process. Even
- setuid sub-process can't grab more capabilities. The capability
- system found since Linux 2.2 is explained later in this document.
- * set_ipv4root(unsigned long ip)
- This system call locks the process (and children) into using a
- single IP when they communicate and when they installs a service.
- This system call is a one shot. Once a process have set its IPV4
- (Internet Protocol Version 4) address to something different from
- 0.0.0.0, it can't change it anymore. Children can't change it
- either.
- If a process tries to bind a specific IP number, it will succeed
- only if this corresponds to the ipv4root (if different from
- 0.0.0.0). If the process bind to any address, it will get the
- ipv4root.
- Basically, once a process is locked to a given ipv4root it is
- forced to use this IP address to establish a service and
- communicate. The restriction on services is handy: Most service
- (Web servers, SQL servers) are binding to address 0.0.0.0. With
- the ipv4root sets to a given IP you can have two virtual servers
- using the exact same general/vanilla configuration for a given
- services and running without any conflict.
- This system calls isolate the IP network space.
-
- Those system calls are not privileged. Any user may issue them. NEW
-
-Limiting super-user: The capabilities system
-
- Once you have created a virtual environment where processes have a
- limited view of the file-system, can't see processes outside of their
- world and can only use a single IP number, you still must limit the
- damages those processes can do. The goal is to run virtual
- environments and provide some root privileges.
-
- How do you limit those root processes from taking over the system, or
- even just re-booting it. Enter the capability system. This is not new,
- but we suspect many people have never heard of it.
-
- In the old Unix/Linux days, user root (user ID 0) could do things
- other user ID could not. All over the place in the kernel, system
- calls were denying access to some resources unless the user ID of the
- process (effective ID in fact) was 0. Plain zero.
-
- The only way a process with user ID 0 could loose some privileges was
- by changing to another ID. Unfortunately this was an all or nothing
- deal. Enter the capabilities.
-
- Today, the difference between root and the other users is the
- capability set. User root has all capabilities and the other users
- have none. The user ID 0 does not mean anything special anymore. There
- are around 30 capabilities defined currently. A process may request to
- loose a capability forever. It won't be able to get it back.
-
- Capabilities allows a root process to diminish its power. This is
- exactly what we need to create custom super-user. A super-user process
- in a virtual server would have some privileges such as binding port
- below 1024, but would not be able to reconfigure the network or reboot
- the machine. Check the file /usr/include/linux/capability.h to learn
- which one are available.
-
- Note that the new system calls (new_s_context and set_ipv4root) are
- not controlled by capabilities. They are by nature irreversible. Once
- a virtual server is trapped in a chroot/s_context/ipv4root box, it
- can't escape from the parameters of this trap.
-
- NEW
-
-Enhancing the capability system
-
- The Linux capability system, is still a work in progress. At some
- point, we expect to see capabilities attached to programs,
- generalizing the setuid concept. A setuid program would become a
- program with all capability granted.
-
- For now, this is not available. As explained above a process may
- request to loose capabilities and its child process will be trapped
- with a smaller capability set.
-
- Well, ..., it does not work that way. Unfortunately, until
- capabilities could be assigned to program, we still need a way to get
- back capabilities even in a child process. So the irreversible logic
- of the capabilities is kind of short circuited in the kernel.
-
- To solve this, we have introduced a new per-process capability ceiling
- (cap_bset). This one represents the capability set inherited by child
- process, including setuid root child process. Lowering this ceiling is
- irreversible for a process and all its child.
-
- This ceiling is handled by the new_s_context system call and the
- reducecap and chcontext utilities (part of the vserver package).
-
- Using this, we can setup a virtual server environment where root has
- less capabilities, so can't reconfigure the main server.
-
- NEW
-
-Playing with the new system calls
-
- The vserver package provides 3 utilities to make use of the new system
- calls. We will describe shortly how they work and provide few example.
- We invite the reader to try those example, so it has a better feel and
- trust.
-
- After re-booting with a kernel implementing the new system calls, and
- installing the vserver package, one is ready to do experiment. You do
- not need to be root to test those new utilities. None of them is
- setuid either. NEW
-
-Playing with /usr/sbin/chcontext
-
- The /usr/sbin/chcontext utility is used to enter into a new security
- context. The utility switch the security context and execute a
- program, specified on the command line. This program is now isolated
- and can't see the other processes running on the server.
-
- The experiment with this, start two command windows (xterm), as the
- same user ID. In each window execute the following commands:
-
- xterm
-
- Using chcontext: first window
-
-/usr/sbin/chcontext /bin/sh
-pstree
-killall xterm
-exit
-
- Using chcontext: second window
- In the first window, you start the xterm command (or any command you
- like). In the second window you execute chcontext. This starts a new
- shell. You execute pstree and see very little. You attempt to kill the
- xterm and you fail. You exit this shell and you are back seeing all
- processes.
-
- Here is another example. You switch context and you get a new shell.
- In this shell you start an xterm. Then you switch context again and
- start another sub-shell. Now the sub-shell is again isolated.
-
-/usr/sbin/chcontext /bin/sh
-pstree
-xterm &
-pstree
-# Ok now you see your xterm
-/usr/sbin/chcontext /bin/sh
-pstree
-# the xterm is not there, killall will fail
-killall xterm
-# Now we exit the shell
-exit
-pstree
-# the xterm is there
-killall xterm
-# Ok, it is gone
-exit
-# We are back to the initial security context
-
- Using chcontext several times
- Processes isolated using chcontext are doubly isolated: They can't see
- the other processes on the server, but the other processes can't see
- them either. The original security context (0) when you boot is no
- better than the other: It sees only process in security context 0.
-
- While playing with chcontext, you will notice an exception. The
- process 1 is visible from every security context. It is visible to
- please utilities like pstree. But only root processes in security
- context 0 are allowed to interact with it. NEW
-
-Playing with /usr/sbin/chcontext as root
-
- The new_s_context system call has a special semantic for root
- processes running in security context 0 and having the CAP_SYS_ADMIN
- capability: They can switch to any context they want.
-
- Normally, new_s_context allocates a new security context by selecting
- an unused one. It walks all processes and find an ID (an integer) not
- currently in use.
-
- But root in security context 0 is allowed to select the context it
- wants. This allow the main server to control the virtual server. The
- chcontext utility has the --ctx option to specify the context ID you
- want.
-
- To help manage several virtual server, given that the security context
- 0 can't see processes in other security context, it is a good thing
- root in the main server (security context 0) is allowed to select a
- specific context. Cool. But we also need a way to have a global
- picture showing all processes in all security context. The security
- context 1 is reserved for this. Security context 1 is allowed to see
- all processes on the server but is not allowed to interact with them
- (kill them).
-
- This special feature was allocated to security context 1 and not 0
- (the default when you boot) to isolate virtual servers from the main.
- This way, while maintaining services on the main server, you won't
- kill service in vservers accidentally.
-
- Here is an example showing those concepts:
-
-# You must be root, running X
-# We start an xterm in another security context
-/usr/sbin/chcontext xterm &
-# We check, there is no xterm running, yet we can
-# see it.
-ps ax | grep xterm
-# Are we running in security context 0
-# We check the s_context line in /proc/self/status
-cat /proc/self/status
-# Ok we in security context 0
-# Try the security context 1
-/usr/sbin/chcontext --ctx 1 ps ax | grep xterm
-# Ok, we see the xterm, we try to kill it
-/usr/sbin/chcontext --ctx 1 killall xterm
-# No, security context 1 can see, but can't kill
-# let's find out in which security context this
-# xterm is running
-/usr/sbin/chcontext --ctx 1 ps ax | grep xterm
-# Ok, this is PID XX. We need the security context
-/usr/sbin/chcontext --ctx 1 cat /proc/XX/status
-# We see the s_context, this is SS.
-# We want to kill this process
-/usr/sbin/chcontext --ctx SS killall xterm
-
- chcontext as root
- The /usr/sbin/vpstree and /usr/sbin/vps commands are supplied by the
- vserver package. They simply runs ps and pstree in security context 1.
- NEW
-
-Playing with /usr/sbin/chbind
-
- The chbind utility is used to lock a process and its children into
- using a specific IP number. This applies to services and client
- connection as well. Here are few examples. Execute them as root:
-
-# httpd is running
-netstat -atn | grep ":80 "
-# We see a line like this
-# tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
-# Now we restart httpd, but we lock it so it
-# uses only the main IP of eth0
-/usr/sbin/chbind --ip eth0 /etc/rc.d/init.d/httpd restart
-netstat -atn | grep ":80 "
-# Now we see a line like
-# tcp 0 192.168.1.1:80 0.0.0.0:* LISTEN
-# httpd.conf was not changed.
-# Now, restart it normally
-/etc/rc.d/init.d/httpd restart
-# Now we experiment with client socket
-# Log using telnet
-telnet localhost
-# Once logged in
-netstat -atn | grep ":23 "
-# You should see a line showing a connection from
-# 127.0.0.1 to 127.0.0.1 like this
-# tcp 0 0 127.0.0.1:23 127.0.0.1:32881 ESTABLISHED
-exit
-# Now we do the telnet again, bug forcing it to select a specific IP
-/usr/sbin/chbind --ip eth0 telnet localhost
-# Log in and then execute
-netstat -atn | grep ":23 "
-# You will get something like
-# tcp 0 0 127.0.0.1:23 192.168.3.9:32883 ESTABLISHED
-
- Using /usr/sbin/chbind
- NEW
-
-Playing with /usr/sbin/reducecap
-
- The reducecap utility is used to lower the capability ceiling of a
- process and child process. Even setuid program won't be able to grab
- more capabilities.
-
-# You are not root now
-# What is the current capability ceiling
-cat /proc/self/status
-# The capBset line presents mostly 1s.
-/usr/sbin/reducecap --secure /bin/sh
-cat /proc/self/status
-# The capBset now shows many more 0s.
-# The capEff shows all 0s, you have no privilege now
-# We su to root
-su
-cat /proc/self/status
-# capEff is much better now, but there are still many 0s
-# Now we try to see if we are really root
-tail /var/log/messages
-# So far so good, we see the content
-/sbin/ifconfig eth0
-/sbin/ifconfig eth0 down
-# No way, we can't configure the interface. In fact
-# we have lost most privilege normally assigned to root
-exit
-
- Using /usr/sbin/reducecap
- NEW
-
-Unification
-
- Installing a virtual private server copies a linux installation inside
- a sub-directory. It is a linux inside linux. If you intend to run
- several vservers on the same box (which you will certainly do :-) ),
- you will end up using a lot of disk space needlessly: Each vserver is
- made up hundreds of megabytes of the same stuff. This is a big waste
- of disk space.
-
- A solution is to use hard links to connect together common files.
- Using the package information, we can tell which packages are shared
- between various vservers, which files are configuration files and
- which are not (binaries, libraries, resource files, ...). Non
- configuration files may be linked together saving a huge amount of
- disk space: A 2 GIG rh7.2 installation shrinks to 38megs.
-
- Using hard links is cool, but may be a problem. If one vserver
- overwrite one file, say /bin/ls, then every vserver will inherit that
- change. Not fun! The solution is to set the immutable bit on every
- linked file. A file with such a bit on can't be modified, even by
- root. The only way to modify it is to turn off the bit first. But
- within a vserver environment, even root is not allowed to perform this
- task. So linked file, turned immutable, are now safe: They can be
- shared between vservers without side effects: Cool!
-
- Well, there is still another side effect. All vservers are now locked
- with the same files. We are saving a lot of disk space, but we pay a
- very heavy price for that: Vservers can't evolve independantly.
-
- A solution was found. A new bit call immutable-linkage-invert was
- added. Combined with the immutable bit, a file may not be modified,
- but may be unlinked. Unlinking a file in Unix/Linux means
- disconnecting the name from the data and removing the name from the
- directory. If the data is still referenced by one or more vservers, it
- continue to exist on disk. So doing "rm /bin/ls" on a vserver, removes
- the file /bin/ls for that vserver and that's all. If all vservers
- perform this task, then /bin/ls (the data) will be forgotten completly
- and the disk space will be recovered.
-
- Using this trick, a vserver gets back its independance. It becomes
- possible to update packages by using the unlink/update sequence:
- Unlink /bin/ls first and then put a new copy in place. Luckily,
- package manager works this way.
-
- To keep this story short (probably too late :-) ), a unified vserver:
- * Uses little disk space
- * Can't interfere with other vservers by changing one of its file.
- * Can perform package update/deletion normally using standard
- practice.
-
- NEW
-
-Applications
-
- NEW
-
-Virtual server
-
- The first goal of this project is to create virtual servers sharing
- the same machine. A virtual server operate like a normal Linux server.
- It runs normal services such as telnet, mail servers, web servers, SQL
- servers. In most cases, the services run using standard configuration:
- The services are running unaware of the virtual server concept.
-
- Normal system administration is performed with ordinary admin tool.
- Virtual servers have users account and a root account.
-
- Packages are installed using standard packages (RPMs for example).
-
- There are few exceptions. Some configuration can't be done inside a
- virtual server. Notably the network configuration and the file-system
- (mount/umount) can't be performed from a virtual server.
-
- NEW
-
-Per user fire-wall
-
- The set_ipv4root() system call may be used to differentiate the
- various users running on an application server. If you want to setup a
- fire-wall limiting what each user is doing, you have to assign one IP
- per user, even if they are running application on the same server. The
- chbind utility may be used to achieve that. NEW
-
-Secure server/Intrusion detection
-
- While it can be interesting to run several virtual servers in one box,
- there is one concept potentially more generally useful. Imagine a
- physical server running a single virtual server. The goal is isolate
- the main environment from any service, any network. You boot in the
- main environment, start very few services and then continue in the
- virtual server. The service in the main environment could be
-
- * Un-reachable from the network.
- * The system log daemon. While virtual server could log messages,
- they would be unable to change/erase the logs. So even a cracked
- virtual server would not be able the edit the log.
- * Some intrusion detection facilities, potentially spying the state
- of the virtual server. For example tripwire could run there and it
- would be impossible to circumvent its operation or trick it.
-
- NEW
-
-Fail over servers
-
- One key feature of a virtual server is the independence from the
- actual hardware. Most hardware issues are irrelevant for the virtual
- server installation. For example:
-
- * Disk layout, partitions and the /etc/fstab configuration. The
- virtual server has a dummy /etc/fstab.
- * Network devices.
- * Processor type, number of processor (kernel selection).
-
- The main server acts as a host and takes care of all those details.
- The virtual server is just a client and ignores all the details. As
- such, the client can be moved to another physical server will very few
- manipulations. For example, to move the virtual server v1 from one
- physical one computer to another, you do
-
- * Turn it off
- /usr/sbin/vserver v1 stop
- * Copy the file /etc/vservers/v1.conf to the new server.
- * Copy all files in /vservers/v1 to the new server
- * On the new server, start the vserver v1
- /usr/sbin/vserver v1 start
-
- As you see, there is no adjustment to do:
-
- * No user account merging.
- * No hardware configuration to fix.
-
- This opens the door to fail over servers. Imagine a backup server
- having a copy of many virtual servers. It can take over their tasks
- with a single command. Various options exists for managing this backup
- server:
-
- * rsync to synchronize the data.
- * Network block devices to synchronize the data in real time.
- * Sharing the installation over a SAN (storage area network).
- * Heartbeat for automatic monitoring/fail over.
-
- NEW
-
-Installation
-
- NEW
-
-The packages
-
- * The kernel
- We are supplying a patched 2.4.20 kernel. You will find [50]here
- the kernel, the .config and the patch.
- To install the kernel, just untar it. This will create a file
- /boot/kernel-2.4.20ctx-17 (ctx stands for security context) and a
- directory /lib/modules/2.4.20ctx-17.
- Then, you need to update your boot loader. For lilo, you add a
- section like this at the end of the file /etc/lilo.conf
-
-
-image=/boot/vmlinuz-2.4.20ctx-17
- label=linux2.4.20ctx-17
- read-only
- root=current
-
- lilo.conf section to add
- Change the /dev/XXXX to your root partition. Then execute
- /sbin/lilo.
- Reboot and select the proper kernel. This kernel is fully
- compatible with a normal 2.4.20 and will perform without any new
- configuration. Note that the supplied kernel does not carry all
- the features and modules found on the various distributions.
- * The vserver package
- This package provides the various utilities to make use of those
- new system calls. The package also provides a complete solution to
- implement virtual servers. We describe the major components here.
- + /usr/sbin/chcontext
- This is the utility to request a new security context. It can
- be used to lower the capability ceiling. Execute it to learn
- more.
- + /usr/sbin/chbind
- This is the utility to select one IP number and assign it to
- a process and its children.
- + /usr/sbin/newvserver (in vserver-admin)
- Front-end to help create new virtual servers.
- + /usr/sbin/reducecap
- This utility is used to lower the capability ceiling of
- children processes.
- + /usr/sbin/vdu
- A trimmed down "du" command reporting space usage of files
- with a single link. Useful to tell how much space a unified
- vserver is using.
- + /usr/sbin/vkill
- Locate the security context associated with a process, enter
- it and kill the process. Generally used after you have
- located a process with vtop, vpstree or vps.
- + /usr/sbin/vps
- Execute the ps command in security context 1 so all processes
- in all vservers are shown. The security context and vserver
- name are mapped inside the report.
- + /usr/sbin/vpstree
- Execute the pstree command in security context 1 so all
- processes in all vservers are shown.
- + /usr/sbin/vrpm
- Apply an rpm command in several (or all) vservers. Useful
- when you wish to update many vservers with the same package.
- /usr/sbin/vrpm server1 server2 -- -Uvh /tmp/*.rpm
- /usr/sbin/vrpm ALL -- -Uvh /tmp/*.rpm
- After updating many packages in different vservers you may
- want to re-unify them to recover disk space (and increase
- cache effectivity). You can do this using the vunify command,
- or simply by using the --unify option to the vrpm command.
- After performing the rpm updates, vrpm will trigger the
- vunify utility on the vservers for the updated packages.
- /usr/sbin/vrpm --unify server1 server2 -- -Uvh /tmp/*.rpm
- + /usr/sbin/vserver
- This is the wrapper to start, stop and administer virtual
- servers.
- + /usr/sbin/vserver-stat
- Produce a small report showing the activity in active
- security context. The report presents the number of process
- in each active security context as well as the name of the
- vserver associated with this context.
- + /usr/sbin/vtop
- Execute the top command in security context 1 so all
- processes in all vservers are shown.
- + /etc/rc.d/init.d/vservers
- This is an init script used to start all virtual servers at
- boot time and stop them at shutdown time. Only virtual
- servers with ONBOOT=yes are started at boot time. All
- vservers are stopped at shutdown time.
- + /etc/rc.d/init.d/rebootmgr
- This is a daemon listening to requests from virtual servers.
- It can either restart or stop a virtual server. The
- /sbin/vreboot and /sbin/vhalt utilities are used to send
- request to the reboot manager.
- + /sbin/vreboot and /sbin/vhalt
- Those utilities are copied in each virtual server. They
- connect to the reboot manager (rebootmgr) server using the
- /dev/reboot Unix domain socket and request either a restart
- or a stop of the virtual server. The reboot manager issue
- either a "/usr/sbin/vserver vserver restart" or
- "/usr/sbin/vserver vserver stop" command. This allows the
- virtual server administrator to test if all automatic service
- are properly restarted at boot time.
- + /usr/lib/vserver/vdu
- This is a limited clone of the du command. It skips file with
- more than one link. It is used to evaluate the disk usage of
- an unified vserver. Using the normal du for this task is
- misleading since it will count all unified files.
-
- NEW
-
-Setting a virtual server
-
- To set a virtual server, you need to copy in a sub-directory a Linux
- installation. One way to achieve that is to copy some parts of the the
- current server by issuing the command vserver XX build, where XX is
- the name of the virtual server (pick one). This basically does (Well,
- it does a little more than that, but this give you an idea):
-
-mkdir /vservers/XX
-cd /vservers/XX
-cp -ax /sbin /bin /etc /usr /var /dev /lib .
-mkdir proc tmp home
-chmod 1777 tmp
-
- Building a virtual server
-
- This is normally done using the command /usr/sbin/newvserver. This is
- a text mode/graphical front-end allowing to setup the vserver runtime
- and configure it. NEW
-
-Basic configuration of the virtual server
-
- A virtual private server has a few settings. They are defined in the
- file /etc/vservers/XX.conf where XX is the name of the virtual server.
- This is a simple script like configuration. Here are the various
- parameters:
-
- * IPROOT
- In general, each virtual server is tied to one IP using the new
- set_ipv4root system call. This way several servers may run the
- same services without conflict. Enter the IP number (a name is
- also valid if defined in the DNS).
- Since kernel ctx-12, you can assign more than one IP number to a
- vserver. Enter them separated by spaces and don't forget to
- enclose them with quotes.
- Bu default, all IPs are configured as an IP alias on the IPROOTDEV
- device (if defined). If you want to attach the various IP numbers
- to different devices, specify the device as a prefix to the IP
- number like this:
-
-IPROOT="eth0:192.168.1.2 eth1:192.168.3.1 192.168.1.4"
-
- IPROOT using multiple devices
- In the example above, the IP 192.168.1.4 will be installed as an
- IP alias on the device IPROOTDEV.
- Use "IPROOT=0.0.0.0" or "IPROOT=" if you do not want to tie the
- vserver at all. It will be allowed to use any IP available on the
- server.
- * IPROOTDEV
- This is the network device use to setup the IP alias defined by
- IPROOT. This is generally eth0. If you define this variable, the
- IP alias will be configured when you start the virtual server and
- un-configure when you stop it.
- * IPROOTMASK
- Netmask used to setup the IP alias. Uses the netmask of the
- IPROOTDEV device by default. Seldom used.
- If you have several IPs on one vserver and want to have different
- netmask for each, use the following syntax:
-
-IPROOT="eth0:192.168.1.2 eth1:192.168.3.1/255.255.255.192"
-
- IPROOT using different netmask
- 192.168.1.2 will use the netmask of eth0, while 192.168.3.1 will
- use the specified netmask: 255.255.255.192.
- * IPROOTBCAST
- Broadcast address used to setup the IP alias. Uses the broadcast
- of the IPROOTDEV device by default. Seldom used.
- * ONBOOT
- The vserver package supplies the vservers service. This service is
- installed in the main server. It is used to start and stop the
- virtual server at boot and shutdown time.
- Virtual server with ONBOOT=yes will be started and stopped
- properly like any other services of the main server.
- Once a virtual server is properly configured, it is a good idea to
- set this parameter to yes.
- * S_CAPS
- You enter here the various capability you want to grant to the
- vserver. By default, a vserver is left with much less capabilities
- than the root server. For example, a vserver is not allowed to use
- raw socket. This explains why the ping command fails. S_CAPS lets
- you enumerate the capability you want to keep in the vserver.
- CAP_NET_RAW will give back ping ability for example.
- * S_CONTEXT
- This is optional. In general the security context ID is selected
- by the kernel. An unused one is selected. If you select an ID (an
- integer greater than 1), make sure you select a different one for
- each server. Again, in most cases, you do not need to select one.
- Leave the line commented.
- * S_DOMAINNAME
- A virtual server may have a different NIS domainname than the main
- server. You set it here. If you leave the field empty, the vserver
- will inherit the same NIS domain as the root server. Enter "none"
- to reset the NIS domain name for this vserver.
- * S_HOSTNAME
- Many services (Apache for one) use the host name to setup some
- defaults. A virtual server may have a different host name than the
- main server. It is a good idea to fill this line.
- * S_NICE
- The is an optional priority level. It is an integer ranging
- between from -20 to 19. Well it is the nice level in fact, so -20
- means the highest priority and 19 the lowest (the highest nice
- level). All processes in the virtual server will be locked to this
- level (or higher niceness).
- Event root is locked and can't get more priority.
- Note that this has limited usefulness. The kernel does not
- differentiate processes running in different security context for
- scheduling (for now :-) ). This means that a virtual servers
- running many low priority processes may nevertheless claim a large
- share of CPU.
- * S_FLAGS
- This is used to set various flags. Here are the supported flags:
- + lock
- This flags prevents the vserver from setting new security
- contexts.
- + sched
- It kind of unifies the processes in a vserver from a
- scheduler view point. All processes are weighted as single
- one when compared to other processes in the real server. This
- prevents a vserver from taking to much CPU resources.
- + nproc
- Make the ulimit maximum user process global to the vserver.
- + private
- Once set on a vserver security context, no other process can
- enter it. Even the root server is unable to enter the
- context. It can see the process list using security context
- 1, but can't signal or trace the process.
- + fakeinit
- This assigned the current process so it works like the
- process number 1. Using this trick, a normal /sbin/init may
- be run in a vserver. The /usr/sbin/vserver command will use
- /sbin/init to start and stop a vserver. A properly configured
- /etc/inittab is needed though.
- o Processes loosing their parent are reparent to this
- process.
- o getppid() done by child process of this process returns
- 1.
- o getpid() done by this process returns 1.
- o This process is not shown in /proc since process number
- 1 is always shown.
- o An "initpid" entry is available in /proc/*/status to
- tell which process is the fake init process.
- * ULIMIT
- This contains the command line option to the ulimit shell command.
- You enter here whatever parameters accepted by ulimit. Here is the
- default when you create a new vserver:
-
-ULIMIT="-H -u 1000"
-
- Default vserver ulimit
- Normally ulimit settings only affects users independantly. So
- limiting a vserver this way, limit each user processes
- independantly in the vserver. Using special flags in the S_FLAGS
- option, you can make those ulimit settings global to the vserver.
- The example above used with the nproc parameter make the maximum
- number of process global. In this case, a maximum of 1000
- processes is available to all users in the vserver.
-
- NEW
-
-Entering the virtual server
-
- It is possible to enter a virtual server context from the main server
- just by executing /usr/sbin/vserver XX enter (where XX is the virtual
- server name).
-
- This creates a shell. From there you can execute anything
- administrative you normally do on a Linux server.
-
- NEW
-
-Configuring the services
-
- The virtual server can run pretty much any services. Many pseudo
- services, such as network configuration are useless (the server is
- already configured). After building the environment, enter it (without
- starting the virtual server) using the vserver name enter command.
- Then using a tool like Linuxconf (control/control service activity) ,
- or ntsysv, browse all service and keep only the needed ones.
-
- So after building the server, you enter it and you select the service
- you need in that server. Many services such as network, and apmd are
- either useless or won't run at all in the virtual server. They will
- fail to start completely. NEW
-
-Starting/Stopping the virtual server
-
- Virtual server with ONBOOT=yes will be started and stopped like any
- other services of the main server. But you can stop and start a
- virtual server at any time. Starting a server means that all
- configured service will be started. Stopping it means that all
- configured services will be stopped and then all remaining process
- will be killed.
-
- Oddly, starting a virtual server does not mean much. There is no
- overhead. No monitoring process or proxy or emulator. Starting a
- virtual server with 4 services is the same as running those 4 services
- in the main server, at least performance wise (the service inside a
- virtual server are locked inside the security context).
-
- The following commands may be used to control a virtual server:
-
- * /usr/sbin/vserver server start
- * /usr/sbin/vserver server stop
- * /usr/sbin/vserver server restart
- * /usr/sbin/vserver server running
- * /usr/sbin/vserver server enter
- * /usr/sbin/vserver server exec some commands ...
- * /usr/sbin/vserver server suexec user some commands ...
- * /usr/sbin/vserver server service service-name
- start/stop/restart/status
- * /usr/sbin/vserver server status
-
- The running command prints if there are any processes running in the
- virtual server context.
-
- Please note
-
- The processes running in a virtual server are invisible from the main
- server. The opposite is true. This is very important. Managing the
- main server must not cause problems to the various virtual servers.
- For example, doing killall httpd will kill all the httpd processes in
- the current context ( the main server or a virtual one).
-
- NEW
-
-Starting/Stopping all the virtual servers
-
- The sysv script /etc/rc.d/init.d/vserver is used to start and stop the
- virtual server at boot and shutdown time. It may be used at any time
- to operate all virtual servers. The following commands are supported:
-
- * /etc/rc.d/init.d/vservers start
- * /etc/rc.d/init.d/vservers stop
- * /etc/rc.d/init.d/vservers restart
- * /etc/rc.d/init.d/vservers status
-
- The status command reports the running status of every virtual server.
- NEW
-
-Restarting a virtual server from inside
-
- A virtual server administrator is not allowed to reboot the machine
- (the kernel). But it is useful to restart his virtual server from
- scratch. This allow him to make sure all the services are properly
- configured to start at boot time.
-
- The /sbin/vreboot and /sbin/vhalt utilities are installed in each
- virtual server so they can request a restart or stop.
-
- The rebootmgr service must be enabled in the main server.
-
- NEW
-
-Executing tasks at vserver start/stop time
-
- You can setup a script called /etc/vservers/XX.sh where XX is the name
- of the virtual server. This script will be called four time:
-
- * Before starting the vserver
- * After starting it.
- * Before stopping it.
- * After stopping it.
-
- You generally perform tasks such as mounting file system (mapping some
- directory in the vserver root using "mount --bind").
-
- Here is an example where you map the /home directory as the vserver
- /home directory.
-
-#!/bin/sh
-case $1 in
-pre-start)
- mount --bind /home /vservers/$2/home
- ;;
-post-start)
- ;;
-pre-stop)
- ;;
-post-stop)
- umount /vservers/$2/home
- ;;
-esac
-
- /etc/vservers/XX.sh
- NEW
-
-Issues
-
- There are some common problem you may encounter. Here they are.
-
- * The main server is not tied (by default) to any ipv4root. So if
- the main server has already some service running they are probably
- binding some UDP or TCP ports using the address 0.0.0.0. Once a
- process has bound a service with the address 0.0.0.0 (see the
- LISTEN lines when executing the "netstat -a" command), no other
- process can bind the same port, even with a specific address.
- The solution is to start the services of the main server using the
- chbind utility to trap them in one ipv4root. For example
-
-/sbin/chbind --ip eth0 /etc/rc.d/init.d/httpd start
-
- Assigning on IP to a service
- will limit Apache to the IP address of the eth0 interface. without
- configuration changes (in httpd.conf). It is probably a good idea
- to start the following services in the main server this way,
- because they will be run by virtual servers as well.
-
- * httpd
- * sshd
- * xinetd
-
- To ease this, the vserver package supplies the following services:
- v_httpd, v_sshd, v_smb and v_xinetd. Disable the corresponding
- services and enable the v_ services and you will lock those services
- on a single IP.
-
- Cleanup rc.local. This is probably not doing anything useful.
-
- NEW
-
-How real is it ?
-
- The project is new. So far, experiments have shown very little
- restrictions. Service works the same in a virtual server. Further,
- performance is the same. And there is a high level of isolation
- between the various virtual servers and the main server. NEW
-
-Features
-
- There are various tricks one can use to make the virtual servers more
- secure.
-
- * Putting a fire-wall on the box and limiting access to a virtual
- services from another one.
- * Using port redirection to allow one virtual server to logically
- bind several IPs. One virtual server could run several web virtual
- host this way.
-
- NEW
-
-Future directions
-
- NEW
-
-User controlled security box
-
- By combining the capabilities, the s_context, the ipv4root and the
- AclFS (component of the [51]virtualfs package), we can produce a user
- level tool allowing controlled access to the user own resources. For
- example the user may download any program he wants and execute them
- under control. Whenever the program tries to access something not
- specified by the user, a popup is presented and the user may choose to
- terminate the program or allow the access.
-
- NEW
-
-Kernel enhancements
-
- We expect to see some wider usage of the virtual servers. As usage
- grow, we expect to see needs for more control. Here are some ideas.
-
- NEW
-
-Per context disk quota
-
- If one installs virtual servers and grant access to less trusted
- users, he may want to limit the disk space used. Since a virtual
- server may create new user accounts and run processes with any user ID
- it wants, the current kernel disk quota is not powerful enough. First,
- it can't differentiate between user ID 100 in one virtual server and
- user ID 100 in another one.
-
- Further, the main administrator may want to control disk space
- allocated to the virtual server on a server per server basis,
- unrelated to the various user ID in use in those virtual servers.
-
- The kernel has already user and group disk quota. Adding security
- context disk quota should be easily done.
-
- To differentiate between user IDs in virtual servers, the kernel could
- coin together the security context and the user id to create a unique
- ID. The kernel 2.4 now supports 32 user ID, so combining security
- context and user ID in a single 32 bits number should be acceptable.
-
- NEW
-
-Global limits
-
- The kernel has supports for user limit (memory, processes file
- handles). With virtual server, we may want to limit the resources used
- by all processes in the virtual server. The security context would be
- used as the key here. The following resources could be limited on a
- security context basis (as opposed to user or process basis)
-
- * Memory used
- * Processes number
- (Done: This is now supported with the nproc flag in the kernel
- 2.4.16ctx-4. By default a new vserver is limited to 1000 processes
- maximum, configurable).
- * File handles
-
- NEW
-
-Scheduler
-
- The scheduler may become security context aware. It could potentially
- use this to provide some fairness and control priority based on
- context. Currently the scheduler is process oriented and does not
- group process together to qualify their priorities. For example, a
- user running 10 compilations will get more CPU than another user
- running a single compilation.
-
- Currently, it is possible to raise the nice (lower priority) for all
- processes in a virtual server. This can't be reversed, so you are
- setting an upper limit on priority (Just set the S_NICE variable in
- the vserver configuration file). Note that a virtual server may still
- start many low priority processes and this can grab significant share
- of the CPU. A global per security context might be needed to really
- provide more control and fairness between the various virtual servers.
-
- Done: The sched security context flag group all process in a vserver
- so their priority is kind of unified. If you have 50 processes running
- full speed in one vserver, they will take as much CPU resource than a
- single process in the root server. A vserver can't starve the other...
- NEW
-
-Security issues
-
- The current kernel + patch provides a fair level of isolation between
- the virtual servers. User root can't take over the system: He sees
- only his processes, has only access to his area of the file system
- (chroot) and can't reconfigure the kernel. Yet there are some
- potential problems. They are fixable. As usage grows, we will know if
- they are real problems. Comments are welcome:
-
- NEW
-
-/dev/random
-
- Writing to /dev/random is not limited by any capability. Any root user
- (virtual included) is allowed to write there. Is this a problem ?
-
- (kernel expert think it is ok) NEW
-
-/dev/pts
-
- /dev/pts is a virtual file-system used to allocate pseudo-tty. It
- presents all the pseudo-tty in use on the server (including all
- virtual server). User root is allowed to read and write to any
- pseudo-tty, potentially causing problems on other vservers.
-
- Starting with the ctx-6 patch, /dev/pts is virtualised. Although the
- file numbers are allocated from a single pool, a vserver only see the
- pseudo-tty it owns. NEW
-
-Network devices
-
- Anyone can list the network devices configurations. This may inform a
- virtual user that another vserver is on the same physical server. By
- using as much resources as possible in his own vservers, a malicious
- user could slow down the other server. Modification to the scheduler
- explained above could stop this.
-
- Starting with the ctx-6 patch, a vserver only see the device
- corresponding to its IP number. NEW
-
-Alternative technologies
-
- Using virtual servers may be a cost effective alternative to several
- independent real servers. You get the administrative independence of
- independent servers, but share some costs including operation costs.
-
- Other technologies exist offering some of the advantages talked in
- this document as well as other. Two technologies are available on
- various hardware platform: Virtual machines and partitioning, NEW
-
-Virtual machines
-
- This has been available for mainframes for a while now. You can boot
- several different OS at once on the same server. This is mainly used
- to isolate environments. For example, you can install the new version
- of an OS on the same server, even while the server is running the
- current version. This allows you to test and do a roll-out gracefully.
-
- The advantages of virtual machines are:
-
- * Total flexibility. You can run many different OS and different
- version of the same OS, all at once.
- * Robustness. You have total isolation. One OS may crash without
- affecting the other.
- * Resource management. You can effectively limit the resources taken
- by one OS.
- * Hardware Independence. The client OS is using virtual disks
- provided by the host OS.
-
- This technology is not directly available on PCs. The Intel x86
- architecture does not support visualization natively. Some products
- nevertheless have appeared and provide this. You can run Linux inside
- Linux, or this other OS (Which BTW has a logo showing a window flying
- in pieces, which quite frankly tells everything about it).
-
- The solutions available on PCs carry most of the advantages of the
- virtual machines found on mainframe, except for performance. You can't
- run that many virtual Linux's using this technology and expect it to
- fly. One example of this technology is [52]vmware, which is quite
- useful, especially if you must run this other OS... vmware may be used
- to run Linux inside Linux, even test Linux installation while running
- linux... NEW
-
-Partitioning
-
- Partitioning (domains ?) is a way to split the resources of a large
- server so you end up with independent servers. For example, you can
- take a 20 CPUs server and create 3 servers, two with 4 CPUs and one
- with 12. You can very easily re-assign CPUs to servers in case you
- need more for a given tasks.
-
- This technology provides full Independence, but much less flexibility.
- If your 12 CPUs server is not working much, the 4 CPUs one can't
- borrow some CPUs for 5 minutes. NEW
-
-Limitation of those technologies
-
- Oddly, one disadvantage of those technologies is a side effect of
- their major advantage: Total Independence. Each virtual server is
- running its own kernel. Cool. This makes the following tasks more
- difficult or impossible:
-
- * Sharing administrative tasks such as backup. The virtual servers
- are using volumes in the host server. The host server can't handle
- the files in those volumes directly without interfering with the
- client OS. It has to use some services of the client OS to access
- the file.
- The vserver solution does not have this limitation since the
- virtual servers are living in the same file-system, sharing the
- same kernel.
- * Task monitoring. The virtual servers run their own kernel. As
- such, the host OS can't spy on the tasks and check for intrusion
- for example.
- * Disk space. Virtual servers are using either volumes or full
- devices in the host server. This space is pre-allocated to the
- maximum needed by the server. You end up with a lot of wasted disk
- space. Imagine running 100 virtual servers this way and allocating
- say 10 gigs to each. You get the picture. The vserver solution is
- sharing a common file-system so the free disk space is available
- to all.
- Further, if you are running the same Linux distribution in the
- virtual servers, you can unify the disk space using hard link and
- immutable attributes. The /usr/lib/vserver/vunify was created to
- test that. Using information found in the rpm package the script
- links the files, except configuration ones.
- Testing vunify on a vserver installed with a RedHat 6.2
- distribution, unifying the packages glibc, binutils, perl, and
- bash saved 60 megs. Quite a few packages are not changing often
- and could be unified.
- Vservers do not need kernel packages and hardware configuration
- tools. This also contribute to save disk space.
- * File system sharing
- A little the same as above. You can't share file system easily
- between vservers unless you use network services (often slower).
- Using "mount --bind", it is very easy to "map" any directory of
- the root server in several vservers, providing raw speed access
- (and even sharing the disk cache).
-
- NEW
-
-Conclusion
-
- Virtual servers are interesting because they can provide a higher
- level of security while potentially reducing the administration task.
- Common operation such as backup, are shared between all servers.
- Services such as monitoring may be configured once.
-
- A Linux server can run many services at once with a high level of
- reliability. As servers are evolving, more and more services are
- added, often unrelated. Unfortunately there are few details here and
- there, making the server more complex than it is in reality. When one
- wants to move one service to another server, it is always a little
- pain: Some user accounts have to be moved and some configuration
- files. A lot of hand tweaking.
-
- By installing services in separate virtual servers, it becomes much
- easier to move services around (just by moving a directory although a
- big one).
-
- Virtual servers may become a preferred way to install common Linux
- servers. NEW
-
-Download
-
- The ftp site for this project is
- [53]ftp://ftp.solucorp.qc.ca/pub/vserver . You will find there the
- following components.
-
- * [54]kernel-2.4.20ctx-17.tar.gz
- [55]kernel-2.4.20ctxsmp-17.tar.gz
- A pre-compiled kernel for Pentium class machine and up. An SMP
- kernel is also supplied.
- * [56]vserver-0.22-1.src.rpm
- The source RPM for the vserver utilities
- * [57]vserver-0.22-1.i386.rpm
- A compiled rpm for RedHat 7.x and up. Should work on any recent
- distribution (glibc 2.2). You need a recent distribution to
- operate a kernel 2.4 anyway.
- * [58]vserver-admin-0.22-1.i386.rpm
- Contains the command /usr/sbin/newvserver. It is a GUI to create
- vservers. It requires the linuxconf-utils and linuxconf-lib
- packages. You can get them from [59]here. linuxconf itself is not
- needed though.
- * [60]vserver-0.22.src.tar.gz
- The vserver utilities source
- * [61]patch-2.4.20ctx-17.gz
- The patch against Linux 2.4.20
- * [62]patches
- The various relative patches (ctxN-ctxN+1)
-
- NEW
-
-References
-
- This project is maintained by Jacques Gelinas [63]jack@solucorp.qc.ca
-
- The vserver package is licensed under the GNU PUBLIC LICENSE.
-
- A FAQ can be found at
- [64]http://www.solucorp.qc.ca/howto.hc?projet=vserver
-
- A mailing list has been created to exchange about this project. It is
- [65]vserver@solucorp.qc.ca .You can subscribe [66]here
-
- The mailing list is archived [67]here.
-
- The change logs for the vserver package are [68]here .
-
- The official copy of this document is found at
- [69]http://www.solucorp.qc.ca/miscprj/s_context.hc
-
- This document was produced using the [70]TLMP documentation system
-
- [71]Top
- [72]Back to project page
- [73]About tlmpdoc and cookies
- Document maintained by Jacques Gélinas ([74]jack@solucorp.qc.ca)
- Last update: Wed Apr 16 11:22:22 2003
-
-Références
-
- 1. http://remtk/solucor/miscprj/s_context.hc?s1=1&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 2. http://remtk/solucor/miscprj/s_context.hc?s1=1&s2=1&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 3. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 4. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=1&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 5. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=2&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 6. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=3&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 7. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=4&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 8. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=5&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 9. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=6&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 10. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=6&s3=1&s4=0&full=0&prjstate=1&nodoc=0
- 11. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=6&s3=2&s4=0&full=0&prjstate=1&nodoc=0
- 12. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=6&s3=3&s4=0&full=0&prjstate=1&nodoc=0
- 13. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=6&s3=4&s4=0&full=0&prjstate=1&nodoc=0
- 14. http://remtk/solucor/miscprj/s_context.hc?s1=2&s2=7&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 15. http://remtk/solucor/miscprj/s_context.hc?s1=3&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 16. http://remtk/solucor/miscprj/s_context.hc?s1=3&s2=1&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 17. http://remtk/solucor/miscprj/s_context.hc?s1=3&s2=2&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 18. http://remtk/solucor/miscprj/s_context.hc?s1=3&s2=3&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 19. http://remtk/solucor/miscprj/s_context.hc?s1=3&s2=4&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 20. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 21. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=1&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 22. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=2&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 23. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=3&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 24. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=4&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 25. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=5&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 26. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=6&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 27. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=7&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 28. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=8&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 29. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=9&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 30. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=10&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 31. http://remtk/solucor/miscprj/s_context.hc?s1=4&s2=11&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 32. http://remtk/solucor/miscprj/s_context.hc?s1=5&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 33. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 34. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=1&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 35. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=2&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 36. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=2&s3=1&s4=0&full=0&prjstate=1&nodoc=0
- 37. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=2&s3=2&s4=0&full=0&prjstate=1&nodoc=0
- 38. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=2&s3=3&s4=0&full=0&prjstate=1&nodoc=0
- 39. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=2&s3=4&s4=0&full=0&prjstate=1&nodoc=0
- 40. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=2&s3=4&s4=1&full=0&prjstate=1&nodoc=0
- 41. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=2&s3=4&s4=2&full=0&prjstate=1&nodoc=0
- 42. http://remtk/solucor/miscprj/s_context.hc?s1=6&s2=2&s3=4&s4=3&full=0&prjstate=1&nodoc=0
- 43. http://remtk/solucor/miscprj/s_context.hc?s1=7&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 44. http://remtk/solucor/miscprj/s_context.hc?s1=7&s2=1&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 45. http://remtk/solucor/miscprj/s_context.hc?s1=7&s2=2&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 46. http://remtk/solucor/miscprj/s_context.hc?s1=7&s2=3&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 47. http://remtk/solucor/miscprj/s_context.hc?s1=8&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 48. http://remtk/solucor/miscprj/s_context.hc?s1=9&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 49. http://remtk/solucor/miscprj/s_context.hc?s1=10&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 50. ftp://ftp.solucorp.qc.ca/pub/vserver
- 51. http://www.solucorp.qc.ca/virtualfs
- 52. http://www.vmware.com/
- 53. ftp://ftp.solucorp.qc.ca/pub/vserver
- 54. ftp://ftp.solucorp.qc.ca/pub/vserver/kernel-2.4.20ctx-17.tar.gz
- 55. ftp://ftp.solucorp.qc.ca/pub/vserver/kernel-2.4.20ctxsmp-17.tar.gz
- 56. ftp://ftp.solucorp.qc.ca/pub/vserver/vserver-0.22-1.src.rpm
- 57. ftp://ftp.solucorp.qc.ca/pub/vserver/vserver-0.22-1.i386.rpm
- 58. ftp://ftp.solucorp.qc.ca/pub/vserver/vserver-admin-0.22-1.i386.rpm
- 59. http://www.solucorp.qc.ca/linuxconf/download.hc
- 60. ftp://ftp.solucorp.qc.ca/pub/vserver/vserver-0.22.src.tar.gz
- 61. ftp://ftp.solucorp.qc.ca/pub/vserver/patch-2.4.20ctx-17.gz
- 62. ftp://ftp.solucorp.qc.ca/pub/vserver/patches
- 63. mailto:jack@solucorp.qc.ca
- 64. http://www.solucorp.qc.ca/howto.hc?projet=vserver
- 65. mailto:vserver@solucorp.qc.ca
- 66. http://www.solucorp.qc.ca/mlist/index.hc?list=vserver
- 67. http://www.paul.sladen.org/vserver/archives/
- 68. http://www.solucorp.qc.ca/changes.hc?projet=vserver
- 69. http://www.solucorp.qc.ca/miscprj/s_context.hc
- 70. http://www.solucorp.qc.ca/tlmp
- 71. http://remtk/solucor/miscprj/s_context.hc?s1=0&s2=0&s3=0&s4=0&full=0&prjstate=1&nodoc=0
- 72. http://remtk/solucor/miscprj/s_context.hc
- 73. http://www.solucorp.qc.ca/tlmp/tlmpdoc.hc
- 74. mailto:jack@solucorp.qc.ca
+++ /dev/null
->=1
---
- * skipping of normal, non-unified files
- * general progress-messages
-
->=2
----
- * deunify/unify messages
- * skip-reason
- * more detailed progress-messages
-
->=3
---
- * skipping of already unified files
-
->=4
---
- * source of unification; when verbosity==4 -> vserver-id, else
- physical path
-
->=6
----
- * skipping of dirs and dotfiles
+++ /dev/null
-## $Id$ --*- makefile -*--
-
-## Copyright (C) 2004 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.
-
-noinst_HEADERS += ensc_wrappers/wrappers-clone.hc \
- ensc_wrappers/wrappers-dirent.hc \
- ensc_wrappers/wrappers-fcntl.hc \
- ensc_wrappers/wrappers-io.hc \
- ensc_wrappers/wrappers-ioctl.hc \
- ensc_wrappers/wrappers-iosock.hc \
- ensc_wrappers/wrappers-mount.hc \
- ensc_wrappers/wrappers-pivot.hc \
- ensc_wrappers/wrappers-resource.hc \
- ensc_wrappers/wrappers-socket.hc \
- ensc_wrappers/wrappers-stdlib.hc \
- ensc_wrappers/wrappers-string.hc \
- ensc_wrappers/wrappers-unistd.hc \
- ensc_wrappers/wrappers-vserver.hc \
- ensc_wrappers/wrappers-wait.hc \
- ensc_wrappers/wrappers.h \
- ensc_wrappers/wrappers_handler.hc
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL pid_t
-Eclone(int (*fn)(void *), void *child_stack, int flags, void *arg)
-{
- pid_t res;
-#ifndef __dietlibc__
- res = clone(fn, child_stack, flags, arg);
-#else
- res = clone((void*(*)(void*))(fn), child_stack, flags, arg);
-#endif
- FatalErrnoError(res==-1, "clone()");
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL DIR *
-Eopendir(const char *name)
-{
- DIR * res = opendir(name);
-
- FatalErrnoError(res==0, "opendir()");
- return res;
-}
-
-inline static WRAPPER_DECL struct dirent *
-Ereaddir(DIR *dir)
-{
- struct dirent *res;
-
- errno = 0;
- res = readdir(dir);
-
- FatalErrnoError(res==0 && errno!=0, "readdir()");
- return res;
-}
-
-#ifndef __dietlibc__
-inline static WRAPPER_DECL void
-Ereaddir_r(DIR *dir, struct dirent *entry, struct dirent **result)
-{
- errno = 0;
- FatalErrnoError(readdir_r(dir, entry, result)==0 && errno!=0, "readdir_r()");
-}
-#endif
-
-inline static WRAPPER_DECL void
-Eclosedir(DIR *dir)
-{
- FatalErrnoError(closedir(dir)==-1, "closedir()");
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL int
-Eopen(char const *fname, int flags, mode_t mode)
-{
- int res = open(fname, flags, mode);
- FatalErrnoError(res==-1, "open()");
-
- return res;
-}
-
-inline static WRAPPER_DECL int
-EopenD(char const *fname, int flags, mode_t mode)
-{
- ENSC_DETAIL1(msg, "open", fname, 1);
-
- {
- int res = open(fname, flags, mode);
- FatalErrnoError(res==-1, msg);
- return res;
- }
-}
-
-
-inline static WRAPPER_DECL void
-Emkdir(const char *pathname, mode_t mode)
-{
- FatalErrnoError(mkdir(pathname,mode)==-1, "mkdir()");
-}
-
-inline static WRAPPER_DECL void
-EmkdirD(const char *pathname, mode_t mode)
-{
- ENSC_DETAIL1(msg, "mkdir", pathname, 1);
- FatalErrnoError(mkdir(pathname,mode)==-1, msg);
-}
-
-inline static WRAPPER_DECL int
-Efcntl(int fd, int cmd, long arg)
-{
- register int res = fcntl(fd, cmd, arg);
- FatalErrnoError(res==-1, "fcntl()");
-
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-#include <stdbool.h>
-
-inline static UNUSED bool
-WwriteAll(int fd, void const *ptr_v, size_t len, int *err)
-{
- register char const *ptr = ptr_v;
-
- if (err) *err = 0;
-
- while (len>0) {
- ssize_t res = TEMP_FAILURE_RETRY(write(fd, ptr, len));
- if (res<=0) {
- if (err) *err = errno;
- return false;
- }
-
- ptr += res;
- len -= res;
- }
- return true;
-}
-
-inline static UNUSED void
-EwriteAll(int fd, void const *ptr_v, size_t len)
-{
- register char const *ptr = ptr_v;
-
- while (len>0) {
- size_t res = TEMP_FAILURE_RETRY(write(fd, ptr, len));
- FatalErrnoError(res==(size_t)-1, "write()");
-
- ptr += res;
- len -= res;
- }
-}
-
-
-inline static UNUSED bool
-WreadAll(int fd, void *ptr_v, size_t len, int *err)
-{
- register char *ptr = ptr_v;
-
- if (err) *err = 0;
-
- while (len>0) {
- ssize_t res = TEMP_FAILURE_RETRY(read(fd, ptr, len));
- if (res==-1) {
- if (err) *err = errno;
- return false;
- }
-
- if (res==0) return false;
-
- ptr += res;
- len -= res;
- }
- return true;
-}
-
-inline static UNUSED bool
-EreadAll(int fd, void *ptr_v, size_t len)
-{
- register char *ptr = ptr_v;
-
- while (len>0) {
- size_t res = TEMP_FAILURE_RETRY(read(fd, ptr, len));
- FatalErrnoError(res==(size_t)-1, "read()");
-
- if (res==0) return false;
-
- ptr += res;
- len -= res;
- }
-
- return true;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL void
-Eioctl(int fd, int request, void *p)
-{
- int res = ioctl(fd, request, p);
- FatalErrnoError(res<0, "ioctl()");
-}
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-#include <stdbool.h>
-
-inline static WRAPPER_DECL bool
-WsendAll(int fd, void const *ptr_v, size_t len, int *err)
-{
- register char const *ptr = ptr_v;
- if (err) *err = 0;
-
- while (len>0) {
- size_t res = TEMP_FAILURE_RETRY(send(fd, ptr, len, MSG_NOSIGNAL));
- if (res==(size_t)-1) {
- if (err) *err = errno;
- return false;
- }
-
- if (res==0) return false;
-
- ptr += res;
- len -= res;
- }
- return true;
-}
-
-inline static WRAPPER_DECL void
-EsendAll(int fd, void const *ptr_v, size_t len)
-{
- register char const *ptr = ptr_v;
-
- while (len>0) {
- size_t res = TEMP_FAILURE_RETRY(send(fd, ptr, len, MSG_NOSIGNAL));
- FatalErrnoError(res==(size_t)-1, "send()");
-
- ptr += res;
- len -= res;
- }
-}
-
-
-inline static WRAPPER_DECL bool
-WrecvAll(int fd, void *ptr_v, size_t len, int *err)
-{
- register char *ptr = ptr_v;
- if (err) *err = 0;
-
- while (len>0) {
- size_t res = TEMP_FAILURE_RETRY(recv(fd, ptr, len, MSG_NOSIGNAL));
- if (res==(size_t)-1) {
- if (err) *err = errno;
- return false;
- }
-
- if (res==0) return false;
-
- ptr += res;
- len -= res;
- }
- return true;
-}
-
-inline static WRAPPER_DECL bool
-ErecvAll(int fd, void *ptr_v, size_t len)
-{
- register char *ptr = ptr_v;
-
- while (len>0) {
- size_t res = TEMP_FAILURE_RETRY(recv(fd, ptr, len, MSG_NOSIGNAL));
- FatalErrnoError(res==(size_t)-1, "recv()");
-
- if (res==0) return false;
-
- ptr += res;
- len -= res;
- }
-
- return true;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL void
-Eumount2(char const *path, int flag)
-{
- FatalErrnoError(umount2(path,flag)==-1, "umount2()");
-}
-
-inline static WRAPPER_DECL void
-Emount(const char *source, const char *target,
- const char *filesystemtype, unsigned long mountflags,
- const void *data)
-{
- FatalErrnoError(mount(source, target, filesystemtype,
- mountflags, data)==-1, "mount()");
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL void
-Epivot_root(const char *new_root, const char *put_old)
-{
- FatalErrnoError(pivot_root(new_root, put_old)==-1, "pivot_root()");
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL void
-Egetrlimit(int resource, struct rlimit *rlim)
-{
- FatalErrnoError(getrlimit(resource, rlim)==-1, "getrlimit()");
-}
-
-inline static WRAPPER_DECL void
-Esetrlimit(int resource, struct rlimit const *rlim)
-{
- FatalErrnoError(setrlimit(resource, rlim)==-1, "setrlimit()");
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers-socket.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL int
-Esocket(int domain, int type, int protocol)
-{
- register int res = socket(domain, type, protocol);
- FatalErrnoError(res==-1, "socket()");
- return res;
-}
-
-inline static WRAPPER_DECL void
-Econnect(int sockfd, void const *serv_addr, socklen_t addrlen)
-{
- FatalErrnoError(connect(sockfd, serv_addr, addrlen)==-1, "connect()");
-}
-
-inline static WRAPPER_DECL void
-Ebind(int sockfd, void *my_addr, socklen_t addrlen)
-{
- FatalErrnoError(bind(sockfd, my_addr, addrlen)==-1, "bind()");
-}
-
-inline static WRAPPER_DECL int
-Eaccept(int s, void *addr, socklen_t *addrlen)
-{
- register int res = accept(s,addr,addrlen);
- FatalErrnoError(res==-1, "accept()");
- return res;
-}
-
-inline static WRAPPER_DECL void
-Elisten(int sock, int backlog)
-{
- FatalErrnoError(listen(sock, backlog)==-1, "bind()");
-}
-
-inline static WRAPPER_DECL void
-Eshutdown(int s, int how)
-{
- FatalErrnoError(shutdown(s,how)==-1, "shutdown()");
-}
-
-inline static WRAPPER_DECL ssize_t
-Erecv(int s, void *buf, size_t len, int flags)
-{
- register ssize_t res = recv(s,buf,len,flags);
- FatalErrnoError(res==-1, "recv()");
- return res;
-}
-
-inline static WRAPPER_DECL ssize_t
-Esend(int s, void const *buf, size_t len, int flags)
-{
- register ssize_t res = send(s,buf,len,flags);
- FatalErrnoError(res==-1, "send()");
- return res;
-}
-
-inline static WRAPPER_DECL int
-Eselect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- struct timeval *timeout)
-{
- register int res = select(n, readfds,writefds,exceptfds, timeout);
- FatalErrnoError(res==-1, "select()");
- return res;
-}
-
-inline static WRAPPER_DECL void
-Esocketpair(int d, int type, int protocol, int sv[2])
-{
- FatalErrnoError(socketpair(d,type,protocol,sv)==-1, "socketpair()");
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL void *
-Emalloc(size_t size)
-{
- register void *res = malloc(size);
- FatalErrnoError(res==0 && size!=0, "malloc()");
- return res;
-}
-
-/*@unused@*/
-inline static WRAPPER_DECL /*@null@*//*@only@*/ void *
-Erealloc(/*@only@*//*@out@*//*@null@*/ void *ptr,
- size_t new_size)
- /*@ensures maxSet(result) == new_size@*/
- /*@modifies *ptr@*/
-{
- register void *res = realloc(ptr, new_size);
- FatalErrnoError(res==0 && new_size!=0, "realloc()");
-
- return res;
-}
-
-inline static WRAPPER_DECL void
-Esetenv(char const *key, char const *val, int override)
-{
- FatalErrnoError(setenv(key,val,override)==-1, "setenv()");
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-/*@unused@*/
-inline static WRAPPER_DECL char *
-Estrdup(char const *s)
-{
- register char *res = strdup(s);
- FatalErrnoError(res==0, "strdup()");
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL void
-Eclose(int s)
-{
- FatalErrnoError(close(s)==-1, "close()");
-}
-
-inline static WRAPPER_DECL void
-Echdir(char const path[])
-{
- FatalErrnoError(chdir(path)==-1, "chdir()");
-}
-
-inline static WRAPPER_DECL void
-Efchdir(int fd)
-{
- FatalErrnoError(fchdir(fd)==-1, "fchdir()");
-}
-
-inline static WRAPPER_DECL void
-Echroot(char const path[])
-{
- FatalErrnoError(chroot(path)==-1, "chroot()");
-}
-
-inline static WRAPPER_DECL NORETURN void
-Eexecv(char const *path, char *argv[])
-{
- execv(path,argv);
- FatalErrnoErrorFail("execv()");
-}
-
-inline static WRAPPER_DECL NORETURN void
-Eexecvp(char const *path, char *argv[])
-{
- execvp(path,argv);
- FatalErrnoErrorFail("execvp()");
-}
-
-inline static WRAPPER_DECL NORETURN void
-EexecvpD(char const *path, char *argv[])
-{
- execvp(path,argv);
- {
- ENSC_DETAIL1(msg, "execvp", path, 1);
- FatalErrnoErrorFail(msg);
- }
-}
-
-inline static WRAPPER_DECL void
-Epipe(int filedes[2])
-{
- FatalErrnoError(pipe(filedes)==-1, "pipe()");
-}
-
-inline static WRAPPER_DECL pid_t
-Efork()
-{
- pid_t res;
- res = fork();
- FatalErrnoError(res==-1, "fork()");
- return res;
-}
-
-inline static WRAPPER_DECL size_t
-Eread(int fd, void *ptr, size_t len)
-{
- size_t res = read(fd, ptr, len);
- FatalErrnoError((ssize_t)(res)==-1, "read()");
-
- return res;
-}
-
-inline static WRAPPER_DECL size_t
-Ewrite(int fd, void const *ptr, size_t len)
-{
- size_t res = write(fd, ptr, len);
- FatalErrnoError((ssize_t)(res)==-1, "write()");
-
- return res;
-}
-
-inline static WRAPPER_DECL size_t
-Ereadlink(const char *path, char *buf, size_t bufsiz)
-{
- size_t res = readlink(path, buf, bufsiz);
- FatalErrnoError((ssize_t)(res)==-1, "readlink()");
-
- return res;
-}
-
-inline static WRAPPER_DECL size_t
-EreadlinkD(const char *path, char *buf, size_t bufsiz)
-{
- size_t res = readlink(path, buf, bufsiz);
- ENSC_DETAIL1(msg, "readlink", path, 1);
- FatalErrnoError((ssize_t)(res)==-1, msg);
-
- return res;
-}
-
-inline static WRAPPER_DECL void
-Esymlink(const char *oldpath, const char *newpath)
-{
- FatalErrnoError(symlink(oldpath, newpath)==-1, "symlink()");
-}
-
-inline static WRAPPER_DECL void
-EsymlinkD(const char *oldpath, const char *newpath)
-{
- ENSC_DETAIL2(msg, "symlink", oldpath, newpath, 1, 1);
- FatalErrnoError(symlink(oldpath, newpath)==-1, msg);
-}
-
-inline static WRAPPER_DECL void
-Eunlink(char const *pathname)
-{
- FatalErrnoError(unlink(pathname)==-1, "unlink()");
-}
-
-inline static void
-Esetuid(uid_t uid)
-{
- FatalErrnoError(setuid(uid)==-1, "setuid()");
-}
-
-inline static void
-Esetgid(gid_t gid)
-{
- FatalErrnoError(setgid(gid)==-1, "setgid()");
-}
-
-#if defined(_GRP_H) && (defined(__USE_BSD) || defined(__dietlibc__))
-inline static void
-Esetgroups(size_t size, const gid_t *list)
-{
- FatalErrnoError(setgroups(size, list)==-1, "setgroups()");
-}
-#endif
-
-inline static WRAPPER_DECL int
-Edup2(int oldfd, int newfd)
-{
- register int res = dup2(oldfd, newfd);
- FatalErrnoError(res==-1, "dup2()");
-
- return res;
-}
-
-inline static WRAPPER_DECL int
-Edup(int fd)
-{
- register int res = dup(fd);
- FatalErrnoError(res==-1, "dup()");
-
- return res;
-}
-
-inline static WRAPPER_DECL pid_t
-Esetsid()
-{
- register pid_t const res = setsid();
- FatalErrnoError(res==-1, "setsid()");
-
- return res;
-}
-
-inline static WRAPPER_DECL int
-Emkstemp(char *template)
-{
- int res = mkstemp(template);
- FatalErrnoError(res==-1, "mkstemp()");
- return res;
-}
-
-inline static WRAPPER_DECL off_t
-Elseek(int fildes, off_t offset, int whence)
-{
- off_t res = lseek(fildes, offset, whence);
- FatalErrnoError(res==(off_t)-1, "lseek()");
- return res;
-}
-
-inline static WRAPPER_DECL void
-Enice(int n)
-{
- FatalErrnoError(nice(n)==-1, "nice()");
-}
-
-inline static WRAPPER_DECL void
-Etruncate(const char *path, off_t length)
-{
- FatalErrnoError(truncate(path,length)==-1, "truncate()");
-}
-
-inline static WRAPPER_DECL void
-Eftruncate(int fd, off_t length)
-{
- FatalErrnoError(ftruncate(fd,length)==-1, "ftruncate()");
-}
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL xid_t
-Evc_new_s_context(xid_t ctx, unsigned int remove_cap, unsigned int flags)
-{
- register xid_t res = vc_new_s_context(ctx,remove_cap,flags);
- FatalErrnoError(res==VC_NOCTX, "vc_new_s_context()");
- return res;
-}
-
-inline static WRAPPER_DECL xid_t
-Evc_get_task_xid(pid_t pid)
-{
- register xid_t res = vc_get_task_xid(pid);
- FatalErrnoError(res==VC_NOCTX, "vc_get_task_xid()");
- return res;
-}
-
-inline static WRAPPER_DECL xid_t
-Evc_ctx_create(xid_t xid)
-{
- register xid_t res = vc_ctx_create(xid);
- FatalErrnoError(res==VC_NOCTX, "vc_ctx_create()");
- return res;
-}
-
-inline static WRAPPER_DECL void
-Evc_ctx_migrate(xid_t xid)
-{
- FatalErrnoError(vc_ctx_migrate(xid)==-1, "vc_ctx_migrate()");
-}
-
-inline static WRAPPER_DECL void
-Evc_get_cflags(xid_t xid, struct vc_ctx_flags *flags)
-{
- FatalErrnoError(vc_get_cflags(xid, flags)==-1, "vc_get_cflags()");
-}
-
-inline static WRAPPER_DECL void
-Evc_set_cflags(xid_t xid, struct vc_ctx_flags const *flags)
-{
- FatalErrnoError(vc_set_cflags(xid, flags)==-1, "vc_set_cflags()");
-}
-
-inline static WRAPPER_DECL void
-Evc_set_vhi_name(xid_t xid, vc_uts_type type,
- char const *val, size_t len)
-{
- FatalErrnoError(vc_set_vhi_name(xid,type,val,len)==-1, "vc_set_vhi_name()");
-}
-
-inline static WRAPPER_DECL void
-Evc_get_ccaps(xid_t xid, struct vc_ctx_caps *caps)
-{
- FatalErrnoError(vc_get_ccaps(xid, caps)==-1, "vc_get_ccaps()");
-}
-
-inline static WRAPPER_DECL void
-Evc_set_ccaps(xid_t xid, struct vc_ctx_caps const *caps)
-{
- FatalErrnoError(vc_set_ccaps(xid, caps)==-1, "vc_set_ccaps()");
-}
-
-inline static WRAPPER_DECL void
-Evc_set_namespace()
-{
- FatalErrnoError(vc_set_namespace()==-1, "vc_set_namespace()");
-}
-
-inline static WRAPPER_DECL void
-Evc_enter_namespace(xid_t xid)
-{
- FatalErrnoError(vc_enter_namespace(xid)==-1, "vc_enter_namespace()");
-}
-
-inline static WRAPPER_DECL xid_t
-Evc_xidopt2xid(char const *id, bool honor_static)
-{
- char const * err;
- xid_t rc = vc_xidopt2xid(id, honor_static, &err);
- if (__builtin_expect(rc==VC_NOCTX,0)) {
- ENSC_DETAIL1(msg, "vc_xidopt2xid", id, 1);
-#if 1
- FatalErrnoErrorFail(msg);
-#else
- {
- size_t l1 = strlen(msg);
- size_t l2 = strlen(err);
- char buf[l1 + l2 + sizeof(": ")];
- memcpy(buf, msg, l1);
- memcpy(buf+l1, ": ", 2);
- memcpy(buf+l1+2, err, l2+1);
-
- FatalErrnoErrorFail(buf);
- }
-#endif
- }
-
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-inline static WRAPPER_DECL pid_t
-Ewait4(pid_t pid, int *status, int options,
- struct rusage *rusage)
-{
- pid_t res;
- res = wait4(pid, status, options, rusage);
- FatalErrnoError(res==-1, "wait4()");
- return res;
-}
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2003,2004 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_SRC_WRAPPERS_H
-#define H_UTIL_VSERVER_SRC_WRAPPERS_H
-
-#define WRAPPER_DECL UNUSED ALWAYSINLINE
-#define H_ENSC_IN_WRAPPERS_H 1
-
-#include "wrappers_handler.hc"
-
-#define ENSC_DOQUOTE_COND(PTR, VAL, LEN, DO_QUOTE) \
- if (DO_QUOTE) *PTR++ = '"'; \
- memcpy(PTR, VAL, LEN); PTR += LEN; \
- if (DO_QUOTE) *PTR++ = '"' \
-
-#define ENSC_DETAIL1(RES,FUNC,VAL,DO_QUOTE) \
- size_t l_ = strlen(VAL); \
- char RES[l_ + sizeof(FUNC "(\"\")")]; \
- char * ptr_ = RES; \
- memcpy(ptr_, FUNC "(", sizeof(FUNC)); ptr_ += sizeof(FUNC); \
- ENSC_DOQUOTE_COND(ptr_, VAL, l_, DO_QUOTE); \
- *ptr_++ = ')'; \
- *ptr_ = '\0';
-
-#define ENSC_DETAIL2(RES,FUNC, VAL0,VAL1, DO_QUOTE0,DO_QUOTE1) \
- size_t l0_ = strlen(VAL0); \
- size_t l1_ = strlen(VAL1); \
- char RES[l0_ + l1_ + sizeof(FUNC "('','')")]; \
- char * ptr_ = RES; \
- memcpy(ptr_, FUNC "(", sizeof(FUNC)); ptr_ += sizeof(FUNC); \
- ENSC_DOQUOTE_COND(ptr_, VAL0, l0_, DO_QUOTE0); \
- *ptr_++ = ','; \
- ENSC_DOQUOTE_COND(ptr_, VAL1, l1_, DO_QUOTE1); \
- *ptr_++ = ')'; \
- *ptr_ = '\0';
-
-
-#ifdef ENSC_WRAPPERS_UNISTD
-# include "wrappers-unistd.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_FCNTL
-# include "wrappers-fcntl.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_MOUNT
-# include "wrappers-mount.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_RESOURCE
-# include "wrappers-resource.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_IOCTL
-# include "wrappers-ioctl.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_WAIT
-# include "wrappers-wait.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_VSERVER
-# include "wrappers-vserver.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_IO
-# include "wrappers-io.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_IOSOCK
-# include "wrappers-iosock.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_DIRENT
-# include "wrappers-dirent.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_CLONE
-# include "wrappers-clone.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_STDLIB
-# include "wrappers-stdlib.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_STRING
-# include "wrappers-string.hc"
-#endif
-
-#ifdef ENSC_WRAPPERS_SOCKET
-# include "wrappers-socket.hc"
-#endif
-
-#undef ENSC_DETAIL2
-#undef ENSC_DETAIL1
-#undef ENSC_DOQUOTE_COND
-#undef H_ENSC_IN_WRAPPERS_H
-#undef WRAPPER_DECL
-
-#endif // H_UTIL_VSERVER_SRC_WRAPPERS_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_ENSC_IN_WRAPPERS_H
-# error wrappers_handler.hc can not be used in this way
-#endif
-
-#include <stdlib.h>
-#include <stdbool.h>
-#include <stdio.h>
-
-static inline ALWAYSINLINE NORETURN void
-FatalErrnoErrorFail(char const msg[])
-{
- extern int wrapper_exit_code;
-
-#ifdef ENSC_WRAPPERS_PREFIX
- {
- int old_errno = errno;
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX);
- errno = old_errno;
- }
-#endif
- perror(msg);
-
- exit(wrapper_exit_code);
-}
-
-static UNUSED void
-FatalErrnoError(bool condition, char const msg[]) /*@*/
-{
- if (__builtin_expect(!condition,true)) return;
- FatalErrnoErrorFail(msg);
-}
+++ /dev/null
-#ifndef _VX_CONTEXT_H
-#define _VX_CONTEXT_H
-
-#include <linux/types.h>
-
-#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
-#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
-
-#define VX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
-
-#ifdef __KERNEL__
-
-#include <linux/list.h>
-#include <linux/spinlock.h>
-#include <linux/rcupdate.h>
-
-#define _VX_INFO_DEF_
-#include "cvirt.h"
-#include "limit.h"
-#include "sched.h"
-#undef _VX_INFO_DEF_
-
-struct vx_info {
- struct hlist_node vx_hlist; /* linked list of contexts */
- struct rcu_head vx_rcu; /* the rcu head */
- xid_t vx_id; /* context id */
- atomic_t vx_usecnt; /* usage count */
- atomic_t vx_refcnt; /* reference count */
- struct vx_info *vx_parent; /* parent context */
- int vx_state; /* context state */
-
- struct namespace *vx_namespace; /* private namespace */
- struct fs_struct *vx_fs; /* private namespace fs */
- uint64_t vx_flags; /* context flags */
- uint64_t vx_bcaps; /* bounding caps (system) */
- uint64_t vx_ccaps; /* context caps (vserver) */
-
- pid_t vx_initpid; /* PID of fake init process */
-
- spinlock_t vx_lock;
- wait_queue_head_t vx_exit; /* context exit waitqueue */
-
- struct _vx_limit limit; /* vserver limits */
- struct _vx_sched sched; /* vserver scheduler */
- struct _vx_cvirt cvirt; /* virtual/bias stuff */
- struct _vx_cacct cacct; /* context accounting */
-
- char vx_name[65]; /* vserver name */
-};
-
-/* status flags */
-
-#define VXS_HASHED 0x0001
-#define VXS_PAUSED 0x0010
-#define VXS_ONHOLD 0x0020
-#define VXS_SHUTDOWN 0x0100
-#define VXS_DEFUNCT 0x1000
-#define VXS_RELEASED 0x8000
-
-/* check conditions */
-
-#define VX_ADMIN 0x0001
-#define VX_WATCH 0x0002
-#define VX_DUMMY 0x0008
-
-#define VX_IDENT 0x0010
-#define VX_EQUIV 0x0020
-#define VX_PARENT 0x0040
-#define VX_CHILD 0x0080
-
-#define VX_ARG_MASK 0x00F0
-
-#define VX_DYNAMIC 0x0100
-#define VX_STATIC 0x0200
-
-#define VX_ATR_MASK 0x0F00
-
-
-struct rcu_head;
-
-// extern void rcu_free_vx_info(struct rcu_head *);
-extern void unhash_vx_info(struct vx_info *);
-
-extern struct vx_info *locate_vx_info(int);
-extern struct vx_info *locate_or_create_vx_info(int);
-
-extern int get_xid_list(int, unsigned int *, int);
-extern int vx_info_is_hashed(xid_t);
-
-extern int vx_migrate_task(struct task_struct *, struct vx_info *);
-
-#endif /* __KERNEL__ */
-
-#include "switch.h"
-
-/* vinfo commands */
-
-#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
-#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
-
-#ifdef __KERNEL__
-extern int vc_task_xid(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
-#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
-
-struct vcmd_vx_info_v0 {
- uint32_t xid;
- uint32_t initpid;
- /* more to come */
-};
-
-#ifdef __KERNEL__
-extern int vc_vx_info(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_ctx_create VC_CMD(VPROC, 1, 0)
-#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 0)
-
-#ifdef __KERNEL__
-extern int vc_ctx_create(uint32_t, void __user *);
-extern int vc_ctx_migrate(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
-#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
-
-struct vcmd_ctx_flags_v0 {
- uint64_t flagword;
- uint64_t mask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_cflags(uint32_t, void __user *);
-extern int vc_set_cflags(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VXF_INFO_LOCK 0x00000001
-#define VXF_INFO_SCHED 0x00000002
-#define VXF_INFO_NPROC 0x00000004
-#define VXF_INFO_PRIVATE 0x00000008
-
-#define VXF_INFO_INIT 0x00000010
-#define VXF_INFO_HIDE 0x00000020
-#define VXF_INFO_ULIMIT 0x00000040
-#define VXF_INFO_NSPACE 0x00000080
-
-#define VXF_SCHED_HARD 0x00000100
-#define VXF_SCHED_PRIO 0x00000200
-#define VXF_SCHED_PAUSE 0x00000400
-
-#define VXF_VIRT_MEM 0x00010000
-#define VXF_VIRT_UPTIME 0x00020000
-#define VXF_VIRT_CPU 0x00040000
-#define VXF_VIRT_LOAD 0x00080000
-
-#define VXF_HIDE_MOUNT 0x01000000
-#define VXF_HIDE_NETIF 0x02000000
-
-#define VXF_STATE_SETUP (1ULL<<32)
-#define VXF_STATE_INIT (1ULL<<33)
-
-#define VXF_FORK_RSS (1ULL<<48)
-#define VXF_PROLIFIC (1ULL<<49)
-
-#define VXF_IGNEG_NICE (1ULL<<52)
-
-#define VXF_ONE_TIME (0x0003ULL<<32)
-
-#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 0)
-#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 0)
-
-struct vcmd_ctx_caps_v0 {
- uint64_t bcaps;
- uint64_t ccaps;
- uint64_t cmask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_ccaps(uint32_t, void __user *);
-extern int vc_set_ccaps(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VXC_SET_UTSNAME 0x00000001
-#define VXC_SET_RLIMIT 0x00000002
-
-#define VXC_RAW_ICMP 0x00000100
-
-#define VXC_SECURE_MOUNT 0x00010000
-#define VXC_SECURE_REMOUNT 0x00020000
-
-
-#endif /* _VX_CONTEXT_H */
+++ /dev/null
-/* _VX_CVIRT_H defined below */
-
-#if defined(__KERNEL__) && defined(_VX_INFO_DEF_)
-
-#include <linux/utsname.h>
-#include <linux/rwsem.h>
-#include <linux/jiffies.h>
-#include <linux/time.h>
-#include <linux/sched.h>
-#include <linux/kernel_stat.h>
-#include <asm/atomic.h>
-
-/* context sub struct */
-
-struct _vx_cvirt {
- int max_threads; /* maximum allowed threads */
- atomic_t nr_threads; /* number of current threads */
- atomic_t nr_running; /* number of running threads */
-
- atomic_t nr_onhold; /* processes on hold */
- uint32_t onhold_last; /* jiffies when put on hold */
-
- struct timespec bias_idle;
- struct timespec bias_uptime; /* context creation point */
-
- struct new_utsname utsname;
-
- spinlock_t load_lock; /* lock for the load averages */
- uint32_t load_last; /* last time load was cacled */
- uint32_t load[3]; /* load averages 1,5,15 */
-
- struct cpu_usage_stat cpustat[NR_CPUS];
-};
-
-struct sock_acc {
- atomic_t count;
- atomic_t total;
-};
-
-struct _vx_cacct {
- unsigned long total_forks;
-
- struct sock_acc sock[5][3];
-};
-
-
-static inline long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
-{
- return atomic_read(&cacct->sock[type][pos].count);
-}
-
-
-static inline long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
-{
- return atomic_read(&cacct->sock[type][pos].total);
-}
-
-
-extern uint64_t vx_idle_jiffies(void);
-
-static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
-{
- uint64_t idle_jiffies = vx_idle_jiffies();
-
- do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
- jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
- atomic_set(&cvirt->nr_threads, 0);
- atomic_set(&cvirt->nr_running, 0);
- atomic_set(&cvirt->nr_onhold, 0);
-
- down_read(&uts_sem);
- cvirt->utsname = system_utsname;
- up_read(&uts_sem);
-
- spin_lock_init(&cvirt->load_lock);
- cvirt->load_last = jiffies;
- cvirt->load[0] = 0;
- cvirt->load[1] = 0;
- cvirt->load[2] = 0;
-}
-
-static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
-{
-#ifdef CONFIG_VSERVER_DEBUG
- int value;
-
- if ((value = atomic_read(&cvirt->nr_threads)))
- printk("!!! cvirt: %p[nr_threads] = %d on exit.\n",
- cvirt, value);
- if ((value = atomic_read(&cvirt->nr_running)))
- printk("!!! cvirt: %p[nr_running] = %d on exit.\n",
- cvirt, value);
-#endif
- return;
-}
-
-static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
-{
- int i,j;
-
- for (i=0; i<5; i++) {
- for (j=0; j<3; j++) {
- atomic_set(&cacct->sock[i][j].count, 0);
- atomic_set(&cacct->sock[i][j].total, 0);
- }
- }
-}
-
-static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
-{
- return;
-}
-
-#define LOAD_INT(x) ((x) >> FSHIFT)
-#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
-
-
-static inline int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
-{
- int length = 0;
- int a, b, c;
-
- length += sprintf(buffer + length,
- "BiasUptime:\t%lu.%02lu\n",
- (unsigned long)cvirt->bias_uptime.tv_sec,
- (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
- length += sprintf(buffer + length,
- "SysName:\t%.*s\n"
- "NodeName:\t%.*s\n"
- "Release:\t%.*s\n"
- "Version:\t%.*s\n"
- "Machine:\t%.*s\n"
- "DomainName:\t%.*s\n"
- ,__NEW_UTS_LEN, cvirt->utsname.sysname
- ,__NEW_UTS_LEN, cvirt->utsname.nodename
- ,__NEW_UTS_LEN, cvirt->utsname.release
- ,__NEW_UTS_LEN, cvirt->utsname.version
- ,__NEW_UTS_LEN, cvirt->utsname.machine
- ,__NEW_UTS_LEN, cvirt->utsname.domainname
- );
-
- a = cvirt->load[0] + (FIXED_1/200);
- b = cvirt->load[1] + (FIXED_1/200);
- c = cvirt->load[2] + (FIXED_1/200);
- length += sprintf(buffer + length,
- "nr_threads:\t%d\n"
- "nr_running:\t%d\n"
- "nr_onhold:\t%d\n"
- "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
- ,atomic_read(&cvirt->nr_threads)
- ,atomic_read(&cvirt->nr_running)
- ,atomic_read(&cvirt->nr_onhold)
- ,LOAD_INT(a), LOAD_FRAC(a)
- ,LOAD_INT(b), LOAD_FRAC(b)
- ,LOAD_INT(c), LOAD_FRAC(c)
- );
- return length;
-}
-
-static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
-{
- int i,j, length = 0;
- static char *type[] = { "UNSPEC", "UNIX", "INET", "INET6", "OTHER" };
-
- for (i=0; i<5; i++) {
- length += sprintf(buffer + length,
- "%s:", type[i]);
- for (j=0; j<3; j++) {
- length += sprintf(buffer + length,
- "\t%12lu/%-12lu"
- ,vx_sock_count(cacct, i, j)
- ,vx_sock_total(cacct, i, j)
- );
- }
- buffer[length++] = '\n';
- }
- length += sprintf(buffer + length,
- "forks:\t%lu\n", cacct->total_forks);
- return length;
-}
-
-#else /* _VX_INFO_DEF_ */
-#ifndef _VX_CVIRT_H
-#define _VX_CVIRT_H
-
-#include "switch.h"
-
-/* cvirt vserver commands */
-
-
-#ifdef __KERNEL__
-
-struct timespec;
-
-void vx_vsi_uptime(struct timespec *, struct timespec *);
-
-struct vx_info;
-
-void vx_update_load(struct vx_info *);
-
-
-#endif /* __KERNEL__ */
-
-#endif /* _VX_CVIRT_H */
-#endif
+++ /dev/null
-#ifndef _VX_DEBUG_H
-#define _VX_DEBUG_H
-
-
-#define VXD_CBIT(n,m) (vx_debug_ ## n & (1 << (m)))
-#define VXD_CMIN(n,m) (vx_debug_ ## n > (m))
-#define VXD_MASK(n,m) (vx_debug_ ## n & (m))
-
-#define VXD_QPOS(v,p) (((uint32_t)(v) >> ((p)*8)) & 0xFF)
-#define VXD_QUAD(v) VXD_QPOS(v,0), VXD_QPOS(v,1), \
- VXD_QPOS(v,2), VXD_QPOS(v,3)
-
-// #define VXD_HERE __FILE__, __LINE__
-
-#define __FUNC__ __func__
-
-
-#ifdef CONFIG_VSERVER_DEBUG
-
-extern unsigned int vx_debug_switch;
-extern unsigned int vx_debug_xid;
-extern unsigned int vx_debug_nid;
-extern unsigned int vx_debug_net;
-extern unsigned int vx_debug_limit;
-extern unsigned int vx_debug_dlim;
-extern unsigned int vx_debug_cvirt;
-
-
-#define VX_LOGLEVEL "vxD: "
-
-#define vxdprintk(c,f,x...) \
- do { \
- if (c) \
- printk(VX_LOGLEVEL f "\n", x); \
- } while (0)
-
-#define vxlprintk(c,f,x...) \
- do { \
- if (c) \
- printk(VX_LOGLEVEL f " @%s:%d\n", x); \
- } while (0)
-
-#define vxfprintk(c,f,x...) \
- do { \
- if (c) \
- printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
- } while (0)
-
-#else
-
-#define vx_debug_switch 0
-#define vx_debug_xid 0
-#define vx_debug_nid 0
-#define vx_debug_net 0
-#define vx_debug_limit 0
-#define vx_debug_dlim 0
-#define vx_debug_cvirt 0
-
-#define vxdprintk(x...) do { } while (0)
-#define vxlprintk(x...) do { } while (0)
-#define vxfprintk(x...) do { } while (0)
-
-#endif
-
-
-
-#endif /* _VX_DEBUG_H */
+++ /dev/null
-#ifndef _VX_DLIMIT_H
-#define _VX_DLIMIT_H
-
-#include "switch.h"
-#include <linux/spinlock.h>
-
-/* inode vserver commands */
-
-#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
-#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
-
-#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
-#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
-
-
-struct vcmd_ctx_dlimit_base_v0 {
- const char __user *name;
- uint32_t flags;
-};
-
-struct vcmd_ctx_dlimit_v0 {
- const char __user *name;
- uint32_t space_used; /* used space in kbytes */
- uint32_t space_total; /* maximum space in kbytes */
- uint32_t inodes_used; /* used inodes */
- uint32_t inodes_total; /* maximum inodes */
- uint32_t reserved; /* reserved for root in % */
- uint32_t flags;
-};
-
-#define CDLIM_UNSET (0ULL)
-#define CDLIM_INFINITY (~0ULL)
-#define CDLIM_KEEP (~1ULL)
-
-
-#ifdef __KERNEL__
-
-struct super_block;
-
-struct dl_info {
- struct hlist_node dl_hlist; /* linked list of contexts */
- struct rcu_head dl_rcu; /* the rcu head */
- xid_t dl_xid; /* context id */
- atomic_t dl_usecnt; /* usage count */
- atomic_t dl_refcnt; /* reference count */
-
- struct super_block *dl_sb; /* associated superblock */
-
-// struct rw_semaphore dl_sem; /* protect the values */
- spinlock_t dl_lock; /* protect the values */
-
- uint64_t dl_space_used; /* used space in bytes */
- uint64_t dl_space_total; /* maximum space in bytes */
- uint32_t dl_inodes_used; /* used inodes */
- uint32_t dl_inodes_total; /* maximum inodes */
-
- unsigned int dl_nrlmult; /* non root limit mult */
-};
-
-struct rcu_head;
-
-extern void rcu_free_dl_info(struct rcu_head *);
-extern void unhash_dl_info(struct dl_info *);
-
-extern struct dl_info *locate_dl_info(struct super_block *, xid_t);
-
-
-struct kstatfs;
-
-extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
-
-
-extern int vc_add_dlimit(uint32_t, void __user *);
-extern int vc_rem_dlimit(uint32_t, void __user *);
-
-extern int vc_set_dlimit(uint32_t, void __user *);
-extern int vc_get_dlimit(uint32_t, void __user *);
-
-
-typedef uint64_t dlsize_t;
-
-
-#endif /* __KERNEL__ */
-
-#endif /* _VX_DLIMIT_H */
+++ /dev/null
-#ifndef _VX_INODE_H
-#define _VX_INODE_H
-
-#include "switch.h"
-
-/* inode vserver commands */
-
-#define VCMD_get_iattr_v0 VC_CMD(INODE, 1, 0)
-#define VCMD_set_iattr_v0 VC_CMD(INODE, 2, 0)
-
-#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
-#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
-
-struct vcmd_ctx_iattr_v0 {
- /* device handle in id */
- uint64_t ino;
- uint32_t xid;
- uint32_t flags;
- uint32_t mask;
-};
-
-struct vcmd_ctx_iattr_v1 {
- const char __user *name;
- uint32_t xid;
- uint32_t flags;
- uint32_t mask;
-};
-
-
-#define IATTR_XID 0x01000000
-
-#define IATTR_ADMIN 0x00000001
-#define IATTR_WATCH 0x00000002
-#define IATTR_HIDE 0x00000004
-#define IATTR_FLAGS 0x00000007
-
-#define IATTR_BARRIER 0x00010000
-#define IATTR_IUNLINK 0x00020000
-#define IATTR_IMMUTABLE 0x00040000
-
-
-#ifdef CONFIG_VSERVER_PROC_SECURE
-#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
-#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
-#else
-#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
-#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
-#endif
-
-#ifdef __KERNEL__
-
-#define vx_hide_check(c,m) (((m) & IATTR_HIDE) ? vx_check(c,m) : 1)
-
-extern int vc_get_iattr_v0(uint32_t, void __user *);
-extern int vc_set_iattr_v0(uint32_t, void __user *);
-
-extern int vc_get_iattr(uint32_t, void __user *);
-extern int vc_set_iattr(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-/* inode ioctls */
-
-#define FIOC_GETXFLG _IOR('x', 5, long)
-#define FIOC_SETXFLG _IOW('x', 6, long)
-
-#endif /* _VX_INODE_H */
+++ /dev/null
-#ifndef _VX_LEGACY_H
-#define _VX_LEGACY_H
-
-#include "switch.h"
-#include "network.h"
-
-/* compatibiliy vserver commands */
-
-#define VCMD_new_s_context VC_CMD(COMPAT, 1, 1)
-#define VCMD_set_ipv4root VC_CMD(COMPAT, 2, 3)
-
-#define VCMD_create_context VC_CMD(VSETUP, 1, 0)
-
-/* compatibiliy vserver arguments */
-
-struct vcmd_new_s_context_v1 {
- uint32_t remove_cap;
- uint32_t flags;
-};
-
-struct vcmd_set_ipv4root_v3 {
- /* number of pairs in id */
- uint32_t broadcast;
- struct {
- uint32_t ip;
- uint32_t mask;
- } nx_mask_pair[NB_IPV4ROOT];
-};
-
-
-#define VX_INFO_LOCK 1 /* Can't request a new vx_id */
-#define VX_INFO_NPROC 4 /* Limit number of processes in a context */
-#define VX_INFO_PRIVATE 8 /* Noone can join this security context */
-#define VX_INFO_INIT 16 /* This process wants to become the */
- /* logical process 1 of the security */
- /* context */
-#define VX_INFO_HIDEINFO 32 /* Hide some information in /proc */
-#define VX_INFO_ULIMIT 64 /* Use ulimit of the current process */
- /* to become the global limits */
- /* of the context */
-#define VX_INFO_NAMESPACE 128 /* save private namespace */
-
-
-#define NB_S_CONTEXT 16
-
-#define NB_IPV4ROOT 16
-
-
-#ifdef __KERNEL__
-extern int vc_new_s_context(uint32_t, void __user *);
-extern int vc_set_ipv4root(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-#endif /* _VX_LEGACY_H */
+++ /dev/null
-/* _VX_LIMIT_H defined below */
-
-#if defined(__KERNEL__) && defined(_VX_INFO_DEF_)
-
-#include <asm/atomic.h>
-#include <asm/resource.h>
-
-/* context sub struct */
-
-#define NUM_LIMITS 20
-
-#define VLIMIT_NSOCK 16
-
-
-extern const char *vlimit_name[NUM_LIMITS];
-
-struct _vx_limit {
- atomic_t ticks;
-
- unsigned long rlim[NUM_LIMITS]; /* Context limit */
- unsigned long rmax[NUM_LIMITS]; /* Context maximum */
- atomic_t rcur[NUM_LIMITS]; /* Current value */
- atomic_t lhit[NUM_LIMITS]; /* Limit hits */
-};
-
-static inline void vx_info_init_limit(struct _vx_limit *limit)
-{
- int lim;
-
- for (lim=0; lim<NUM_LIMITS; lim++) {
- limit->rlim[lim] = RLIM_INFINITY;
- limit->rmax[lim] = 0;
- atomic_set(&limit->rcur[lim], 0);
- atomic_set(&limit->lhit[lim], 0);
- }
-}
-
-static inline void vx_info_exit_limit(struct _vx_limit *limit)
-{
-#ifdef CONFIG_VSERVER_DEBUG
- unsigned long value;
- unsigned int lim;
-
- for (lim=0; lim<NUM_LIMITS; lim++) {
- value = atomic_read(&limit->rcur[lim]);
- if (value)
- printk("!!! limit: %p[%s,%d] = %ld on exit.\n",
- limit, vlimit_name[lim], lim, value);
- }
-#endif
-}
-
-static inline void vx_limit_fixup(struct _vx_limit *limit)
-{
- unsigned long value;
- unsigned int lim;
-
- for (lim=0; lim<NUM_LIMITS; lim++) {
- value = atomic_read(&limit->rcur[lim]);
- if (value > limit->rmax[lim])
- limit->rmax[lim] = value;
- if (limit->rmax[lim] > limit->rlim[lim])
- limit->rmax[lim] = limit->rlim[lim];
- }
-}
-
-#define VX_LIMIT_FMT ":\t%10d\t%10ld\t%10ld\t%6d\n"
-
-#define VX_LIMIT_ARG(r) \
- ,atomic_read(&limit->rcur[r]) \
- ,limit->rmax[r] \
- ,limit->rlim[r] \
- ,atomic_read(&limit->lhit[r])
-
-static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
-{
- vx_limit_fixup(limit);
- return sprintf(buffer,
- "PROC" VX_LIMIT_FMT
- "VM" VX_LIMIT_FMT
- "VML" VX_LIMIT_FMT
- "RSS" VX_LIMIT_FMT
- "FILES" VX_LIMIT_FMT
- "SOCK" VX_LIMIT_FMT
- VX_LIMIT_ARG(RLIMIT_NPROC)
- VX_LIMIT_ARG(RLIMIT_AS)
- VX_LIMIT_ARG(RLIMIT_MEMLOCK)
- VX_LIMIT_ARG(RLIMIT_RSS)
- VX_LIMIT_ARG(RLIMIT_NOFILE)
- VX_LIMIT_ARG(VLIMIT_NSOCK)
- );
-}
-
-#else /* _VX_INFO_DEF_ */
-#ifndef _VX_LIMIT_H
-#define _VX_LIMIT_H
-
-#include "switch.h"
-
-#define VXD_RLIMIT(r,l) (VXD_CBIT(limit, (l)) && ((r) == (l)))
-
-/* rlimit vserver commands */
-
-#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
-#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
-#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
-
-struct vcmd_ctx_rlimit_v0 {
- uint32_t id;
- uint64_t minimum;
- uint64_t softlimit;
- uint64_t maximum;
-};
-
-struct vcmd_ctx_rlimit_mask_v0 {
- uint32_t minimum;
- uint32_t softlimit;
- uint32_t maximum;
-};
-
-#define CRLIM_UNSET (0ULL)
-#define CRLIM_INFINITY (~0ULL)
-#define CRLIM_KEEP (~1ULL)
-
-#ifdef __KERNEL__
-
-#include <linux/compiler.h>
-
-extern int vc_get_rlimit(uint32_t, void __user *);
-extern int vc_set_rlimit(uint32_t, void __user *);
-extern int vc_get_rlimit_mask(uint32_t, void __user *);
-
-struct sysinfo;
-
-void vx_vsi_meminfo(struct sysinfo *);
-void vx_vsi_swapinfo(struct sysinfo *);
-
-
-#endif /* __KERNEL__ */
-
-#endif /* _VX_LIMIT_H */
-#endif
-
-
+++ /dev/null
-#ifndef _VX_NAMESPACE_H
-#define _VX_NAMESPACE_H
-
-#include <linux/types.h>
-
-
-/* virtual host info names */
-
-#define VCMD_vx_set_vhi_name VC_CMD(VHOST, 1, 0)
-#define VCMD_vx_get_vhi_name VC_CMD(VHOST, 2, 0)
-
-struct vcmd_vx_vhi_name_v0 {
- uint32_t field;
- char name[65];
-};
-
-
-enum vx_vhi_name_field {
- VHIN_CONTEXT=0,
- VHIN_SYSNAME,
- VHIN_NODENAME,
- VHIN_RELEASE,
- VHIN_VERSION,
- VHIN_MACHINE,
- VHIN_DOMAINNAME,
-};
-
-
-#ifdef __KERNEL__
-
-#include <linux/compiler.h>
-
-extern int vc_set_vhi_name(uint32_t, void __user *);
-extern int vc_get_vhi_name(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_enter_namespace VC_CMD(PROCALT, 1, 0)
-#define VCMD_cleanup_namespace VC_CMD(PROCALT, 2, 0)
-#define VCMD_set_namespace VC_CMD(PROCALT, 3, 0)
-
-#ifdef __KERNEL__
-
-struct vx_info;
-struct namespace;
-struct fs_struct;
-struct vfsmount;
-
-extern int vx_check_vfsmount(struct vx_info *, struct vfsmount *);
-
-extern int vx_set_namespace(struct vx_info *, struct namespace *, struct fs_struct *);
-
-extern int vc_enter_namespace(uint32_t, void __user *);
-extern int vc_cleanup_namespace(uint32_t, void __user *);
-extern int vc_set_namespace(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-#endif /* _VX_NAMESPACE_H */
+++ /dev/null
-#ifndef _VX_NETWORK_H
-#define _VX_NETWORK_H
-
-#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
-
-#define NX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
-
-#define NB_IPV4ROOT 16
-
-#ifdef __KERNEL__
-
-#include <linux/list.h>
-#include <linux/spinlock.h>
-#include <linux/utsname.h>
-#include <linux/rcupdate.h>
-#include <asm/resource.h>
-#include <asm/atomic.h>
-
-
-struct nx_info {
- struct hlist_node nx_hlist; /* linked list of nxinfos */
- struct rcu_head nx_rcu; /* the rcu head */
- nid_t nx_id; /* vnet id */
- atomic_t nx_usecnt; /* usage count */
- atomic_t nx_refcnt; /* reference count */
-
- uint64_t nx_flags; /* network flag word */
- uint64_t nx_ncaps; /* network capabilities */
-
- int nbipv4;
- __u32 ipv4[NB_IPV4ROOT]; /* Process can only bind to these IPs */
- /* The first one is used to connect */
- /* and for bind any service */
- /* The other must be used explicity */
- __u32 mask[NB_IPV4ROOT]; /* Netmask for each ipv4 */
- /* Used to select the proper source */
- /* address for sockets */
- __u32 v4_bcast; /* Broadcast address to receive UDP */
-
- char nx_name[65]; /* network context name */
-};
-
-
-struct rcu_head;
-
-extern void rcu_free_nx_info(struct rcu_head *);
-extern void unhash_nx_info(struct nx_info *);
-
-extern struct nx_info *locate_nx_info(int);
-extern struct nx_info *locate_or_create_nx_info(int);
-
-extern int get_nid_list(int, unsigned int *, int);
-extern int nx_info_is_hashed(nid_t);
-
-extern int nx_migrate_task(struct task_struct *, struct nx_info *);
-
-struct in_ifaddr;
-struct net_device;
-
-int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
-int dev_in_nx_info(struct net_device *, struct nx_info *);
-
-struct sock;
-
-int nx_addr_conflict(struct nx_info *, uint32_t, struct sock *);
-
-
-#endif /* __KERNEL__ */
-
-#include "switch.h"
-
-/* vinfo commands */
-
-#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
-
-#ifdef __KERNEL__
-extern int vc_task_nid(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
-
-struct vcmd_nx_info_v0 {
- uint32_t nid;
- /* more to come */
-};
-
-#ifdef __KERNEL__
-extern int vc_nx_info(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_net_create VC_CMD(VNET, 1, 0)
-#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
-
-#define VCMD_net_add VC_CMD(NETALT, 1, 0)
-#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
-
-struct vcmd_net_nx_v0 {
- uint16_t type;
- uint16_t count;
- uint32_t ip[4];
- uint32_t mask[4];
- /* more to come */
-};
-
-// IPN_TYPE_IPV4
-
-
-#ifdef __KERNEL__
-extern int vc_net_create(uint32_t, void __user *);
-extern int vc_net_migrate(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
-#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
-
-struct vcmd_net_flags_v0 {
- uint64_t flagword;
- uint64_t mask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_nflags(uint32_t, void __user *);
-extern int vc_set_nflags(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define IPF_STATE_SETUP (1ULL<<32)
-
-
-#define IPF_ONE_TIME (0x0001ULL<<32)
-
-#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
-#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
-
-struct vcmd_net_caps_v0 {
- uint64_t ncaps;
- uint64_t cmask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_ncaps(uint32_t, void __user *);
-extern int vc_set_ncaps(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define IPC_WOSSNAME 0x00000001
-
-
-#endif /* _VX_NETWORK_H */
+++ /dev/null
-/* _VX_SCHED_H defined below */
-
-#if defined(__KERNEL__) && defined(_VX_INFO_DEF_)
-
-#include <linux/spinlock.h>
-#include <linux/jiffies.h>
-#include <linux/cpumask.h>
-#include <asm/atomic.h>
-#include <asm/param.h>
-
-struct _vx_ticks {
- uint64_t user_ticks; /* token tick events */
- uint64_t sys_ticks; /* token tick events */
- uint64_t hold_ticks; /* token ticks paused */
- uint64_t unused[5]; /* cacheline ? */
-};
-
-/* context sub struct */
-
-struct _vx_sched {
- atomic_t tokens; /* number of CPU tokens */
- spinlock_t tokens_lock; /* lock for token bucket */
-
- int fill_rate; /* Fill rate: add X tokens... */
- int interval; /* Divisor: per Y jiffies */
- int tokens_min; /* Limit: minimum for unhold */
- int tokens_max; /* Limit: no more than N tokens */
- uint32_t jiffies; /* last time accounted */
-
- int priority_bias; /* bias offset for priority */
- cpumask_t cpus_allowed; /* cpu mask for context */
-
- struct _vx_ticks cpu[NR_CPUS];
-};
-
-static inline void vx_info_init_sched(struct _vx_sched *sched)
-{
- int i;
-
- /* scheduling; hard code starting values as constants */
- sched->fill_rate = 1;
- sched->interval = 4;
- sched->tokens_min = HZ >> 4;
- sched->tokens_max = HZ >> 1;
- sched->jiffies = jiffies;
- sched->tokens_lock = SPIN_LOCK_UNLOCKED;
-
- atomic_set(&sched->tokens, HZ >> 2);
- sched->cpus_allowed = CPU_MASK_ALL;
- sched->priority_bias = 0;
-
- for_each_cpu(i) {
- sched->cpu[i].user_ticks = 0;
- sched->cpu[i].sys_ticks = 0;
- sched->cpu[i].hold_ticks = 0;
- }
-}
-
-static inline void vx_info_exit_sched(struct _vx_sched *sched)
-{
- return;
-}
-
-static inline int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
-{
- int length = 0;
- int i;
-
- length += sprintf(buffer,
- "Token:\t\t%8d\n"
- "FillRate:\t%8d\n"
- "Interval:\t%8d\n"
- "TokensMin:\t%8d\n"
- "TokensMax:\t%8d\n"
- "PrioBias:\t%8d\n"
- ,atomic_read(&sched->tokens)
- ,sched->fill_rate
- ,sched->interval
- ,sched->tokens_min
- ,sched->tokens_max
- ,sched->priority_bias
- );
-
- for_each_online_cpu(i) {
- length += sprintf(buffer + length,
- "cpu %d: %lld %lld %lld\n"
- ,i
- ,sched->cpu[i].user_ticks
- ,sched->cpu[i].sys_ticks
- ,sched->cpu[i].hold_ticks
- );
- }
-
- return length;
-}
-
-
-#else /* _VX_INFO_DEF_ */
-#ifndef _VX_SCHED_H
-#define _VX_SCHED_H
-
-#include "switch.h"
-
-/* sched vserver commands */
-
-#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
-#define VCMD_set_sched VC_CMD(SCHED, 1, 3)
-
-struct vcmd_set_sched_v2 {
- int32_t fill_rate;
- int32_t interval;
- int32_t tokens;
- int32_t tokens_min;
- int32_t tokens_max;
- uint64_t cpu_mask;
-};
-
-struct vcmd_set_sched_v3 {
- uint32_t set_mask;
- int32_t fill_rate;
- int32_t interval;
- int32_t tokens;
- int32_t tokens_min;
- int32_t tokens_max;
- int32_t priority_bias;
-};
-
-
-#define VXSM_FILL_RATE 0x0001
-#define VXSM_INTERVAL 0x0002
-#define VXSM_TOKENS 0x0010
-#define VXSM_TOKENS_MIN 0x0020
-#define VXSM_TOKENS_MAX 0x0040
-#define VXSM_PRIO_BIAS 0x0100
-
-#define SCHED_KEEP (-2)
-
-#ifdef __KERNEL__
-
-extern int vc_set_sched_v1(uint32_t, void __user *);
-extern int vc_set_sched_v2(uint32_t, void __user *);
-extern int vc_set_sched(uint32_t, void __user *);
-
-
-#define VAVAVOOM_RATIO 50
-
-#define MAX_PRIO_BIAS 20
-#define MIN_PRIO_BIAS -20
-
-#include "context.h"
-
-
-/* scheduling stuff */
-
-int effective_vavavoom(struct task_struct *, int);
-
-int vx_tokens_recalc(struct vx_info *);
-
-/* new stuff ;) */
-
-static inline int vx_tokens_avail(struct vx_info *vxi)
-{
- return atomic_read(&vxi->sched.tokens);
-}
-
-static inline void vx_consume_token(struct vx_info *vxi)
-{
- atomic_dec(&vxi->sched.tokens);
-}
-
-static inline int vx_need_resched(struct task_struct *p)
-{
-#ifdef CONFIG_VSERVER_HARDCPU
- struct vx_info *vxi = p->vx_info;
-#endif
- int slice = --p->time_slice;
-
-#ifdef CONFIG_VSERVER_HARDCPU
- if (vxi) {
- int tokens;
-
- if ((tokens = vx_tokens_avail(vxi)) > 0)
- vx_consume_token(vxi);
- /* for tokens > 0, one token was consumed */
- if (tokens < 2)
- return 1;
- }
-#endif
- return (slice == 0);
-}
-
-
-static inline void vx_onhold_inc(struct vx_info *vxi)
-{
- int onhold = atomic_read(&vxi->cvirt.nr_onhold);
-
- atomic_inc(&vxi->cvirt.nr_onhold);
- if (!onhold)
- vxi->cvirt.onhold_last = jiffies;
-}
-
-static inline void __vx_onhold_update(struct vx_info *vxi)
-{
- int cpu = smp_processor_id();
- uint32_t now = jiffies;
- uint32_t delta = now - vxi->cvirt.onhold_last;
-
- vxi->cvirt.onhold_last = now;
- vxi->sched.cpu[cpu].hold_ticks += delta;
-}
-
-static inline void vx_onhold_dec(struct vx_info *vxi)
-{
- if (atomic_dec_and_test(&vxi->cvirt.nr_onhold))
- __vx_onhold_update(vxi);
-}
-
-#endif /* __KERNEL__ */
-
-#endif /* _VX_SCHED_H */
-#endif
+++ /dev/null
-#ifndef _VX_SIGNAL_H
-#define _VX_SIGNAL_H
-
-#include "switch.h"
-
-/* context signalling */
-
-#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
-#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
-
-struct vcmd_ctx_kill_v0 {
- int32_t pid;
- int32_t sig;
-};
-
-struct vcmd_wait_exit_v0 {
- int32_t a;
- int32_t b;
-};
-
-#ifdef __KERNEL__
-
-extern int vc_ctx_kill(uint32_t, void __user *);
-extern int vc_wait_exit(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-#endif /* _VX_SIGNAL_H */
+++ /dev/null
-#ifndef _VX_SWITCH_H
-#define _VX_SWITCH_H
-
-#include <linux/types.h>
-
-#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
-#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
-#define VC_VERSION(c) ((c) & 0xFFF)
-
-#define VC_CMD(c,i,v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
- | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
-
-/*
-
- Syscall Matrix V2.8
-
- |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
- |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
- |INFO |SETUP | |MOVE | | | | | |
- -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
- SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICES| |
- HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
- -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
- CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
- PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
- -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
- MEMORY | | | | | | | |SWAP | |
- | 16| 17| 18| 19| 20| 21| | 22| 23|
- -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
- NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
- | 24| 25| 26| 27| 28| 29| | 30| 31|
- -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
- DISK | | | | |DLIMIT | | |INODE | |
- VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
- -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
- OTHER | | | | | | | |VINFO | |
- | 40| 41| 42| 43| 44| 45| | 46| 47|
- =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
- SPECIAL|EVENT | | | |FLAGS | | | | |
- | 48| 49| 50| 51| 52| 53| | 54| 55|
- -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
- SPECIAL| | | | |RLIMIT |SYSCALL| | |COMPAT |
- | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
- -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
-
-*/
-
-#define VC_CAT_VERSION 0
-
-#define VC_CAT_VSETUP 1
-#define VC_CAT_VHOST 2
-
-#define VC_CAT_VPROC 9
-#define VC_CAT_PROCALT 10
-#define VC_CAT_PROCMIG 11
-#define VC_CAT_PROCTRL 12
-
-#define VC_CAT_SCHED 14
-
-#define VC_CAT_VNET 25
-#define VC_CAT_NETALT 26
-#define VC_CAT_NETMIG 27
-#define VC_CAT_NETCTRL 28
-
-#define VC_CAT_DLIMIT 36
-#define VC_CAT_INODE 38
-
-#define VC_CAT_VINFO 46
-#define VC_CAT_EVENT 48
-
-#define VC_CAT_FLAGS 52
-#define VC_CAT_RLIMIT 60
-
-#define VC_CAT_SYSTEST 61
-#define VC_CAT_COMPAT 63
-
-/* interface version */
-
-#define VCI_VERSION 0x00010022
-
-
-/* query version */
-
-#define VCMD_get_version VC_CMD(VERSION, 0, 0)
-
-
-#ifdef __KERNEL__
-
-#include <linux/errno.h>
-
-
-#else /* __KERNEL__ */
-#define __user
-#endif /* __KERNEL__ */
-
-#endif /* _VX_SWITCH_H */
+++ /dev/null
-#ifndef _VX_XID_H
-#define _VX_XID_H
-
-
-#define XID_TAG(in) (!(in) || \
- (((struct inode *)in)->i_sb && \
- (((struct inode *)in)->i_sb->s_flags & MS_TAGXID)))
-
-
-#ifdef CONFIG_INOXID_NONE
-
-#define MAX_UID 0xFFFFFFFF
-#define MAX_GID 0xFFFFFFFF
-
-#define INOXID_XID(tag, uid, gid, xid) (0)
-
-#define XIDINO_UID(tag, uid, xid) (uid)
-#define XIDINO_GID(tag, gid, xid) (gid)
-
-#endif
-
-
-#ifdef CONFIG_INOXID_GID16
-
-#define MAX_UID 0xFFFFFFFF
-#define MAX_GID 0x0000FFFF
-
-#define INOXID_XID(tag, uid, gid, xid) \
- ((tag) ? (((gid) >> 16) & 0xFFFF) : 0)
-
-#define XIDINO_UID(tag, uid, xid) (uid)
-#define XIDINO_GID(tag, gid, xid) \
- ((tag) ? (((gid) & 0xFFFF) | ((xid) << 16)) : (gid))
-
-#endif
-
-
-#ifdef CONFIG_INOXID_UGID24
-
-#define MAX_UID 0x00FFFFFF
-#define MAX_GID 0x00FFFFFF
-
-#define INOXID_XID(tag, uid, gid, xid) \
- ((tag) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
-
-#define XIDINO_UID(tag, uid, xid) \
- ((tag) ? (((uid) & 0xFFFFFF) | (((xid) & 0xFF00) << 16)) : (uid))
-#define XIDINO_GID(tag, gid, xid) \
- ((tag) ? (((gid) & 0xFFFFFF) | (((xid) & 0x00FF) << 24)) : (gid))
-
-#endif
-
-
-#ifdef CONFIG_INOXID_UID16
-
-#define MAX_UID 0x0000FFFF
-#define MAX_GID 0xFFFFFFFF
-
-#define INOXID_XID(tag, uid, gid, xid) \
- ((tag) ? ((uid) >> 16) & 0xFFFF) : 0)
-
-#define XIDINO_UID(tag, uid, xid) \
- ((tag) ? (((uid) & 0xFFFF) | ((xid) << 16)) : (uid))
-#define XIDINO_GID(tag, gid, xid) (gid)
-
-#endif
-
-
-#ifdef CONFIG_INOXID_INTERN
-
-#define MAX_UID 0xFFFFFFFF
-#define MAX_GID 0xFFFFFFFF
-
-#define INOXID_XID(tag, uid, gid, xid) \
- ((tag) ? (xid) : 0)
-
-#define XIDINO_UID(tag, uid, xid) (uid)
-#define XIDINO_GID(tag, gid, xid) (gid)
-
-#endif
-
-
-#ifdef CONFIG_INOXID_RUNTIME
-
-#define MAX_UID 0xFFFFFFFF
-#define MAX_GID 0xFFFFFFFF
-
-#define INOXID_XID(tag, uid, gid, xid) (0)
-
-#define XIDINO_UID(tag, uid, xid) (uid)
-#define XIDINO_GID(tag, gid, xid) (gid)
-
-#endif
-
-
-#define INOXID_UID(tag, uid, gid) \
- ((tag) ? ((uid) & MAX_UID) : (uid))
-#define INOXID_GID(tag, uid, gid) \
- ((tag) ? ((gid) & MAX_GID) : (gid))
-
-
-static inline uid_t vx_map_uid(uid_t uid)
-{
- if ((uid > MAX_UID) && (uid != -1))
- uid = -2;
- return (uid & MAX_UID);
-}
-
-static inline gid_t vx_map_gid(gid_t gid)
-{
- if ((gid > MAX_GID) && (gid != -1))
- gid = -2;
- return (gid & MAX_GID);
-}
-
-
-#ifdef CONFIG_VSERVER_LEGACY
-#define FIOC_GETXID _IOR('x', 1, long)
-#define FIOC_SETXID _IOW('x', 2, long)
-#define FIOC_SETXIDJ _IOW('x', 3, long)
-#endif
-
-#endif /* _VX_XID_H */
+++ /dev/null
-*.la
-*.lo
-.buexcl
-.deps
-.dirstamp
-.libs
-util-vserver.pc
+++ /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; either version 2, or (at your option)
-## any later version.
-##
-## 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.
-##
-
-lib_VERSION = 0.0.0
-
-lib_compat_SRCS = lib/cflags-compat.c \
- lib/cflags_list-compat.c
-lib_legacy_SRCS = lib/getprocentry-legacy.c
-lib_management_SRCS = lib/createskeleton.c \
- lib/getvserverbyctx.c \
- lib/getvserverbyctx-compat.hc \
- lib/getvserverbyctx-v13.hc \
- lib/getvservercfgstyle.c \
- lib/getvserverappdir.c \
- lib/getvservercfgdir.c \
- lib/getvserverctx.c \
- lib/getvservername.c \
- lib/getvservervdir.c \
- lib/xidopt2xid.c
-lib_v11_SRCS = lib/syscall_rlimit.c \
- lib/syscall_rlimit-v11.hc \
- lib/syscall_kill.c \
- lib/syscall_kill-v11.hc
-lib_v13_SRCS = lib/syscall_ctxcreate.c \
- lib/syscall_ctxcreate-v13.hc \
- lib/syscall_ctxmigrate.c \
- lib/syscall_ctxmigrate-v13.hc \
- lib/syscall_cleanupnamespace-v13.hc \
- lib/syscall_cleanupnamespace.c \
- lib/syscall_enternamespace-v13.hc \
- lib/syscall_enternamespace.c \
- lib/syscall_getccaps-v13.hc \
- lib/syscall_getccaps.c \
- lib/syscall_getcflags-v13.hc \
- lib/syscall_getcflags.c \
- lib/syscall_getiattr-fscompat.hc \
- lib/syscall_getiattr-v13.hc \
- lib/syscall_getiattr.c \
- lib/syscall_getncaps-net.hc \
- lib/syscall_getncaps.c \
- lib/syscall_getnflags-net.hc \
- lib/syscall_getnflags.c \
- lib/syscall_getnxinfo-net.hc \
- lib/syscall_getnxinfo.c \
- lib/syscall_gettasknid-net.hc \
- lib/syscall_gettasknid.c \
- lib/syscall_gettaskxid-oldproc.hc \
- lib/syscall_gettaskxid-v13.hc \
- lib/syscall_gettaskxid.c \
- lib/syscall_getvhiname-olduts.hc \
- lib/syscall_getvhiname-v13.hc \
- lib/syscall_getvhiname.c \
- lib/syscall_getvxinfo-oldproc.hc \
- lib/syscall_getvxinfo-v13.hc \
- lib/syscall_getvxinfo.c \
- lib/syscall_netadd-net.hc \
- lib/syscall_netadd.c \
- lib/syscall_netcreate-net.hc \
- lib/syscall_netcreate.c \
- lib/syscall_netmigrate-net.hc \
- lib/syscall_netmigrate.c \
- lib/syscall_netremove-net.hc \
- lib/syscall_netremove.c \
- lib/syscall_setccaps-v13.hc \
- lib/syscall_setccaps.c \
- lib/syscall_setcflags-v13.hc \
- lib/syscall_setcflags.c \
- lib/syscall_setiattr-fscompat.hc \
- lib/syscall_setiattr-v13.hc \
- lib/syscall_setiattr.c \
- lib/syscall_setnamespace-v13.hc \
- lib/syscall_setnamespace.c \
- lib/syscall_setncaps-net.hc \
- lib/syscall_setncaps.c \
- lib/syscall_setnflags-net.hc \
- lib/syscall_setnflags.c \
- lib/syscall_setsched-v13.hc \
- lib/syscall_setsched.c \
- lib/syscall_setvhiname-olduts.hc \
- lib/syscall_setvhiname-v13.hc \
- lib/syscall_setvhiname.c \
- lib/bcaps-v13.c \
- lib/bcaps_list-v13.c \
- lib/ccaps-v13.c \
- lib/ccaps_list-v13.c \
- lib/cflags-v13.c \
- lib/cflags_list-v13.c \
- lib/ncaps-net.c \
- lib/ncaps_list-net.c \
- lib/nflags-net.c \
- lib/nflags_list-net.c
-
-if ENSC_HAVE_C99_COMPILER
-lib_v13_SRCS += lib/syscall_adddlimit-v13.hc \
- lib/syscall_adddlimit.c \
- lib/syscall_getdlimit-v13.hc \
- lib/syscall_getdlimit.c \
- lib/syscall_remdlimit-v13.hc \
- lib/syscall_remdlimit.c \
- lib/syscall_setdlimit-v13.hc \
- lib/syscall_setdlimit.c
-endif
-
-PKGCONFIG_FILES = lib/util-vserver
-
-lib_SRCS = lib/syscall.c \
- lib/checkversion.c \
- lib/isdirectory.c \
- lib/isfile.c \
- lib/islink.c \
- lib/getnbipv4root.c \
- lib/getversion.c \
- lib/capabilities.c \
- lib/getfilecontext.c \
- lib/getinsecurebcaps.c \
- lib/getxidtype.c \
- lib/isdynamicxid.c \
- lib/issupported.c \
- lib/issupportedstring.c \
- lib/listparser_uint32.c \
- lib/listparser_uint64.c \
- lib/syscall-syscall.c \
- lib/val2text-t2v-uint32.c \
- lib/val2text-t2v-uint64.c \
- lib/val2text-v2t-uint32.c \
- lib/val2text-v2t-uint64.c \
- lib/parselimit.c \
- $(lib_legacy_SRCS) \
- $(lib_compat_SRCS) \
- $(lib_management_SRCS) \
- $(lib_v11_SRCS) \
- $(lib_v13_SRCS) \
- $(ensc_fmt_SRCS)
-
-include_HEADERS += lib/vserver.h
-
-noinst_HEADERS += lib/syscall-compat.hc \
- lib/syscall-legacy.hc \
- lib/createskeleton-full.hc \
- lib/createskeleton-short.hc \
- lib/fmt.h \
- lib/getversion-internal.hc \
- lib/safechroot-internal.hc \
- lib/ioctl-getext2flags.hc \
- lib/ioctl-getfilecontext.hc \
- lib/ioctl-setext2flags.hc \
- lib/ioctl-setfilecontext.hc \
- lib/ioctl-getxflg.hc \
- lib/ioctl-setxflg.hc \
- lib/ext2fs.h \
- lib/listparser.hc \
- lib/val2text.hc \
- lib/virtual.h \
- lib/internal.h \
- lib/utils-legacy.h \
- lib/vserver-internal.h
-
-LIBVSERVER_GLIBC = lib/libvserver.la
-lib_LTLIBRARIES += $(LIBVSERVER_GLIBC)
-
-if USE_DIETLIBC
-LIBVSERVER_DIET = lib/libvserver.a
-LIBVSERVER = $(LIBVSERVER_DIET)
-lib_LIBRARIES += $(LIBVSERVER_DIET)
-else
-LIBVSERVER_DIET = lib-dietlibc-not-enabled-error.a
-LIBVSERVER = lib/libvserver.la
-endif
-
-lib_libvserver_la_SOURCES = $(lib_SRCS)
-lib_libvserver_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIB_DEBUG_CPPFLAGS)
-lib_libvserver_la_LDFLAGS = -version $(lib_VERSION)
-
-lib_libvserver_a_SOURCES = $(lib_SRCS)
-lib_libvserver_a_CPPFLAGS = $(AM_CPPFLAGS) $(LIB_DEBUG_CPPFLAGS)
-
-DIETPROGS += lib/lib_libvserver_a-%
-
-CLEANFILES += lib/libvserver.la \
- lib/libvserver.a
-
-include $(srcdir)/lib/apidoc/Makefile-files
-include $(srcdir)/lib/testsuite/Makefile-files
+++ /dev/null
-.apidoc
-Doxyfile
-html
-latex
-man
+++ /dev/null
-# Doxyfile 1.3.6
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME = "@PACKAGE@ (libvserver)"
-PROJECT_NUMBER = @PACKAGE_VERSION@
-OUTPUT_DIRECTORY =
-OUTPUT_LANGUAGE = English
-USE_WINDOWS_ENCODING = NO
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-ABBREVIATE_BRIEF =
-ALWAYS_DETAILED_SEC = NO
-INLINE_INHERITED_MEMB = NO
-FULL_PATH_NAMES = NO
-STRIP_FROM_PATH =
-SHORT_NAMES = NO
-JAVADOC_AUTOBRIEF = NO
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP = NO
-INHERIT_DOCS = YES
-DISTRIBUTE_GROUP_DOC = NO
-TAB_SIZE = 8
-ALIASES =
-OPTIMIZE_OUTPUT_FOR_C = YES
-OPTIMIZE_OUTPUT_JAVA = NO
-SUBGROUPING = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL = NO
-EXTRACT_PRIVATE = YES
-EXTRACT_STATIC = NO
-EXTRACT_LOCAL_CLASSES = YES
-HIDE_UNDOC_MEMBERS = NO
-HIDE_UNDOC_CLASSES = NO
-HIDE_FRIEND_COMPOUNDS = NO
-HIDE_IN_BODY_DOCS = NO
-INTERNAL_DOCS = NO
-CASE_SENSE_NAMES = YES
-HIDE_SCOPE_NAMES = NO
-SHOW_INCLUDE_FILES = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = YES
-SORT_BRIEF_DOCS = NO
-SORT_BY_SCOPE_NAME = NO
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = YES
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-SHOW_USED_FILES = YES
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = YES
-WARN_IF_DOC_ERROR = YES
-WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT = @top_srcdir@/lib
-FILE_PATTERNS = vserver.h \
- internal.h
-RECURSIVE = NO
-EXCLUDE =
-EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS =
-EXAMPLE_PATH = @top_srcdir@/lib/apidoc
-EXAMPLE_PATTERNS =
-EXAMPLE_RECURSIVE = NO
-IMAGE_PATH =
-INPUT_FILTER =
-FILTER_SOURCE_FILES = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER = YES
-INLINE_SOURCES = NO
-STRIP_CODE_COMMENTS = YES
-REFERENCED_BY_RELATION = YES
-REFERENCES_RELATION = YES
-VERBATIM_HEADERS = YES
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = NO
-COLS_IN_ALPHA_INDEX = 5
-IGNORE_PREFIX =
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML = YES
-HTML_OUTPUT = html
-HTML_FILE_EXTENSION = .html
-HTML_HEADER =
-HTML_FOOTER =
-HTML_STYLESHEET =
-HTML_ALIGN_MEMBERS = YES
-GENERATE_HTMLHELP = NO
-CHM_FILE =
-HHC_LOCATION =
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = NO
-ENUM_VALUES_PER_LINE = 4
-GENERATE_TREEVIEW = NO
-TREEVIEW_WIDTH = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX = YES
-LATEX_OUTPUT = latex
-LATEX_CMD_NAME = latex
-MAKEINDEX_CMD_NAME = makeindex
-COMPACT_LATEX = YES
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = YES
-USE_PDFLATEX = YES
-LATEX_BATCHMODE = YES
-LATEX_HIDE_INDICES = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN = YES
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = YES
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML = NO
-XML_OUTPUT = xml
-XML_SCHEMA =
-XML_DTD =
-XML_PROGRAMLISTING = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD = NO
-PERLMOD_LATEX = NO
-PERLMOD_PRETTY = YES
-PERLMOD_MAKEVAR_PREFIX =
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = YES
-EXPAND_ONLY_PREDEF = NO
-SEARCH_INCLUDES = YES
-INCLUDE_PATH =
-INCLUDE_FILE_PATTERNS =
-PREDEFINED = VC_ATTR_UNUSED= \
- VC_ATTR_NONNULL(X)= \
- VC_ATTR_NORETURN= \
- VC_ATTR_ALWAYSINLINE= \
- VC_ATTR_PURE= \
- IS_DOXYGEN=1
-EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-TAGFILES =
-GENERATE_TAGFILE =
-ALLEXTERNALS = NO
-EXTERNAL_GROUPS = YES
-PERL_PATH = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = YES
-HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = YES
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-UML_LOOK = YES
-TEMPLATE_RELATIONS = NO
-INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = YES
-CALL_GRAPH = YES
-GRAPHICAL_HIERARCHY = YES
-DOT_IMAGE_FORMAT = png
-DOT_PATH =
-DOTFILE_DIRS =
-MAX_DOT_GRAPH_WIDTH = 1024
-MAX_DOT_GRAPH_HEIGHT = 1024
-MAX_DOT_GRAPH_DEPTH = 0
-GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
-DOT_TRANSPARENT = YES
-DOT_MULTI_TARGETS = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-SEARCHENGINE = NO
+++ /dev/null
-## $Id$ --*- makefile -*--
-
-## Copyright (C) 2004 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.
-
-CLEANFILES += lib/apidoc/.apidoc
-EXTRA_DIST += lib/apidoc/list2xxx.syntax
-
-doc: lib/apidoc/.apidoc
-clean-local: clean_lib_apidoc
-
-clean_lib_apidoc:
- -rm -rf lib/apidoc/html lib/apidoc/latex lib/apidoc/man
-
-lib/apidoc/.apidoc: lib/apidoc/Doxyfile lib/vserver.h lib/internal.h
- -rm -rf lib/apidoc/html lib/apidoc/latex lib/apidoc/man
- cd "$$(dirname '$<')" && $(DOXYGEN) "$$(basename '$<')"
- $(MAKE) -j1 -C lib/apidoc/latex
- touch '$@'
+++ /dev/null
-When the \c `~' prefix is used, the bits will be unset, and the \c `^'
-prefix specifies a bitnumber instead of a bitmask. A `~' after another
-`~' will cancel both ones. The special values for \c NAME will be
-recognized case insensitively.
+++ /dev/null
-LIST <- ELEM | ELEM ',' LIST
-ELEM <- '~' ELEM | MASK | NAME
-MASK <- NUMBER | '^' NUMBER
-NUMBER <- 0[0-7]* | [1-9][0-9]* | 0x[0-9,a-f]+
-NAME <- <literal name> | "all" | "any" | "none"
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-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 "vserver.h"
-#include "internal.h"
-#include <lib_internal/util-dimof.h>
-#include <linux/capability.h>
-
-#include <string.h>
-#include <strings.h>
-#include <assert.h>
-
-#ifndef CAP_QUOTACTL
-# define CAP_QUOTACTL VC_CAP_QUOTACTL
-#endif
-
-#define DECL(VAL) { #VAL, sizeof(#VAL)-1, 1 << (CAP_ ## VAL) }
-
-static struct Mapping_uint64 const VALUES[] = {
- DECL(CHOWN),
- DECL(DAC_OVERRIDE),
- DECL(DAC_READ_SEARCH),
- DECL(FOWNER),
- DECL(FSETID),
- DECL(KILL),
- DECL(SETGID),
- DECL(SETUID),
- DECL(SETPCAP),
- DECL(LINUX_IMMUTABLE),
- DECL(NET_BIND_SERVICE),
- DECL(NET_BROADCAST),
- DECL(NET_ADMIN),
- DECL(NET_RAW),
- DECL(IPC_LOCK),
- DECL(IPC_OWNER),
- DECL(SYS_MODULE),
- DECL(SYS_RAWIO),
- DECL(SYS_CHROOT),
- DECL(SYS_PTRACE),
- DECL(SYS_PACCT),
- DECL(SYS_ADMIN),
- DECL(SYS_BOOT),
- DECL(SYS_NICE),
- DECL(SYS_RESOURCE),
- DECL(SYS_TIME),
- DECL(SYS_TTY_CONFIG),
- DECL(MKNOD),
- DECL(LEASE),
- DECL(QUOTACTL),
-};
-
-inline static char const *
-removePrefix(char const *str, size_t *len)
-{
- if ((len==0 || *len==0 || *len>4) &&
- strncasecmp("cap_", str, 4)==0) {
- if (len && *len>4) *len -= 4;
- return str+4;
- }
- else
- return str;
-}
-
-uint_least64_t
-vc_text2bcap(char const *str, size_t len)
-{
- char const * tmp = removePrefix(str, &len);
- ssize_t idx = utilvserver_value2text_uint64(tmp, len,
- VALUES, DIM_OF(VALUES));
- if (idx==-1) return 0;
- else return VALUES[idx].val;
-}
-
-char const *
-vc_lobcap2text(uint_least64_t *val)
-{
- ssize_t idx = utilvserver_text2value_uint64(val,
- VALUES, DIM_OF(VALUES));
-
- if (idx==-1) return 0;
- else return VALUES[idx].id;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <>
-//
-// 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 "vserver.h"
-#include "internal.h"
-
-#include <string.h>
-
-int
-vc_list2bcap(char const *str, size_t len,
- struct vc_err_listparser *err,
- struct vc_ctx_caps *caps)
-{
- return utilvserver_listparser_uint64(str, len,
- err ? &err->ptr : 0,
- err ? &err->len : 0,
- &caps->bcaps, &caps->bmask,
- vc_text2bcap);
-}
+++ /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 "vserver.h"
-#include <string.h>
-
-#if 1
-# define DECLARECAP(X,Y) { #X, VC_##X }
-#else
-# define DECLARECAP(X,Y) { #X, Y }
-#endif
-
-static struct {
- char const * const id;
- unsigned char bit;
-} const CAP2BIT[] = {
- DECLARECAP(CAP_CHOWN, 0),
- DECLARECAP(CAP_DAC_OVERRIDE, 1),
- DECLARECAP(CAP_DAC_READ_SEARCH, 2),
- DECLARECAP(CAP_FOWNER, 3),
- DECLARECAP(CAP_FSETID, 4),
- DECLARECAP(CAP_KILL, 5),
- DECLARECAP(CAP_SETGID, 6),
- DECLARECAP(CAP_SETUID, 7),
- DECLARECAP(CAP_SETPCAP, 8),
- DECLARECAP(CAP_LINUX_IMMUTABLE, 9),
- DECLARECAP(CAP_NET_BIND_SERVICE, 10),
- DECLARECAP(CAP_NET_BROADCAST, 11),
- DECLARECAP(CAP_NET_ADMIN, 12),
- DECLARECAP(CAP_NET_RAW, 13),
- DECLARECAP(CAP_IPC_LOCK, 14),
- DECLARECAP(CAP_IPC_OWNER, 15),
- DECLARECAP(CAP_SYS_MODULE, 16),
- DECLARECAP(CAP_SYS_RAWIO, 17),
- DECLARECAP(CAP_SYS_CHROOT, 18),
- DECLARECAP(CAP_SYS_PTRACE, 19),
- DECLARECAP(CAP_SYS_PACCT, 20),
- DECLARECAP(CAP_SYS_ADMIN, 21),
- DECLARECAP(CAP_SYS_BOOT, 22),
- DECLARECAP(CAP_SYS_NICE, 23),
- DECLARECAP(CAP_SYS_RESOURCE, 24),
- DECLARECAP(CAP_SYS_TIME, 25),
- DECLARECAP(CAP_SYS_TTY_CONFIG, 26),
- DECLARECAP(CAP_MKNOD, 27),
- DECLARECAP(CAP_LEASE, 28),
- DECLARECAP(CAP_QUOTACTL, 29),
-};
-
-int
-vc_text2cap(char const *str)
-{
- size_t i;
- if (strncmp(str, "CAP_", 4)==0) str += 4;
-
- for (i=0; i<sizeof(CAP2BIT)/sizeof(CAP2BIT[0]); ++i)
- if (strcmp(CAP2BIT[i].id+4, str)==0) return CAP2BIT[i].bit;
-
- return -1;
-}
-
-char const *
-vc_cap2text(unsigned int bit)
-{
- if ((size_t)bit>=sizeof(CAP2BIT)/sizeof(CAP2BIT[0])) return 0;
- return CAP2BIT[bit].id;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-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 "vserver.h"
-#include "internal.h"
-#include <lib_internal/util-dimof.h>
-
-#include <string.h>
-#include <assert.h>
-
-#define DECL(STR, VAL) { STR, sizeof(STR)-1, VAL }
-
-static struct Mapping_uint64 const VALUES[] = {
- DECL("utsname", VC_VXC_SET_UTSNAME),
- DECL("rlimit", VC_VXC_SET_RLIMIT),
- DECL("icmp", VC_VXC_RAW_ICMP),
- DECL("mount", VC_VXC_SECURE_MOUNT),
- DECL("remount", VC_VXC_SECURE_REMOUNT),
- // some deprecated values...
- DECL("ping", VC_VXC_RAW_ICMP),
-};
-
-uint_least64_t
-vc_text2ccap(char const *str, size_t len)
-{
- ssize_t idx = utilvserver_value2text_uint64(str, len,
- VALUES, DIM_OF(VALUES));
- if (idx==-1) return 0;
- else return VALUES[idx].val;
-}
-
-char const *
-vc_loccap2text(uint_least64_t *val)
-{
- ssize_t idx = utilvserver_text2value_uint64(val,
- VALUES, DIM_OF(VALUES));
-
- if (idx==-1) return 0;
- else return VALUES[idx].id;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <>
-//
-// 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 "vserver.h"
-#include "internal.h"
-
-#include <string.h>
-
-int
-vc_list2ccap(char const *str, size_t len,
- struct vc_err_listparser *err,
- struct vc_ctx_caps *caps)
-{
- return utilvserver_listparser_uint64(str, len,
- err ? &err->ptr : 0,
- err ? &err->len : 0,
- &caps->ccaps, &caps->cmask,
- vc_text2ccap);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-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 "vserver.h"
-#include <string.h>
-#include <assert.h>
-
-#define DECL(STR, VAL) { STR, sizeof(STR)-1, VAL }
-
-static struct {
- char const * const id;
- size_t len;
- unsigned char val;
-} const FLAGVALUES[] = {
- DECL("lock", S_CTX_INFO_LOCK),
- DECL("sched", S_CTX_INFO_SCHED),
- DECL("nproc", S_CTX_INFO_NPROC),
- DECL("private", S_CTX_INFO_PRIVATE),
- DECL("fakeinit", S_CTX_INFO_INIT),
- DECL("hideinfo", S_CTX_INFO_HIDEINFO),
- DECL("ulimit", S_CTX_INFO_ULIMIT),
- DECL("namespace", S_CTX_INFO_NAMESPACE),
-};
-
-uint_least32_t
-vc_text2cflag_compat(char const *str, size_t len)
-{
- size_t i;
- if (len==0) len=strlen(str);
-
- for (i=0; i<sizeof(FLAGVALUES)/sizeof(FLAGVALUES[0]); ++i)
- if (len==FLAGVALUES[i].len &&
- strncmp(FLAGVALUES[i].id, str, len)==0)
- return FLAGVALUES[i].val;
-
- return 0;
-}
-
-char const *
-vc_hicflag2text_compat(uint_least32_t val)
-{
- size_t i;
- size_t idx;
-
- assert(S_CTX_INFO_ULIMIT==64);
-
- for (i=S_CTX_INFO_ULIMIT, idx=6; i>0; i/=2, --idx)
- if (val & i) return FLAGVALUES[idx].id;
-
- return 0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-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 "vserver.h"
-#include "internal.h"
-#include <lib_internal/util-dimof.h>
-
-#include <string.h>
-#include <assert.h>
-
-#define DECL(STR, VAL) { STR, sizeof(STR)-1, VAL }
-
-static struct Mapping_uint64 const VALUES[] = {
- DECL("lock", VC_VXF_INFO_LOCK),
- DECL("nproc", VC_VXF_INFO_NPROC),
- DECL("private", VC_VXF_INFO_PRIVATE),
- DECL("fakeinit", VC_VXF_INFO_INIT),
-
- DECL("hideinfo", VC_VXF_INFO_HIDEINFO),
- DECL("ulimit", VC_VXF_INFO_ULIMIT),
- DECL("namespace", VC_VXF_INFO_NAMESPACE),
-
- DECL("sched_hard", VC_VXF_SCHED_HARD),
- DECL("sched_prio", VC_VXF_SCHED_PRIO),
- DECL("sched_pause", VC_VXF_SCHED_PAUSE),
-
- DECL("virt_mem", VC_VXF_VIRT_MEM),
- DECL("virt_uptime", VC_VXF_VIRT_UPTIME),
- DECL("virt_cpu", VC_VXF_VIRT_CPU),
- DECL("virt_load", VC_VXF_VIRT_LOAD),
-
- DECL("hide_mount", VC_VXF_HIDE_MOUNT),
- DECL("hide_netif", VC_VXF_HIDE_NETIF),
-
- DECL("state_setup", VC_VXF_STATE_SETUP),
- DECL("state_init", VC_VXF_STATE_INIT),
-
- DECL("fork_rss", VC_VXF_FORK_RSS),
- DECL("prolific", VC_VXF_PROLIFIC),
- DECL("igneg_nice", VC_VXF_IGNEG_NICE),
-
-};
-
-uint_least64_t
-vc_text2cflag(char const *str, size_t len)
-{
- ssize_t idx = utilvserver_value2text_uint64(str, len,
- VALUES, DIM_OF(VALUES));
- if (idx==-1) return 0;
- else return VALUES[idx].val;
-}
-
-char const *
-vc_locflag2text(uint_least64_t *val)
-{
- ssize_t idx = utilvserver_text2value_uint64(val,
- VALUES, DIM_OF(VALUES));
-
- if (idx==-1) return 0;
- else return VALUES[idx].id;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <>
-//
-// 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 "vserver.h"
-#include <string.h>
-
-uint_least32_t
-vc_list2cflag_compat(char const *str, size_t len,
- struct vc_err_listparser *err)
-{
- uint32_t res = 0;
-
- if (len==0) len = strlen(str);
-
- for (;len>0;) {
- char const *ptr = strchr(str, ',');
- size_t cnt = ptr ? (size_t)(ptr-str) : len;
- unsigned int tmp;
-
- if (cnt>=len) { cnt=len; len=0; }
- else len-=(cnt+1);
-
- tmp = vc_text2cflag_compat(str,cnt);
-
- if (tmp!=0) res |= tmp;
- else {
- if (err) {
- err->ptr = str;
- err->len = cnt;
- }
- return res;
- }
-
- if (ptr==0) break;
- str = ptr+1;
- }
-
- if (err) {
- err->ptr = 0;
- err->len = 0;
- }
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <>
-//
-// 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 "vserver.h"
-#include "internal.h"
-
-#include <string.h>
-
-int
-vc_list2cflag(char const *str, size_t len,
- struct vc_err_listparser *err,
- struct vc_ctx_flags *flags)
-{
- return utilvserver_listparser_uint64(str, len,
- err ? &err->ptr : 0,
- err ? &err->len : 0,
- &flags->flagword, &flags->mask,
- vc_text2cflag);
-}
+++ /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 "vserver.h"
-#include "vserver-internal.h"
-#include "getversion-internal.hc"
-
-int
-utilvserver_checkCompatVersion()
-{
- static int res=0;
- static int v_errno;
-
- if (res==0) {
- res = vc_get_version_internal(VC_CAT_COMPAT);
- v_errno = errno;
-#ifdef VC_ENABLE_API_LEGACY
- if (res==-1 && (errno==ENOSYS || errno==EINVAL)) res=0;
-#endif
- }
-
- errno = v_errno;
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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.
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#define CONCAT_TWO_ARGS(BUF, LHS,RHS) \
- size_t BUF ## l1 = strlen(LHS); \
- size_t BUF ## l2 = strlen(RHS); \
- char BUF[BUF##l1 + BUF##l2 + 2]; \
- \
- memcpy(BUF, LHS, BUF##l1 + 1); \
- if (BUF##l2 > 0) { \
- BUF[ BUF##l1 ] = '/'; \
- memcpy(BUF+ BUF##l1 + 1, RHS, BUF##l2 + 1); \
- }
-
-static inline int
-mkdir2(char const *lhs, char const *rhs, int mode)
-{
- CONCAT_TWO_ARGS(buf, lhs, rhs);
- return mkdir(buf, mode);
-}
-
-static inline int
-setIAttr2(char const *lhs, char const *rhs, int flags)
-{
- CONCAT_TWO_ARGS(buf, lhs, rhs);
-
- return vc_set_iattr(buf, 0, flags, VC_IMMUTABLE_ALL);
-}
-
-static inline int
-symlink2(char const *old_lhs, char const *old_rhs,
- char const *new_lhs, char const *new_rhs)
-{
- CONCAT_TWO_ARGS(old_buf, old_lhs, old_rhs);
-
- {
- CONCAT_TWO_ARGS(new_buf, new_lhs, new_rhs);
- return symlink(old_buf, new_buf);
- }
-}
-
-#undef CONCAT_TWO_ARGS
-
-static inline int
-vc_createSkeleton_full(char const *id, char const *name, int flags)
-{
- if (mkdir(id, 0755)==-1) return -1;
-
- if (mkdir2(id, "apps", 0755)==-1 ||
- ((flags&vcSKEL_INTERFACES) && mkdir2(id, "interfaces", 755)==-1) ||
- ((flags&vcSKEL_PKGMGMT) && (
- mkdir2(id, "apps/pkgmgmt", 0755)==-1)))
- return -1;
-
- for (;;) {
- char const *basedir = CONFDIR "/.defaults/run";
-
- if (!utilvserver_isDirectory(basedir, true)) basedir = DEFAULT_PKGSTATEDIR;
- if (!utilvserver_isDirectory(basedir, true)) break;
-
- if (symlink2(basedir, name, id, "run")==-1)
- return -1;
-
- break;
- }
-
- while (flags&vcSKEL_PKGMGMT) {
- char const *basedir = CONFDIR "/.defaults/apps/pkgmgmt/base";
-
- if (!utilvserver_isDirectory(basedir, true)) basedir = DEFAULT_VSERVERPKGDIR;
- if (!utilvserver_isDirectory(basedir, true)) break;
-
- if (mkdir2(basedir, name, 0755)==-1 ||
- symlink2(basedir, name, id, "apps/pkgmgmt/base")==-1)
- return -1;
-
- break;
- }
-
- while (flags&vcSKEL_FILESYSTEM) {
- char const *basedir = CONFDIR "/.defaults/vdirbase";
-
- if (!utilvserver_isDirectory(basedir, true)) basedir = DEFAULT_VSERVERDIR;
- if (!utilvserver_isDirectory(basedir, true)) break;
-
- if (mkdir2(basedir, name, 0755)==-1 ||
- setIAttr2(basedir, name, 0)==-1 ||
- symlink2(basedir, name, id, "vdir")==-1)
- return -1;
-
- break;
- }
-
- return 0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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.
-
-#include <stdlib.h>
-#include <string.h>
-
-static inline int
-vc_createSkeleton_short(char const *id, int flags)
-{
- size_t l = strlen(id);
- char buf[sizeof(CONFDIR "/") + l];
-
- memcpy(buf, CONFDIR "/", sizeof(CONFDIR "/")-1);
- memcpy(buf+sizeof(CONFDIR "/")-1, id, l+1);
-
- return vc_createSkeleton_full(buf, id, flags);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "internal.h"
-
-#include "pathconfig.h"
-
-#include "createskeleton-full.hc"
-#include "createskeleton-short.hc"
-
-#include <errno.h>
-
-int
-vc_createSkeleton(char const *id, vcCfgStyle style, int flags)
-{
- if (style==vcCFG_NONE || style==vcCFG_AUTO) {
- if (strchr(id, '/')!=0) style = vcCFG_RECENT_FULL;
- else style = vcCFG_RECENT_SHORT;
- }
-
- switch (style) {
- case vcCFG_RECENT_SHORT : return vc_createSkeleton_short(id, flags);
- case vcCFG_RECENT_FULL : return vc_createSkeleton_full(id, 0, flags);
- default : ;
- }
-
- errno = EINVAL;
- return -1;
-}
+++ /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_SRC_EXT2FS_H
-#define H_UTIL_VSERVER_SRC_EXT2FS_H
-
-#ifdef ENSC_HAVE_EXT2FS_EXT2_FS_H
-# include <ext2fs/ext2_fs.h>
-#elif defined(ENSC_HAVE_LINUX_EXT2_FS_H)
-# include <linux/ext2_fs.h>
-#else
-# error Do not know how to include <ext2_fs.h>
-#endif
-
-#endif // H_UTIL_VSERVER_SRC_EXT2FS_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_FMT_H
-#define H_UTIL_VSERVER_LIB_FMT_H
-
-#include "../ensc_fmt/fmt.h"
-
-#endif // H_UTIL_VSERVER_LIB_FMT_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include <errno.h>
-
-xid_t vc_getfilecontext(char const *filename)
-{
- xid_t res;
- uint32_t mask = VC_IATTR_XID;
-
- if (vc_get_iattr(filename, &res, 0,&mask)==-1)
- return VC_NOCTX;
- else if ((mask&VC_IATTR_XID) && res!=VC_NOCTX)
- return res;
-
- errno = 0;
- return VC_NOCTX;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-
-uint_least64_t
-vc_get_insecurebcaps()
-{
- return ( (1<<VC_CAP_LINUX_IMMUTABLE) | (1<<VC_CAP_NET_BROADCAST) |
- (1<<VC_CAP_NET_ADMIN) | (1<<VC_CAP_NET_RAW) |
- (1<<VC_CAP_IPC_LOCK) | (1<<VC_CAP_IPC_OWNER) |
- (1<<VC_CAP_SYS_MODULE) | (1<<VC_CAP_SYS_RAWIO) |
- (1<<VC_CAP_SYS_PACCT) | (1<<VC_CAP_SYS_ADMIN) |
- (1<<VC_CAP_SYS_NICE) |
- (1<<VC_CAP_SYS_RESOURCE) | (1<<VC_CAP_SYS_TIME) |
- (1<<VC_CAP_MKNOD) | (1<<VC_CAP_QUOTACTL)
-
-#if defined(VC_ENABLE_API_COMPAT)
- | (vc_isSupported(vcFEATURE_VSHELPER) ? 0 : (1<<VC_CAP_SYS_BOOT))
-#endif
- );
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-size_t
-vc_get_nb_ipv4root()
-{
- return NB_IPV4ROOT;
-}
+++ /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 "utils-legacy.h"
-#include "internal.h"
-#include "vserver-internal.h"
-
-#include <string.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-
-static volatile size_t proc_bufsize = 4097;
-
-size_t
-utilvserver_getProcEntryBufsize()
-{
- return proc_bufsize;
-}
-
-char *
-utilvserver_getProcEntry(pid_t pid,
- char *str,
- char *buf, size_t bufsize)
-{
- char status_name[ sizeof("/proc//status") + sizeof(unsigned int)*3 + 1 ];
- int fd;
- size_t len;
- char * res = 0;
-
- if (pid<0 || (uint32_t)(pid)>99999) {
- errno = EBADR;
- return 0;
- }
-
- if (pid==0) strcpy(status_name, "/proc/self/status");
- else {
- strcpy(status_name, "/proc/");
- len = utilvserver_fmt_uint(status_name+sizeof("/proc/")-1, pid);
- strcpy(status_name+sizeof("/proc/")+len-1, "/status");
- }
-
- fd = open(status_name, O_RDONLY);
- if (fd==-1) return 0;
-
- len = read(fd, buf, bufsize);
- close(fd);
-
- if (len<bufsize) {
- buf[len] = '\0';
- if (str)
- res = strstr(buf, str) + strlen(str);
- else
- res = buf;
- }
- else if (len!=(size_t)-1) {
- if (proc_bufsize==bufsize)
- proc_bufsize = bufsize * 2 - 1;
-
- errno = EAGAIN;
- }
-
- return res;
-}
+++ /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_LIB_GETVERSION_INTERNAL_H
-#define H_UTIL_VSERVER_LIB_GETVERSION_INTERNAL_H
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#define _LINUX_TYPES_H 1
-#include "linuxvirtual.h"
-
-static inline ALWAYSINLINE UNUSED int
-vc_get_version_internal(int cat)
-{
- return vserver(VCMD_get_version, cat, 0);
-}
-
-#endif // H_UTIL_VSERVER_LIB_GETVERSION_INTERNAL_H
+++ /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 "vserver-internal.h"
-#include "getversion-internal.hc"
-
-int
-vc_get_version()
-{
- return vc_get_version_internal(VC_CAT_COMPAT);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "internal.h"
-#include "pathconfig.h"
-
-#include <string.h>
-
-char *
-vc_getVserverAppDir(char const *id, vcCfgStyle style, char const *app)
-{
- size_t l1 = strlen(id);
- size_t l2 = strlen(app);
- char *res = 0;
-
- if (style==vcCFG_NONE || style==vcCFG_AUTO)
- style = vc_getVserverCfgStyle(id);
-
- switch (style) {
- case vcCFG_NONE : return 0;
- case vcCFG_LEGACY : return 0;
- case vcCFG_RECENT_FULL :
- case vcCFG_RECENT_SHORT :
- {
- char buf[sizeof(CONFDIR) + l1 + l2 + sizeof("//apps/") - 1];
- char * ptr = buf;
-
- if (style==vcCFG_RECENT_FULL)
- memcpy(ptr, id, l1);
- else {
- memcpy(ptr, CONFDIR "/", sizeof(CONFDIR "/")-1);
- ptr += sizeof(CONFDIR "/")-1;
- memcpy(ptr, id, l1);
- }
-
- ptr += l1;
- memcpy(ptr, "/apps/", 6); ptr += 6;
- memcpy(ptr, app, l2); ptr += l2;
- *ptr = '\0';
-
- res = strdup(buf);
- break;
- }
- default : return 0;
- }
-
- if (!utilvserver_isDirectory(res, true)) {
- free(res);
- res = 0;
- }
-
- return res;
-}
+++ /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 "vserver.h"
-#include "internal.h"
-#include "pathconfig.h"
-#include "compat-c99.h"
-
-#include <string.h>
-#include <unistd.h>
-
-#ifdef VC_ENABLE_API_COMPAT
-#include <dirent.h>
-#include <sys/types.h>
-
-
-static char *
-handleLegacy(xid_t xid)
-{
- DIR *dir = opendir(DEFAULT_PKGSTATEDIR);
- struct dirent *ep;
- char * result = 0;
-
- if (dir==0) return 0;
- while ((ep=readdir(dir))!=0) {
- char * const name = ep->d_name;
- size_t l = name ? strlen(name) : 0;
- xid_t cur_xid;
-
- if (l<=4 || strcmp(name+l-4, ".ctx")!=0) continue;
- name[l-4] = '\0';
- cur_xid = vc_getVserverCtx(name, vcCFG_LEGACY, false, 0);
- if (cur_xid!=xid) continue;
-
- result = strdup(name);
- break;
- }
-
- closedir(dir);
- return result;
-}
-#else
-static inline char *
-handleLegacy(xid_t UNUSED xid)
-{
- return 0;
-}
-#endif
-
-static char *
-vc_getVserverByCtx_compat(xid_t ctx, vcCfgStyle *style, char const *revdir)
-{
- if (revdir==0) revdir = DEFAULT_PKGSTATEREVDIR;
-
- {
- vcCfgStyle cur_style = vcCFG_NONE;
- size_t l = strlen(revdir);
- size_t l1;
- char path[l + sizeof(unsigned int)*3 + 3];
-
- strcpy(path, revdir);
- path[l] = '/';
- l1 = utilvserver_fmt_uint(path+l+1, ctx);
- path[l+1+l1] = '\0';
-
- if (style==0 || *style==vcCFG_AUTO) {
- if (access(path, F_OK)==0) cur_style = vcCFG_RECENT_FULL;
- else cur_style = vcCFG_LEGACY;
- }
- else
- cur_style = *style;
-
- switch (cur_style) {
- case vcCFG_RECENT_SHORT :
- case vcCFG_RECENT_FULL :
- // check if expected ctx == actual ctx
- if (vc_getVserverCtx(path, vcCFG_RECENT_FULL, false, 0)!=ctx) return 0;
-
- if (style) *style = vcCFG_RECENT_FULL;
- return strdup(path);
- // TODO: handle legacy
- case vcCFG_LEGACY :
- {
- char * tmp = handleLegacy(ctx);
- if (tmp && style)
- *style = vcCFG_LEGACY;
-
- return tmp;
- }
-
- default :
- return 0;
- }
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static char *
-vc_getVserverByCtx_v13(xid_t ctx, vcCfgStyle *style, char const UNUSED *revdir)
-{
- char buf[128];
-
- if (vc_get_vhi_name(ctx, vcVHI_CONTEXT, buf, sizeof buf)!=-1 &&
- vc_getVserverCtx(buf, vcCFG_RECENT_FULL, false, 0)==ctx) {
- if (style) *style = vcCFG_RECENT_FULL;
- return strdup(buf);
- }
- else
- return 0;
-}
+++ /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 "vserver.h"
-#include "internal.h"
-#include "pathconfig.h"
-#include "compat-c99.h"
-
-#include <string.h>
-#include <unistd.h>
-
-#include "getvserverbyctx-compat.hc"
-#include "getvserverbyctx-v13.hc"
-
-char *
-vc_getVserverByCtx(xid_t ctx, vcCfgStyle *style, char const *revdir)
-{
- if (vc_isSupported(vcFEATURE_MIGRATE))
- return vc_getVserverByCtx_v13(ctx, style, revdir);
- else
- return vc_getVserverByCtx_compat(ctx, style, revdir);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "internal.h"
-#include "pathconfig.h"
-
-#include <string.h>
-
-char *
-vc_getVserverCfgDir(char const *id, vcCfgStyle style)
-{
- size_t l1 = strlen(id);
- char *res = 0;
-
- if (style==vcCFG_NONE || style==vcCFG_AUTO)
- style = vc_getVserverCfgStyle(id);
-
- switch (style) {
- case vcCFG_NONE : return 0;
- case vcCFG_LEGACY : return 0;
- case vcCFG_RECENT_FULL : res = strdup(id); break;
- case vcCFG_RECENT_SHORT :
- {
- char buf[sizeof(CONFDIR) + l1 + sizeof("/") - 1];
-
- strcpy(buf, CONFDIR "/");
- strcpy(buf+sizeof(CONFDIR "/") - 1, id);
-
- res = strdup(buf);
- break;
- }
- default : return 0;
- }
-
- if (!utilvserver_isDirectory(res, true)) {
- free(res);
- res = 0;
- }
-
- return res;
-}
+++ /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 "vserver.h"
-#include "pathconfig.h"
-#include "internal.h"
-
-#include <string.h>
-#include <sys/param.h>
-#include <unistd.h>
-#include <assert.h>
-
-static inline bool
-isRelPath(char const *p)
-{
- return p[0]=='.' && (p[1]=='/' || (p[1]=='.' && p[2]=='/'));
-}
-
-static inline bool
-isAbsPath(char const *p)
-{
- return p[0]=='/';
-}
-
-#define ISDIR utilvserver_isDirectory(buf, true)
-#define ISFILE utilvserver_isFile(buf, true)
-#define ISLINK utilvserver_isLink(buf)
-
-vcCfgStyle
-vc_getVserverCfgStyle(char const *id)
-{
- vcCfgStyle res = vcCFG_NONE;
- size_t l1 = strlen(id);
- char buf[l1 +
- MAX(sizeof(CONFDIR "/"),sizeof(DEFAULT_VSERVERDIR "/")) +
- MAX(sizeof("/legacy"), sizeof(".conf")) - 1];
- char * marker = 0;
- bool is_path;
-
- strcpy(buf, id);
- marker = buf+l1;
- strcpy(marker, "/vdir");
-
- is_path = isAbsPath(buf) || isRelPath(buf);
- if (is_path && (ISDIR || ISLINK))
- res = vcCFG_RECENT_FULL;
- else if (!is_path) {
- strcpy(buf, CONFDIR "/");
- strcpy(buf+sizeof(CONFDIR "/") - 1, id);
- marker = buf+sizeof(CONFDIR "/")+l1 - 1;
- strcpy(marker, "/vdir");
-
- if (ISDIR) res = vcCFG_RECENT_SHORT;
- else {
- strcpy(buf, DEFAULT_VSERVERDIR "/");
- strcpy(buf+sizeof(DEFAULT_VSERVERDIR)+1 - 1, id);
-
- if (ISDIR) res = vcCFG_LEGACY;
- }
-
- if (res==vcCFG_LEGACY) {
- strcpy(buf, CONFDIR "/");
- strcpy(buf+sizeof(CONFDIR "/") - 1, id);
- strcpy(buf+sizeof(CONFDIR "/")+l1 - 1, ".conf");
-
- if (!ISFILE) res = vcCFG_NONE;
- }
- }
-
-
- if (res==vcCFG_RECENT_FULL || res==vcCFG_RECENT_SHORT) {
- assert(marker!=0);
- strcpy(marker, "/legacy");
- if (access(buf, F_OK)==0) res=vcCFG_LEGACY;
- }
-
- return res;
-}
+++ /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 "vserver.h"
-#include "pathconfig.h"
-#include "compat-c99.h"
-#include "lib_internal/util.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#ifdef VC_ENABLE_API_COMPAT
-#include <fcntl.h>
-
-static xid_t
-extractLegacyXID(char const *dir, char const *basename)
-{
- size_t l1 = strlen(dir);
- size_t l2 = strlen(basename);
- char path[l1 + l2 + sizeof("/.ctx")];
- char * ptr = path;
- int fd;
- ssize_t len;
- xid_t result = VC_NOXID;
-
- ptr = Xmemcpy(ptr, dir, l1);
- *ptr++ = '/';
- ptr = Xmemcpy(ptr, basename, l2);
- ptr = Xmemcpy(ptr, ".ctx", 5);
-
- fd = open(path, O_RDONLY);
- if (fd==-1) return VC_NOXID;
-
- len = lseek(fd, 0, SEEK_END);
-
- if (len!=-1 && lseek(fd, 0, SEEK_SET)!=-1) {
- char buf[len+2];
- char const *pos = 0;
-
- buf[0] = '\n';
-
- if (read(fd, buf+1, len+1)==len) {
- buf[len+1] = '\0';
- pos = strstr(buf, "\nS_CONTEXT=");
- }
-
- if (pos) pos += 11;
- if (*pos>='1' && *pos<='9')
- result = atoi(pos);
- }
-
- close(fd);
- return result;
-}
-#else
-static xid_t
-extractLegacyXID(char const UNUSED *dir, char const UNUSED *basename)
-{
- return VC_NOXID;
-}
-#endif
-
-
-static xid_t
-getCtxFromFile(char const *pathname)
-{
- int fd;
- off_t len;
-
- fd = open(pathname, O_RDONLY);
-
- if (fd==-1 ||
- (len=lseek(fd, 0, SEEK_END))==-1 ||
- (len>50) ||
- (lseek(fd, 0, SEEK_SET)==-1))
- return VC_NOCTX;
-
- {
- char buf[len+1];
- char *errptr;
- xid_t res;
-
- if (TEMP_FAILURE_RETRY(read(fd, buf, len+1))!=len)
- return VC_NOCTX;
-
- res = strtol(buf, &errptr, 10);
- if (*errptr!='\0' && *errptr!='\n') return VC_NOCTX;
-
- return res;
- }
-}
-
-xid_t
-vc_getVserverCtx(char const *id, vcCfgStyle style, bool honor_static, bool *is_running)
-{
- size_t l1 = strlen(id);
- char buf[sizeof(CONFDIR "//") + l1 + sizeof("/context")];
-
- if (style==vcCFG_NONE || style==vcCFG_AUTO)
- style = vc_getVserverCfgStyle(id);
-
- if (is_running) *is_running = false;
-
- switch (style) {
- case vcCFG_NONE : return VC_NOCTX;
- case vcCFG_LEGACY :
- return extractLegacyXID(DEFAULT_PKGSTATEDIR, id);
- case vcCFG_RECENT_SHORT :
- case vcCFG_RECENT_FULL : {
- size_t idx = 0;
- xid_t res = 0;
-
- if (style==vcCFG_RECENT_SHORT) {
- memcpy(buf, CONFDIR "/", sizeof(CONFDIR "/")-1);
- idx = sizeof(CONFDIR "/") - 1;
- }
- memcpy(buf+idx, id, l1); idx += l1;
- memcpy(buf+idx, "/run", 5); // appends '\0' too
-
- res = getCtxFromFile(buf);
- if (is_running) *is_running = res!=VC_NOCTX;
-
- if (res==VC_NOCTX && honor_static) {
- memcpy(buf+idx, "/context", 9); // appends '\0' too
-
- res = getCtxFromFile(buf);
- }
-
- return res;
- }
- default : return VC_NOCTX;
- }
-}
+++ /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 "vserver.h"
-#include "pathconfig.h"
-
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <libgen.h>
-#include <unistd.h>
-#include <limits.h>
-
-static char *
-getRecentName(char *start, char *end)
-{
- char *res = 0;
- int fd;
- char buf[PATH_MAX];
-
- strcpy(end, "/name");
- fd = open(start, O_RDONLY);
- if (fd!=-1) {
- off_t len;
-
- if ((len=lseek(fd, 0, SEEK_END))!=-1 &&
- (len<VC_LIMIT_VSERVER_NAME_LEN) &&
- (lseek(fd, 0, SEEK_SET)!=-1)) {
- char buf[len+1];
-
- if (TEMP_FAILURE_RETRY(read(fd, buf, len+1))==len) {
- while (len>0 && buf[len-1]=='\n') --len;
- buf[len] = '\0';
- if (len>0) res = buf;
- }
-
- close(fd);
- return strdup(res);
- }
-
- close(fd);
- }
-
- if (res==0) {
- *end = '\0';
- res = realpath(start, buf);
- //printf("start='%s', res='%s'\n", start,res);
- if (res==0) res = start;
-
- res = basename(res);
- }
-
- return strdup(res);
-}
-
-char *
-vc_getVserverName(char const *id, vcCfgStyle style)
-{
- size_t l1 = strlen(id);
-
- if (style==vcCFG_NONE || style==vcCFG_AUTO)
- style = vc_getVserverCfgStyle(id);
-
- switch (style) {
- case vcCFG_NONE : return 0;
- case vcCFG_LEGACY : return strdup(id);
- case vcCFG_RECENT_SHORT :
- {
- char buf[sizeof(CONFDIR "/") + l1 + sizeof("/name") - 1];
-
- strcpy(buf, CONFDIR "/");
- strcpy(buf+sizeof(CONFDIR "/") - 1, id);
-
- return getRecentName(buf, buf+sizeof(CONFDIR "/")+l1 - 1);
- }
- case vcCFG_RECENT_FULL :
- {
- char buf[l1 + sizeof("/name")];
- strcpy(buf, id);
-
- return getRecentName(buf, buf+l1);
- }
- default : return 0;
- }
-}
+++ /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 "vserver.h"
-#include "internal.h"
-#include "pathconfig.h"
-
-#include <string.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include <fcntl.h>
-
-static char *
-getDir(char *dir, bool physical)
-{
- int fd;
- char tmp[PATH_MAX];
-
- if (!physical) return strdup(dir);
-
- fd = open(".", O_RDONLY);
- if (fd==-1) return 0;
-
- if (chdir(dir)!=-1 &&
- getcwd(tmp, sizeof tmp)!=0)
- dir = strdup(tmp);
- else
- dir = 0;
-
- if (fchdir(fd)==-1) {
- if (write(2, "FATAL error: failed to restore directory\n", 41)!=41) { /*...*/ }
- abort();
- }
- close(fd);
- return dir;
-}
-
-char *
-vc_getVserverVdir(char const *id, vcCfgStyle style, bool physical)
-{
- size_t l1 = strlen(id);
- char *res = 0;
-
- if (style==vcCFG_NONE || style==vcCFG_AUTO)
- style = vc_getVserverCfgStyle(id);
-
- switch (style) {
- case vcCFG_NONE : return 0;
- case vcCFG_LEGACY :
- {
- char buf[sizeof(DEFAULT_VSERVERDIR "/") + l1];
-
- strcpy(buf, DEFAULT_VSERVERDIR "/");
- strcpy(buf+sizeof(DEFAULT_VSERVERDIR "/") - 1, id);
-
- res = getDir(buf, physical);
- break;
- }
-
- case vcCFG_RECENT_SHORT :
- {
- char buf[sizeof(CONFDIR) + l1 + sizeof("//vdir") - 1];
-
- strcpy(buf, CONFDIR "/");
- strcpy(buf+sizeof(CONFDIR "/") - 1, id);
- strcpy(buf+sizeof(CONFDIR "/")+l1 - 1, "/vdir");
-
- res = getDir(buf, physical);
- break;
- }
-
- case vcCFG_RECENT_FULL :
- {
- char buf[l1 + sizeof("/vdir")];
-
- strcpy(buf, id);
- strcpy(buf+l1, "/vdir");
-
- res = getDir(buf, physical);
- break;
- }
-
- default : return 0;
- }
-
- // ignore physical-case; we went into the directory while determining
- // the physical path so the directory exists
- if (!physical && !utilvserver_isDirectory(res, true)) {
- free(res);
- res = 0;
- }
-
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "vserver.h"
-#include "virtual.h"
-
-vcXidType
-vc_getXIDType(xid_t xid)
-{
- if (xid==0) return vcTYPE_MAIN;
- if (xid==1) return vcTYPE_WATCH;
- if (xid>1 && xid<MIN_D_CONTEXT) return vcTYPE_STATIC;
- if (xid>=MIN_D_CONTEXT && xid<MAX_S_CONTEXT) return vcTYPE_DYNAMIC;
- return vcTYPE_INVALID;
-}
+++ /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.
-
-/** \file internal.h
- * \brief Declarations which are used by util-vserver internally.
- */
-
-#ifndef H_UTIL_VSERVER_LIB_INTERNAL_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_H
-
-#include "fmt.h"
-#include <stdlib.h>
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int utilvserver_checkCompatVersion();
-bool utilvserver_isDirectory(char const *path, bool follow_link);
-bool utilvserver_isFile(char const *path, bool follow_link);
-bool utilvserver_isLink(char const *path);
-
-int utilvserver_listparser_uint32(char const *str, size_t len,
- char const **err_ptr, size_t *err_len,
- uint_least32_t *flag,
- uint_least32_t *mask,
- uint_least32_t (*func)(char const*,
- size_t)) NONNULL((1,5,6,7));
-
-int utilvserver_listparser_uint64(char const *str, size_t len,
- char const **err_ptr, size_t *err_len,
- uint_least64_t *flag,
- uint_least64_t *mask,
- uint_least64_t (*func)(char const*,
- size_t)) NONNULL((1,5,6,7));
-
-struct Mapping_uint32 {
- char const * const id;
- size_t len;
- uint_least32_t val;
-};
-
-struct Mapping_uint64 {
- char const * const id;
- size_t len;
- uint_least64_t val;
-};
-
-ssize_t utilvserver_value2text_uint32(char const *str, size_t len,
- struct Mapping_uint32 const *map,
- size_t map_len) NONNULL((1,3));
-
-ssize_t utilvserver_value2text_uint64(char const *str, size_t len,
- struct Mapping_uint64 const *map,
- size_t map_len) NONNULL((1,3));
-
-ssize_t utilvserver_text2value_uint32(uint_least32_t *val,
- struct Mapping_uint32 const *map,
- size_t map_len) NONNULL((1,2));
-
-ssize_t utilvserver_text2value_uint64(uint_least64_t *val,
- struct Mapping_uint64 const *map,
- size_t map_len) NONNULL((1,2));
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "ext2fs.h"
-
-#include <sys/ioctl.h>
-
-#ifndef EXT2_IMMUTABLE_FILE_FL
-# define EXT2_IMMUTABLE_FILE_FL 0x00000010
-#endif
-
-#ifndef EXT2_IMMUTABLE_LINK_FL
-# define EXT2_IMMUTABLE_LINK_FL 0x00008000
-#endif
-
-static inline ALWAYSINLINE int
-vc_X_get_ext2flags(int fd, long *flags)
-{
- int rc;
-
- *flags = 0;
- rc = ioctl(fd, EXT2_IOC_GETFLAGS, flags);
- *flags = EXT2FLAGS_KERNEL2USER(*flags);
-
- ENSC_FIX_IOCTL(rc);
-
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "ext2fs.h"
-
-#include <sys/ioctl.h>
-
-static inline ALWAYSINLINE xid_t
-vc_X_get_filecontext(int fd)
-{
- int c;
- int rc = ioctl(fd, EXT2_IOC_GETCONTEXT, &c);
-
- ENSC_FIX_IOCTL(rc);
-
- if (rc==-1) return VC_NOCTX;
- else return c;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "ext2fs.h"
-
-#include <sys/ioctl.h>
-
-#define FIOC_GETXFLG _IOR('x', 5, long)
-
-static inline ALWAYSINLINE int
-vc_X_get_xflg(int fd, long *flags)
-{
- int rc;
- *flags = 0;
- rc = ioctl(fd, FIOC_GETXFLG, flags);
-
- if (rc<-1) {
- errno = -rc;
- rc = -1;
- }
-
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "ext2fs.h"
-
-#include <sys/ioctl.h>
-
-#ifndef EXT2_IMMUTABLE_FILE_FL
-# define EXT2_IMMUTABLE_FILE_FL 0x00000010
-#endif
-
-#ifndef EXT2_IMMUTABLE_LINK_FL
-# define EXT2_IMMUTABLE_LINK_FL 0x00008000
-#endif
-
-static inline ALWAYSINLINE int
-vc_X_set_ext2flags(int fd, long set_flags, long del_flags)
-{
- long old_flags = 0;
- int rc;
-
- set_flags = EXT2FLAGS_USER2KERNEL(set_flags);
- del_flags = EXT2FLAGS_USER2KERNEL(del_flags);
-
- if (del_flags!=-1) {
- if (ioctl(fd, EXT2_IOC_GETFLAGS, &old_flags)==-1) return -1;
- old_flags &= ~del_flags;
- }
-
- old_flags |= set_flags;
- rc = ioctl(fd, EXT2_IOC_SETFLAGS, &old_flags);
-
- ENSC_FIX_IOCTL(rc);
-
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "ext2fs.h"
-
-#include <sys/ioctl.h>
-
-static inline ALWAYSINLINE int
-vc_X_set_filecontext(int fd, xid_t ctx)
-{
- int c = ctx;
- int rc = ioctl(fd, EXT2_IOC_SETCONTEXT, &c);
-
- ENSC_FIX_IOCTL(rc);
-
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "ext2fs.h"
-
-#include <sys/ioctl.h>
-
-#define FIOC_SETXFLG _IOW('x', 6, long)
-
-static inline ALWAYSINLINE int
-vc_X_set_xflg(int fd, long flags)
-{
- int rc;
- rc = ioctl(fd, FIOC_SETXFLG, &flags);
-
- ENSC_FIX_IOCTL(rc);
-
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "internal.h"
-
-#include <stdbool.h>
-#include <unistd.h>
-#include <sys/stat.h>
-
-bool
-utilvserver_isDirectory(char const *path, bool follow_link)
-{
- struct stat st;
- if ( ( follow_link && stat(path, &st)==-1) ||
- (!follow_link && lstat(path, &st)==-1) ) return false;
-
- return S_ISDIR(st.st_mode);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-bool
-vc_is_dynamic_xid(xid_t xid)
-{
- return xid>=MIN_D_CONTEXT;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "internal.h"
-
-#include <stdbool.h>
-#include <unistd.h>
-#include <sys/stat.h>
-
-bool
-utilvserver_isFile(char const *path, bool follow_link)
-{
- struct stat st;
- if ( ( follow_link && stat(path, &st)==-1) ||
- (!follow_link && lstat(path, &st)==-1) ) return false;
-
- return S_ISREG(st.st_mode);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "internal.h"
-
-#include <stdbool.h>
-#include <unistd.h>
-#include <sys/stat.h>
-
-bool
-utilvserver_isLink(char const *path)
-{
- struct stat st;
- if (lstat(path, &st)==-1) return false;
-
- return S_ISLNK(st.st_mode);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "assert.h"
-
-bool
-vc_isSupported(vcFeatureSet feature)
-{
- int ver = vc_get_version();
- if (ver==-1) return false;
-
- switch (feature) {
- case vcFEATURE_COMPAT : return true;
- case vcFEATURE_VSHELPER0 : return ver >= 0x00010000 && ver < 0x00010010;
- case vcFEATURE_VSHELPER : return ver >= 0x00010000;
- case vcFEATURE_VKILL : return ver >= 0x00010004;
- case vcFEATURE_RLIMIT : return ver >= 0x00010004;
- case vcFEATURE_VINFO : return ver >= 0x00010010;
- case vcFEATURE_VHI : return ver >= 0x00010010;
- case vcFEATURE_IATTR : return ver >= 0x00010011;
- case vcFEATURE_MIGRATE : return ver >= 0x00010012;
- case vcFEATURE_NAMESPACE : return ver >= 0x00010012;
- case vcFEATURE_SCHED : return ver >= 0x00020000; // todo
- default : assert(false);
- }
-
- return false;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "lib_internal/util-dimof.h"
-#include <strings.h>
-
-#define DECL(F) \
- { vcFEATURE_ ## F, #F }
-
-static struct {
- vcFeatureSet feature;
- char const * name;
-} FEATURES[] = {
- DECL(VKILL), DECL(IATTR), DECL(RLIMIT), DECL(COMPAT),
- DECL(MIGRATE), DECL(NAMESPACE), DECL(SCHED), DECL(VINFO),
- DECL(VHI), DECL(VSHELPER0), DECL(VSHELPER)
-};
-
-bool
-vc_isSupportedString(char const *str)
-{
- size_t i;
- for (i=0; i<DIM_OF(FEATURES); ++i) {
- if (strcasecmp(FEATURES[i].name, str)==0)
- return vc_isSupported(FEATURES[i].feature);
- }
-
- return false;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 <stdlib.h>
-#include <string.h>
-#include <strings.h>
-
-#define TONUMBER_uint64(S,E,B) strtoll(S,E,B)
-#define TONUMBER_uint32(S,E,B) strtol (S,E,B)
-
-#define ISNUMBER(TYPE,SHORT) \
- static inline ALWAYSINLINE bool \
- isNumber_##SHORT(char const **str,size_t *len,TYPE *res,char end_chr) \
- { \
- char *err_ptr; \
- if (**str=='^') { \
- *res = ((TYPE)(1)) << TONUMBER_##SHORT(++*str, &err_ptr, 0); \
- if (len) --*len; \
- } \
- else \
- *res = TONUMBER_##SHORT(*str, &err_ptr, 0); \
- return err_ptr>*str && *err_ptr==end_chr; \
- }
-
-
-#define LISTPARSER(TYPE,SHORT) \
- ISNUMBER(TYPE,SHORT) \
- int \
- utilvserver_listparser_ ## SHORT(char const *str, size_t len, \
- char const **err_ptr, \
- size_t *err_len, \
- TYPE *flag, \
- TYPE *mask, \
- TYPE (*func)(char const *, size_t)) \
- { \
- if (len==0) len = strlen(str); \
- for (;len>0;) { \
- char const *ptr = strchr(str, ','); \
- size_t cnt; \
- TYPE tmp = 0; \
- bool is_neg = false; \
- bool allow_zero = true; \
- \
- while (len>0 && (*str=='!' || *str=='~')) { \
- is_neg = !is_neg; \
- ++str; \
- --len; \
- } \
- \
- cnt = ptr ? (size_t)(ptr-str) : len; \
- if (cnt>=len) { cnt=len; len=0; } \
- else len-=(cnt+1); \
- \
- if (cnt==0) \
- allow_zero = false; \
- else if (strncasecmp(str,"all",cnt)==0 || \
- strncasecmp(str,"any",cnt)==0) \
- tmp = ~(TYPE)(0); \
- else if (strncasecmp(str,"none",cnt)==0) {} \
- else if (!isNumber_##SHORT(&str, &cnt, &tmp, str[cnt])) { \
- tmp = (*func)(str,cnt); \
- allow_zero = false; \
- } \
- \
- if (tmp!=0 || allow_zero) { \
- if (!is_neg) *flag |= tmp; \
- else *flag &= ~tmp; \
- *mask |= tmp; \
- } \
- else { \
- if (err_ptr) *err_ptr = str; \
- if (err_len) *err_len = cnt; \
- return -1; \
- } \
- \
- if (ptr==0) break; \
- str = ptr+1; \
- } \
- \
- if (err_ptr) *err_ptr = 0; \
- if (err_len) *err_len = 0; \
- return 0; \
- }
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "internal.h"
-#include "listparser.hc"
-
-LISTPARSER(uint_least32_t, uint32)
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "internal.h"
-#include "listparser.hc"
-
-LISTPARSER(uint_least64_t, uint64)
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-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 "vserver.h"
-#include "internal.h"
-#include <lib_internal/util-dimof.h>
-
-#include <string.h>
-#include <assert.h>
-
-#define DECL(STR, VAL) { STR, sizeof(STR)-1, VAL }
-
-static struct Mapping_uint64 const VALUES[] = {
-#warning Add the 'ncap' values here
-};
-
-uint_least64_t
-vc_text2ncap(char const *str, size_t len)
-{
- ssize_t idx = utilvserver_value2text_uint64(str, len,
- VALUES, DIM_OF(VALUES));
- if (idx==-1) return 0;
- else return VALUES[idx].val;
-}
-
-char const *
-vc_loncap2text(uint_least64_t *val)
-{
- ssize_t idx = utilvserver_text2value_uint64(val,
- VALUES, DIM_OF(VALUES));
-
- if (idx==-1) return 0;
- else return VALUES[idx].id;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <>
-//
-// 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 "vserver.h"
-#include "internal.h"
-
-#include <string.h>
-
-int
-vc_list2ncap(char const *str, size_t len,
- struct vc_err_listparser *err,
- struct vc_net_caps *caps)
-{
- return utilvserver_listparser_uint64(str, len,
- err ? &err->ptr : 0,
- err ? &err->len : 0,
- &caps->ncaps, &caps->cmask,
- vc_text2ncap);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-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 "vserver.h"
-#include "internal.h"
-#include <lib_internal/util-dimof.h>
-
-#include <string.h>
-#include <assert.h>
-
-#define DECL(STR, VAL) { STR, sizeof(STR)-1, VAL }
-
-static struct Mapping_uint64 const VALUES[] = {
-#warning Add the 'nflags' values here
-};
-
-uint_least64_t
-vc_text2nflag(char const *str, size_t len)
-{
- ssize_t idx = utilvserver_value2text_uint64(str, len,
- VALUES, DIM_OF(VALUES));
- if (idx==-1) return 0;
- else return VALUES[idx].val;
-}
-
-char const *
-vc_lonflag2text(uint_least64_t *val)
-{
- ssize_t idx = utilvserver_text2value_uint64(val,
- VALUES, DIM_OF(VALUES));
-
- if (idx==-1) return 0;
- else return VALUES[idx].id;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <>
-//
-// 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 "vserver.h"
-#include "internal.h"
-
-#include <string.h>
-
-int
-vc_list2nflag(char const *str, size_t len,
- struct vc_err_listparser *err,
- struct vc_net_flags *flags)
-{
- return utilvserver_listparser_uint64(str, len,
- err ? &err->ptr : 0,
- err ? &err->len : 0,
- &flags->flagword, &flags->mask,
- vc_text2nflag);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include <string.h>
-#include <stdlib.h>
-
-bool
-vc_parseLimit(char const *buf, vc_limit_t *res)
-{
- char * errptr;
-
- if (strncmp(buf, "inf", 3)==0) {
- *res = VC_LIM_INFINITY;
- return true;
- }
-
- *res = strtoll(buf, &errptr, 0);
-
- if (errptr!=buf) {
- switch (*errptr) {
- case 'M' : *res *= 1024; /* fallthrough */
- case 'K' : *res *= 1024; ++errptr; break;
- case 'm' : *res *= 1000; /* fallthrough */
- case 'k' : *res *= 1000; ++errptr; break;
- default : break;
- }
- }
-
- return errptr!=buf && (*errptr=='\0' || *errptr=='\n');
-}
+++ /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_LIB_SAFECHROOT_INTERNAL_H
-#define H_UTIL_VSERVER_LIB_SAFECHROOT_INTERNAL_H
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "compat.h"
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#ifndef NDEBUG
-static void
-vc_tell_unsafe_chroot()
-{
- static int flag = -1;
- if (flag==-1) {
- char const * const e = getenv("VC_TELL_UNSAFE_CHROOT");
- flag = e ? atoi(e) : 0;
- flag = flag ? 1 : 0;
- }
-
- if (flag) write(2, "Unsafe chroot() used\n", 23);
-}
-#else
-static ALWAYSINLINE UNUSED void vc_tell_unsafe_chroot() {}
-#endif
-
-
-#endif // H_UTIL_VSERVER_LIB_SAFECHROOT_INTERNAL_H
+++ /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 "compat.h"
-
-#include "safechroot-internal.hc"
-#include "vserver.h"
-
-#include <unistd.h>
-
-static inline ALWAYSINLINE xid_t
-vc_new_s_context_compat(xid_t ctx, unsigned int remove_cap, unsigned int flags)
-{
- struct vcmd_new_s_context_v1 msg;
- msg.remove_cap = remove_cap;
- msg.flags = flags;
-
- return vserver(VCMD_new_s_context, CTX_USER2KERNEL(ctx), &msg);
-}
-
-static inline ALWAYSINLINE int
-vc_set_ipv4root_compat(uint32_t bcast, size_t nb, struct vc_ip_mask_pair const *ips)
-{
- struct vcmd_set_ipv4root_v3 msg;
- size_t i;
-
- if (nb>NB_IPV4ROOT) {
- errno = -EOVERFLOW;
- return -1;
- }
-
- msg.broadcast = bcast;
-
- for (i=0; i<nb; ++i) {
- msg.nx_mask_pair[i].ip = ips[i].ip;
- msg.nx_mask_pair[i].mask = ips[i].mask;
- }
-
- return vserver(VCMD_set_ipv4root, nb, &msg);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on syscall.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- This tells the system call number for new_s_context and set_ipv4root
- using /proc/self/status. This helps until the vserver project is
- included officially in the kernel (and has its own syscall).
-
- We rely on /proc/self/status to find the syscall number.
-
- If it is not there, we rely on adm/unistd.h.
-
- If this file does not have those system calls (not a patched kernel source)
- we rely on static values in this file.
-*/
-#include "safechroot-internal.hc"
-
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <syscall.h>
-#include <asm/unistd.h>
-#include <stdbool.h>
-
-// Here is the trick. We keep a copy of the define, then undef it
-// and then later, we try to locate the value reading /proc/self/status
-// If this fails, we have the old preserved copy.
-static int def_NR_set_ipv4root = 274;
-#undef __NR_set_ipv4root
-
-static int __NR_set_ipv4root_rev0;
-static int __NR_set_ipv4root_rev1;
-static int __NR_set_ipv4root_rev2;
-static int __NR_set_ipv4root_rev3;
-static int rev_ipv4root=0;
-
-#ifdef ENSC_SYSCALL_TRADITIONAL
-# if defined __dietlibc__
-extern long int syscall (long int __sysno, ...);
-# endif
-
-inline static int
-set_ipv4root_rev0(unsigned long ip)
-{
- return syscall(__NR_set_ipv4root_rev0, ip);
-}
-
-inline static int
-set_ipv4root_rev1(unsigned long ip, unsigned long bcast)
-{
- return syscall(__NR_set_ipv4root_rev1, ip, bcast);
-}
-
-inline static int
-set_ipv4root_rev2(unsigned long *ip, int nb, unsigned long bcast)
-{
- return syscall(__NR_set_ipv4root_rev2, ip, nb, bcast);
-}
-
-inline static int
-set_ipv4root_rev3(unsigned long *ip, int nb, unsigned long bcast, unsigned long * mask)
-{
- return syscall(__NR_set_ipv4root_rev3, ip, nb, bcast, mask);
-}
-
-#else // ENSC_SYSCALL_TRADITIONAL
-inline static _syscall1(int, set_ipv4root_rev0, unsigned long, ip)
-inline static _syscall2(int, set_ipv4root_rev1, unsigned long, ip, unsigned long, bcast)
-inline static _syscall3(int, set_ipv4root_rev2, unsigned long *, ip, int, nb, unsigned long, bcast)
-inline static _syscall4(int, set_ipv4root_rev3, unsigned long *, ip, int, nb, unsigned long, bcast, unsigned long *, mask)
-#endif // ENSC_SYSCALL_TRADITIONAL
-
-static int def_NR_new_s_context = 273;
-#undef __NR_new_s_context
-static int __NR_new_s_context_rev0;
-static int rev_s_context=0;
-
-
-#ifdef ENSC_SYSCALL_TRADITIONAL
-inline static xid_t
-new_s_context_rev0(int newctx, int remove_cap, int flags)
-{
- return syscall(__NR_new_s_context_rev0, newctx, remove_cap, flags);
-}
-#else // ENSC_SYSCALL_TRADITIONAL
-inline static _syscall3(int, new_s_context_rev0, int, newctx, int, remove_cap, int, flags)
-#endif // ENSC_SYSCALL_TRADITIONAL
-
-
-static bool is_init = false;
-
-#include "utils-legacy.h"
-
-#ifndef WRITE_MSG
-# define WRITE_MSG(FD,X) (void)(write(FD,X,sizeof(X)-1))
-#endif
-
-
-static bool
-getNumRevPair(char const *str, int *num, int *rev)
-{
- char const * blank_pos = strchr(str, ' ');
- char const * eol_pos = strchr(str, '\n');
-
- *num = atoi(str);
- if (*num==0) return false;
-
- if (blank_pos!=0 && eol_pos!=0 && blank_pos<eol_pos &&
- strncmp(blank_pos+1, "rev", 3)==0)
- *rev = atoi(blank_pos+4);
-
- return true;
-}
-
-#define SET_TAG_POS(TAG) \
- pos = strstr(buf, (TAG)); \
- if (pos) pos+=sizeof(TAG)-1
-
-static bool init_internal()
-{
- size_t bufsize = utilvserver_getProcEntryBufsize();
- char buf[bufsize];
- char const * pos = 0;
- pid_t pid = getpid();
- int num;
-
- errno = 0;
-
- pos=utilvserver_getProcEntry(pid, 0, buf, bufsize);
- if (pos==0 && errno==EAGAIN) return false;
-
- SET_TAG_POS("\n__NR_set_ipv4root: ");
- if ( pos!=0 && getNumRevPair(pos, &num, &rev_ipv4root) ) {
- __NR_set_ipv4root_rev0 =
- __NR_set_ipv4root_rev1 =
- __NR_set_ipv4root_rev2 =
- __NR_set_ipv4root_rev3 = num;
- }
-
- SET_TAG_POS("\n__NR_new_s_context: ");
- if ( pos!=0 && getNumRevPair(pos, &num, &rev_s_context) )
- __NR_new_s_context_rev0 = num;
-
- return true;
-}
-
-#undef SET_TAG_POS
-
-static void init()
-{
- if (!is_init){
- __NR_set_ipv4root_rev0 = def_NR_set_ipv4root;
- __NR_set_ipv4root_rev1 = def_NR_set_ipv4root;
- __NR_set_ipv4root_rev2 = def_NR_set_ipv4root;
- __NR_set_ipv4root_rev3 = def_NR_set_ipv4root;
- __NR_new_s_context_rev0 = def_NR_new_s_context;
-
- while (!init_internal() && errno==EAGAIN) {}
-
- is_init = true;
- }
-}
-
-void vc_init_legacy()
-{
- init();
-}
-
-void vc_init_internal_legacy(int ctx_rev, int ctx_number,
- int ipv4_rev, int ipv4_number)
-{
- rev_s_context = ctx_rev;
- __NR_new_s_context_rev0 = ctx_number;
-
- rev_ipv4root = ipv4_rev;
- __NR_set_ipv4root_rev0 = ipv4_number;
- __NR_set_ipv4root_rev1 = ipv4_number;
- __NR_set_ipv4root_rev2 = ipv4_number;
- __NR_set_ipv4root_rev3 = ipv4_number;
-
- is_init = true;
-}
-
-static ALWAYSINLINE xid_t
-vc_new_s_context_legacy(int ctx, int remove_cap, int flags)
-{
- xid_t ret = -1;
- init();
- if (rev_s_context == 0){
- return new_s_context_rev0(ctx, remove_cap, flags);
- }else{
- errno = -ENOSYS;
- ret = VC_NOCTX;
- }
- return ret;
-}
-
-static ALWAYSINLINE int
-vc_set_ipv4root_legacy_internal (
- unsigned long ip[],
- int nb,
- unsigned long bcast,
- unsigned long mask[])
-{
- init();
- if (rev_ipv4root == 0){
- if (nb > 1){
- WRITE_MSG(2,"set_ipv4root: Several IP number specified, but this kernel only supports one. Ignored\n");
- }
- return set_ipv4root_rev0 (ip[0]);
- }else if (rev_ipv4root == 1){
- if (nb > 1){
- WRITE_MSG(2,"set_ipv4root: Several IP number specified, but this kernel only supports one. Ignored\n");
- }
- return set_ipv4root_rev1 (ip[0],bcast);
- }else if (rev_ipv4root == 2){
- return set_ipv4root_rev2 (ip,nb,bcast);
- }else if (rev_ipv4root == 3){
- return set_ipv4root_rev3 (ip,nb,bcast,mask);
- }
- errno = EINVAL;
- return -1;
-}
-
-static ALWAYSINLINE int
-vc_set_ipv4root_legacy(uint32_t bcast, size_t nb, struct vc_ip_mask_pair const *ips)
-{
- unsigned long ip[nb];
- unsigned long mask[nb];
- size_t i;
-
- for (i=0; i<nb; ++i) {
- ip[i] = ips[i].ip;
- mask[i] = ips[i].mask;
- }
-
- return vc_set_ipv4root_legacy_internal(ip, nb, bcast, mask);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz 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 "vserver-internal.h"
-
-#if 0
-int
-vc_syscall(uint32_t cmd, xid_t xid, void *data) __attribute__((__alias__("vserver")));
-#else
-int
-vc_syscall(uint32_t cmd, xid_t xid, void *data)
-{
- return vserver(cmd, xid, data);
-}
-#endif
+++ /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 "compat.h"
-#include "vserver.h"
-#include "internal.h"
-
-#define _LINUX_TYPES_H 1
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_COMPAT) && defined(VC_ENABLE_API_LEGACY)
-# define VC_MULTIVERSION_SYSCALL 1
-#endif
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_COMPAT
-# include "syscall-compat.hc"
-#endif
-
-#ifdef VC_ENABLE_API_LEGACY
-# include "syscall-legacy.hc"
-#endif
-
-#include <stdbool.h>
-#include <errno.h>
-
-
-#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
-
-xid_t
-vc_new_s_context(xid_t ctx, unsigned int remove_cap, unsigned int flags)
-{
- CALL_VC(CALL_VC_COMPAT(vc_new_s_context, ctx, remove_cap, flags),
- CALL_VC_LEGACY(vc_new_s_context, ctx, remove_cap, flags));
-}
-
-int
-vc_set_ipv4root(uint32_t bcast, size_t nb, struct vc_ip_mask_pair const *ips)
-{
- CALL_VC(CALL_VC_COMPAT(vc_set_ipv4root, bcast, nb, ips),
- CALL_VC_LEGACY(vc_set_ipv4root, bcast, nb, ips));
-}
-
-LINK_WARNING("vc_new_s_context", "warning: vc_new_s_context() is obsoleted; use vc_create_context() instead of");
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "vserver.h"
-
-static inline ALWAYSINLINE int
-vc_add_dlimit_v13b(char const *filename, xid_t xid, uint32_t flags)
-{
- struct vcmd_ctx_dlimit_base_v0 init = {
- .name = filename,
- .flags = flags
- };
-
- return vserver(VCMD_add_dlimit, CTX_USER2KERNEL(xid), &init);
-}
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2005 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_adddlimit-v13.hc"
-#endif
-
-int
-vc_add_dlimit(char const *filename, xid_t xid, uint32_t flags)
-{
- CALL_VC(CALL_VC_V13B(vc_add_dlimit, filename, xid, flags));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-
-static inline ALWAYSINLINE int
-vc_cleanup_namespace_v13(int UNUSED tmp)
-{
- return vserver(VCMD_cleanup_namespace, 0, 0);
-}
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_cleanupnamespace-v13.hc"
-#endif
-
-int
-vc_cleanup_namespace()
-{
- CALL_VC(CALL_VC_V13(vc_cleanup_namespace,0));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE xid_t
-vc_ctx_create_v13(xid_t xid)
-{
- xid_t res = vserver(VCMD_ctx_create, CTX_USER2KERNEL(xid), 0);
-
- return CTX_KERNEL2USER(res);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_V13)
-# include "syscall_ctxcreate-v13.hc"
-#endif
-
-#if defined(VC_ENABLE_API_V13)
-xid_t
-vc_ctx_create(xid_t xid)
-{
- CALL_VC(CALL_VC_V13A(vc_ctx_create, xid));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_ctx_migrate_v13(xid_t xid)
-{
- return vserver(VCMD_ctx_migrate, CTX_USER2KERNEL(xid), 0);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_V13)
-# include "syscall_ctxmigrate-v13.hc"
-#endif
-
-#if defined(VC_ENABLE_API_V13)
-int
-vc_ctx_migrate(xid_t xid)
-{
- CALL_VC(CALL_VC_V13A(vc_ctx_migrate, xid));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-
-static inline ALWAYSINLINE int
-vc_enter_namespace_v13(xid_t xid)
-{
- return vserver(VCMD_enter_namespace, CTX_USER2KERNEL(xid), 0);
-}
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_enternamespace-v13.hc"
-#endif
-
-int
-vc_enter_namespace(xid_t xid)
-{
- CALL_VC(CALL_VC_V13(vc_enter_namespace, xid));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_get_ccaps_v13(xid_t xid, struct vc_ctx_caps *caps)
-{
- struct vcmd_ctx_caps_v0 k_caps;
- int res;
-
- res = vserver(VCMD_get_ccaps, CTX_USER2KERNEL(xid), &k_caps);
- caps->bcaps = k_caps.bcaps;
- caps->bmask = ~0ull;
- caps->ccaps = k_caps.ccaps;
- caps->cmask = k_caps.cmask;
-
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_V13)
-# include "syscall_getccaps-v13.hc"
-#endif
-
-#if defined(VC_ENABLE_API_V13)
-int
-vc_get_ccaps(xid_t xid, struct vc_ctx_caps *caps)
-{
- if (caps==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_V13A(vc_get_ccaps, xid, caps));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_get_cflags_v13(xid_t xid, struct vc_ctx_flags *flags)
-{
- struct vcmd_ctx_flags_v0 k_flags;
- int res;
-
- if (flags==0) {
- errno = EFAULT;
- return -1;
- }
-
- res = vserver(VCMD_get_cflags, CTX_USER2KERNEL(xid), &k_flags);
- flags->flagword = k_flags.flagword;
- flags->mask = k_flags.mask;
-
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_V13)
-# include "syscall_getcflags-v13.hc"
-#endif
-
-#if defined(VC_ENABLE_API_V13)
-int
-vc_get_cflags(xid_t xid, struct vc_ctx_flags *flags)
-{
- CALL_VC(CALL_VC_V13A(vc_get_cflags, xid, flags));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "vserver.h"
-
-static inline ALWAYSINLINE int
-vc_get_dlimit_v13b(char const *filename, xid_t xid,
- uint_least32_t flags, struct vc_ctx_dlimit *limits)
-{
- int rc;
- struct vcmd_ctx_dlimit_v0 attr = {
- .name = filename,
- .flags = flags
- };
-
- rc = vserver(VCMD_get_dlimit, CTX_USER2KERNEL(xid), &attr);
-
- if (limits) {
- limits->space_used = CDLIM_KERNEL2USER(attr.space_used);
- limits->space_total = CDLIM_KERNEL2USER(attr.space_total);
- limits->inodes_used = CDLIM_KERNEL2USER(attr.inodes_used);
- limits->inodes_total = CDLIM_KERNEL2USER(attr.inodes_total);
- limits->reserved = CDLIM_KERNEL2USER(attr.reserved);
- }
-
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2005 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_getdlimit-v13.hc"
-#endif
-
-int
-vc_get_dlimit(char const *filename, xid_t xid,
- uint_least32_t flags, struct vc_ctx_dlimit *limits)
-{
- CALL_VC(CALL_VC_V13B(vc_get_dlimit, filename, xid, flags, limits));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "ioctl-getext2flags.hc"
-#include "ioctl-getfilecontext.hc"
-#include "ioctl-getxflg.hc"
-
-#include <fcntl.h>
-static inline ALWAYSINLINE int
-vc_get_iattr_fscompat(char const *filename,
- xid_t * /*@null@*/ xid,
- uint32_t * /*@null@*/ flags,
- uint32_t * mask)
-{
- struct stat st;
- int stat_rc;
- int fd;
- int old_mask = *mask;
-
- *mask = 0;
-
- if (lstat(filename, &st)==-1) return -1;
- if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode)) return 0;
-
- fd = open(filename, O_RDONLY);
- if (fd==-1) return -1;
-
- stat_rc = fstat(fd, &st);
- if (stat_rc==-1) goto err;
-
- if ( old_mask&VC_IATTR_XID ) {
- *xid = vc_X_get_filecontext(fd);
- if (*xid!=VC_NOCTX) *mask |= VC_IATTR_XID;
- }
-
- if ( old_mask&VC_IATTR_IUNLINK ) {
- long tmp;
- int rc = vc_X_get_ext2flags(fd, &tmp);
-
- if (rc!=-1) {
- *mask |= VC_IATTR_IUNLINK;
- if (tmp & (VC_IMMUTABLE_FILE_FL|VC_IMMUTABLE_LINK_FL))
- *flags |= VC_IATTR_IUNLINK;
- }
- }
-
- if ( (old_mask&VC_IATTR_BARRIER) && S_ISDIR(st.st_mode)) {
- *mask |= VC_IATTR_BARRIER;
- if ((st.st_mode&0777) == 0) *flags |= VC_IATTR_BARRIER;
- }
-
- if ( (old_mask&(VC_IATTR_WATCH|VC_IATTR_HIDE)) ){
- long tmp;
- int rc = vc_X_get_xflg(fd, &tmp);
- if (rc!=-1) {
- *mask |= (VC_IATTR_WATCH|VC_IATTR_HIDE);
- if (tmp&1) *flags |= VC_IATTR_HIDE;
- if (tmp&2) *flags |= VC_IATTR_WATCH;
- }
- }
-
- close(fd);
- return 0;
- err:
- {
- int old_errno = errno;
- close(fd);
- errno = old_errno;
- return -1;
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-
-static inline ALWAYSINLINE int
-vc_get_iattr_v13(char const *filename,
- xid_t *xid, uint32_t *flags, uint32_t *mask)
-{
- struct vcmd_ctx_iattr_v1 attr;
- int rc;
-
- attr.name = filename;
-
- rc = vserver(VCMD_get_iattr, 0, &attr);
- if (xid) *xid = CTX_KERNEL2USER(attr.xid);
- if (flags) *flags = attr.flags;
- if (mask) *mask = attr.mask;
-
- return rc;
-}
+++ /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 "vserver.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_FSCOMPAT) && defined(VC_ENABLE_API_V13)
-# define VC_MULTIVERSION_SYSCALL 1
-#endif
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_getiattr-v13.hc"
-#endif
-
-#ifdef VC_ENABLE_API_FSCOMPAT
-# include "syscall_getiattr-fscompat.hc"
-#endif
-
-int
-vc_get_iattr(char const *filename, xid_t *xid, uint32_t *flags, uint32_t *mask)
-{
- if ( (mask==0) ||
- ((*mask&VC_IATTR_XID) && xid==0) ||
- ((*mask&~VC_IATTR_XID) && flags==0) ) {
- errno = EFAULT;
- return -1;
- }
- if ( flags ) *flags &= ~*mask;
-
- CALL_VC(CALL_VC_V13 (vc_get_iattr, filename, xid, flags, mask),
- CALL_VC_FSCOMPAT(vc_get_iattr, filename, xid, flags, mask));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_get_ncaps_net(nid_t nid, struct vc_net_caps *caps)
-{
- struct vcmd_net_caps_v0 k_caps;
- int res;
-
- res = vserver(VCMD_get_ncaps, NID_USER2KERNEL(nid), &k_caps);
- caps->ncaps = k_caps.ncaps;
- caps->cmask = k_caps.cmask;
-
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_NET)
-# include "syscall_getncaps-net.hc"
-#endif
-
-#if defined(VC_ENABLE_API_NET)
-int
-vc_get_ncaps(nid_t nid, struct vc_net_caps *caps)
-{
- if (caps==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_NET(vc_get_ncaps, nid, caps));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_get_nflags_net(nid_t nid, struct vc_net_flags *flags)
-{
- struct vcmd_net_flags_v0 k_flags;
- int res;
-
- res = vserver(VCMD_get_nflags, NID_USER2KERNEL(nid), &k_flags);
- flags->flagword = k_flags.flagword;
- flags->mask = k_flags.mask;
-
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_NET)
-# include "syscall_getnflags-net.hc"
-#endif
-
-#if defined(VC_ENABLE_API_NET)
-int
-vc_get_nflags(nid_t nid, struct vc_net_flags *flags)
-{
- if (flags==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_NET(vc_get_nflags, nid, flags));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_get_nx_info_net(nid_t nid, struct vc_nx_info *info)
-{
- struct vcmd_nx_info_v0 res;
- int rc;
-
- rc = vserver(VCMD_nx_info, NID_USER2KERNEL(nid), &res);
- if (rc==-1) return -1;
-
- info->nid = NID_KERNEL2USER(res.nid);
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_NET
-# include "syscall_getnxinfo-net.hc"
-#endif
-
-#ifdef VC_ENABLE_API_NET
-int
-vc_get_nx_info(nid_t nid, struct vc_nx_info *info)
-{
- if (info==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_NET(vc_get_nx_info, nid, info));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE nid_t
-vc_get_task_nid_net(pid_t pid)
-{
- nid_t res=vserver(VCMD_task_nid, pid, 0);
- return NID_KERNEL2USER(res);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_NET
-# include "syscall_gettasknid-net.hc"
-#endif
-
-#ifdef VC_ENABLE_API_NET
-nid_t
-vc_get_task_nid(pid_t pid)
-{
- CALL_VC(CALL_VC_NET(vc_get_task_nid, pid));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "utils-legacy.h"
-
-static xid_t
-getctx_legacy_internal(pid_t pid)
-{
- size_t bufsize = utilvserver_getProcEntryBufsize();
- char buf[bufsize];
- char *pos = 0;
-
- pos = utilvserver_getProcEntry(pid, "\ns_context: ", buf, bufsize);
-
- if (pos!=0) return atoi(pos);
- else return VC_NOCTX;
-}
-
-static inline ALWAYSINLINE xid_t
-vc_get_task_xid_oldproc(pid_t pid)
-{
- xid_t res;
- do {
- res = getctx_legacy_internal(pid);
- } while (res==VC_NOCTX && errno==EAGAIN);
-
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE xid_t
-vc_get_task_xid_v13(pid_t pid)
-{
- xid_t res=vserver(VCMD_task_xid, pid, 0);
- return CTX_KERNEL2USER(res);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_OLDPROC) && defined(VC_ENABLE_API_V13)
-# define VC_MULTIVERSION_SYSCALL 1
-#endif
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_gettaskxid-v13.hc"
-#endif
-
-#ifdef VC_ENABLE_API_OLDPROC
-# include "syscall_gettaskxid-oldproc.hc"
-#endif
-
-xid_t
-vc_get_task_xid(pid_t pid)
-{
- CALL_VC(CALL_VC_V13 (vc_get_task_xid, pid),
- CALL_VC_OLDPROC(vc_get_task_xid, pid));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_get_vhi_name_olduts(xid_t xid, vc_uts_type type, char *val, size_t len)
-{
- if (xid!=VC_SAMECTX) {
- errno = ESRCH;
- return -1;
- }
-
- switch (type) {
- case vcVHI_NODENAME : return gethostname (val, len);
- case vcVHI_DOMAINNAME : return getdomainname(val, len);
- default :
- errno = ENOENT;
- return -1;
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 <string.h>
-
-static inline ALWAYSINLINE int
-vc_get_vhi_name_v13(xid_t xid, vc_uts_type type, char *val, size_t len)
-{
- struct vcmd_vx_vhi_name_v0 cmd;
- int rc;
- size_t l = sizeof(cmd.name);
-
- cmd.field = VHI_USER2KERNEL(type);
- rc = vserver(VCMD_vx_get_vhi_name, CTX_USER2KERNEL(xid), &cmd);
- ENSC_FIX_IOCTL(rc);
- if (rc==-1) return -1;
-
- l = l>len ? len : l;
- strncpy(val, cmd.name, l);
- return 0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_OLDUTS) && defined(VC_ENABLE_API_V13)
-# define VC_MULTIVERSION_SYSCALL 1
-#endif
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_getvhiname-v13.hc"
-#endif
-
-#ifdef VC_ENABLE_API_OLDUTS
-# include "syscall_getvhiname-olduts.hc"
-#endif
-
-int
-vc_get_vhi_name(xid_t xid, vc_uts_type type, char *val, size_t len)
-{
- CALL_VC(CALL_VC_V13 (vc_get_vhi_name, xid, type, val, len),
- CALL_VC_OLDUTS(vc_get_vhi_name, xid, type, val, len));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_get_vx_info_oldproc(xid_t UNUSED xid, struct vc_vx_info UNUSED *info)
-{
- // TODO: ???
- errno = ENOSYS;
- return -1;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_get_vx_info_v13(xid_t xid, struct vc_vx_info *info)
-{
- if (xid==0 || xid==1) {
- info->xid = xid;
- info->initpid = -1;
-
- return 0;
- }
- else {
- struct vcmd_vx_info_v0 res;
- int rc;
-
- rc = vserver(VCMD_vx_info, CTX_USER2KERNEL(xid), &res);
- if (rc==-1) return -1;
-
- info->xid = CTX_KERNEL2USER(res.xid);
- info->initpid = res.initpid;
-
- return rc;
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_OLDPROC) && defined(VC_ENABLE_API_V13)
-# define VC_MULTIVERSION_SYSCALL 1
-#endif
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_getvxinfo-v13.hc"
-#endif
-
-#ifdef VC_ENABLE_API_OLDPROC
-# include "syscall_getvxinfo-oldproc.hc"
-#endif
-
-int
-vc_get_vx_info(xid_t xid, struct vc_vx_info *info)
-{
- if (info==0) {
- errno = EFAULT;
- return -1;
- }
- CALL_VC(CALL_VC_V13 (vc_get_vx_info, xid, info),
- CALL_VC_OLDPROC(vc_get_vx_info, xid, info));
-}
+++ /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
-
-static inline ALWAYSINLINE int
-vc_ctx_kill_v11(xid_t ctx, pid_t pid, int sig)
-{
- struct vcmd_ctx_kill_v0 param = { .pid = 0 };
- param.pid = pid;
- param.sig = sig;
-
- return vserver(VCMD_ctx_kill, CTX_USER2KERNEL(ctx), ¶m);
-}
+++ /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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_V11) || defined(VC_ENABLE_API_V13)
-# include "syscall_kill-v11.hc"
-#endif
-
-#ifdef VC_ENABLE_API_V13
-# define vc_ctx_kill_v13 vc_ctx_kill_v11
-#endif
-
-
-#if defined(VC_ENABLE_API_V11) || defined(VC_ENABLE_API_V13)
-
- // NOTICE: the reverse order of V11 -> V13 is correct here since these are
- // the same syscalls
-
-int
-vc_ctx_kill(xid_t ctx, pid_t pid, int sig)
-{
- CALL_VC(CALL_VC_V11(vc_ctx_kill, ctx, pid, sig),
- CALL_VC_V13(vc_ctx_kill, ctx, pid, sig));
-}
-
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_net_add_net(nid_t nid, struct vc_net_nx const *info)
-{
- struct vcmd_net_nx_v0 k_info;
-
- k_info.type = NETTYPE_USER2KERNEL(info->type);
- k_info.count = info->count;
-
- return vserver(VCMD_net_add, NID_USER2KERNEL(nid), &k_info);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_NET)
-# include "syscall_netadd-net.hc"
-#endif
-
-#if defined(VC_ENABLE_API_NET) && 0
-int
-vc_net_add(nid_t nid, struct vc_net_nx const *info)
-{
- if (info==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_NET(vc_net_add, nid, info));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE nid_t
-vc_net_create_net(nid_t nid)
-{
- nid_t res = vserver(VCMD_net_create, NID_USER2KERNEL(nid), 0);
-
- return NID_KERNEL2USER(res);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_NET)
-# include "syscall_netcreate-net.hc"
-#endif
-
-#if defined(VC_ENABLE_API_NET)
-nid_t
-vc_net_create(nid_t nid)
-{
- CALL_VC(CALL_VC_NET(vc_net_create, nid));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_net_migrate_net(nid_t nid)
-{
- return vserver(VCMD_net_migrate, NID_USER2KERNEL(nid), 0);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_NET)
-# include "syscall_netmigrate-net.hc"
-#endif
-
-#if defined(VC_ENABLE_API_NET)
-int
-vc_net_migrate(nid_t nid)
-{
- CALL_VC(CALL_VC_NET(vc_net_migrate, nid));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_net_remove_net(nid_t nid, struct vc_net_nx const *info)
-{
- struct vcmd_net_nx_v0 k_info;
-
- k_info.type = NETTYPE_USER2KERNEL(info->type);
- k_info.count = info->count;
-
- return vserver(VCMD_net_remove, NID_USER2KERNEL(nid), &k_info);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_NET)
-# include "syscall_netremove-net.hc"
-#endif
-
-#if defined(VC_ENABLE_API_NET) && 0
-int
-vc_net_remove(nid_t nid, struct vc_net_nx const *info)
-{
- if (info==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_NET(vc_net_remove, nid, info));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "vserver.h"
-
-static inline ALWAYSINLINE int
-vc_rem_dlimit_v13b(char const *filename, xid_t xid, uint32_t flags)
-{
- struct vcmd_ctx_dlimit_base_v0 init = {
- .name = filename,
- .flags = flags
- };
-
- return vserver(VCMD_rem_dlimit, CTX_USER2KERNEL(xid), &init);
-}
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2005 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_remdlimit-v13.hc"
-#endif
-
-int
-vc_rem_dlimit(char const *filename, xid_t xid, uint32_t flags)
-{
- CALL_VC(CALL_VC_V13B(vc_rem_dlimit, filename, xid, flags));
-}
+++ /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
-
-#define KERN2USR(LIMIT) \
- (((LIMIT)==CRLIM_INFINITY) ? VC_LIM_INFINITY : \
- ((LIMIT)==CRLIM_KEEP) ? VC_LIM_KEEP : (LIMIT))
-
-#define USR2KERN(LIMIT) \
- (((LIMIT)==VC_LIM_INFINITY) ? CRLIM_INFINITY : \
- ((LIMIT)==VC_LIM_KEEP) ? CRLIM_KEEP : (LIMIT))
-
-static inline ALWAYSINLINE int
-vc_get_rlimit_v11(xid_t ctx, int resource, struct vc_rlimit *lim)
-{
- struct vcmd_ctx_rlimit_v0 vc_lim;
- int rc;
-
- vc_lim.id = resource;
- rc = vserver(VCMD_get_rlimit, CTX_USER2KERNEL(ctx), &vc_lim);
- lim->min = KERN2USR(vc_lim.minimum);
- lim->soft = KERN2USR(vc_lim.softlimit);
- lim->hard = KERN2USR(vc_lim.maximum);
-
- return rc;
-}
-
-static inline ALWAYSINLINE int
-vc_set_rlimit_v11(xid_t ctx, int resource, struct vc_rlimit const *lim)
-{
- struct vcmd_ctx_rlimit_v0 vc_lim;
-
- vc_lim.id = resource;
- vc_lim.minimum = USR2KERN(lim->min);
- vc_lim.softlimit = USR2KERN(lim->soft);
- vc_lim.maximum = USR2KERN(lim->hard);
-
- return vserver(VCMD_set_rlimit, CTX_USER2KERNEL(ctx), &vc_lim);
-}
-
-static inline ALWAYSINLINE int
-vc_get_rlimit_mask_v11(xid_t ctx, int UNUSED tmp, struct vc_rlimit_mask *lim)
-{
- struct vcmd_ctx_rlimit_mask_v0 vc_lim;
- int rc;
-
- rc = vserver(VCMD_get_rlimit_mask, CTX_USER2KERNEL(ctx), &vc_lim);
-
- lim->min = vc_lim.minimum;
- lim->soft = vc_lim.softlimit;
- lim->hard = vc_lim.maximum;
-
- return rc;
-}
-
-#undef KERN2USR
-#undef USR2KERN
+++ /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 "compat.h"
-
-#include "vserver.h"
-#include "internal.h"
-#include "linuxvirtual.h"
-
-
-#include "vserver-internal.h"
-
-#if defined(VC_ENABLE_API_V11) || defined(VC_ENABLE_API_V13)
-# include "syscall_rlimit-v11.hc"
-#endif
-
-#ifdef VC_ENABLE_API_V13
-# define vc_get_rlimit_v13 vc_get_rlimit_v11
-# define vc_set_rlimit_v13 vc_set_rlimit_v11
-# define vc_get_rlimit_mask_v13 vc_get_rlimit_mask_v11
-#endif
-
-
-#if defined(VC_ENABLE_API_V11) || defined(VC_ENABLE_API_V13)
-
- // NOTICE: the reverse order of V11 -> V13 is correct here since these are
- // the same syscalls
-
-int
-vc_get_rlimit(xid_t ctx, int resource, struct vc_rlimit *lim)
-{
- CALL_VC(CALL_VC_V11(vc_get_rlimit, ctx, resource, lim),
- CALL_VC_V13(vc_get_rlimit, ctx, resource, lim));
-}
-
-int
-vc_set_rlimit(xid_t ctx, int resource, struct vc_rlimit const *lim)
-{
- CALL_VC(CALL_VC_V11(vc_set_rlimit, ctx, resource, lim),
- CALL_VC_V13(vc_set_rlimit, ctx, resource, lim));
-}
-
-int
-vc_get_rlimit_mask(xid_t ctx, struct vc_rlimit_mask *lim)
-{
- CALL_VC(CALL_VC_V11(vc_get_rlimit_mask, ctx, 0, lim),
- CALL_VC_V13(vc_get_rlimit_mask, ctx, 0, lim));
-}
-
-
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_set_ccaps_v13(xid_t xid, struct vc_ctx_caps const *caps)
-{
- struct vcmd_ctx_caps_v0 k_caps;
-
- k_caps.bcaps = caps->bcaps & caps->bmask;
- k_caps.ccaps = caps->ccaps;
- k_caps.cmask = caps->cmask;
-
- return vserver(VCMD_set_ccaps, CTX_USER2KERNEL(xid), &k_caps);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_V13)
-# include "syscall_setccaps-v13.hc"
-#endif
-
-#if defined(VC_ENABLE_API_V13)
-int
-vc_set_ccaps(xid_t xid, struct vc_ctx_caps const *caps)
-{
- if (caps==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_V13A(vc_set_ccaps, xid, caps));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_set_cflags_v13(xid_t xid, struct vc_ctx_flags const *flags)
-{
- struct vcmd_ctx_flags_v0 k_flags;
-
- if (flags==0) {
- errno = EFAULT;
- return -1;
- }
-
- k_flags.flagword = flags->flagword;
- k_flags.mask = flags->mask;
-
- return vserver(VCMD_set_cflags, CTX_USER2KERNEL(xid), &k_flags);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_V13)
-# include "syscall_setcflags-v13.hc"
-#endif
-
-#if defined(VC_ENABLE_API_V13)
-int
-vc_set_cflags(xid_t xid, struct vc_ctx_flags const *flags)
-{
- if (flags==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_V13A(vc_set_cflags, xid, flags));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "vserver.h"
-
-static inline ALWAYSINLINE int
-vc_set_dlimit_v13b(char const *filename, xid_t xid,
- uint_least32_t flags, struct vc_ctx_dlimit const *limits)
-{
- struct vcmd_ctx_dlimit_v0 attr = {
- .name = filename,
- .flags = flags,
- .space_used = CDLIM_USER2KERNEL(limits->space_used),
- .space_total = CDLIM_USER2KERNEL(limits->space_total),
- .inodes_used = CDLIM_USER2KERNEL(limits->inodes_used),
- .inodes_total = CDLIM_USER2KERNEL(limits->inodes_total),
- .reserved = CDLIM_USER2KERNEL(limits->reserved),
- };
-
- return vserver(VCMD_set_dlimit, CTX_USER2KERNEL(xid), &attr);
-}
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2005 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_setdlimit-v13.hc"
-#endif
-
-int
-vc_set_dlimit(char const *filename, xid_t xid,
- uint_least32_t flags, struct vc_ctx_dlimit const *limits)
-{
- CALL_VC(CALL_VC_V13B(vc_set_dlimit, filename, xid, flags, limits));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "ioctl-setext2flags.hc"
-#include "ioctl-setfilecontext.hc"
-#include "ioctl-setxflg.hc"
-#include "ioctl-getxflg.hc"
-
-#include <fcntl.h>
-
-static inline ALWAYSINLINE int
-vc_set_iattr_fscompat(char const *filename,
- xid_t xid,
- uint32_t flags, uint32_t mask)
-{
- int fd;
- struct stat st;
- int stat_rc;
-
- fd = open(filename, O_RDONLY);
- if (fd==-1) return -1;
-
- stat_rc = fstat(fd, &st);
- if (stat_rc==-1) goto err;
-
- if ( (mask&VC_IATTR_IUNLINK) ) {
- unsigned int const tmp = VC_IMMUTABLE_FILE_FL|VC_IMMUTABLE_LINK_FL;
- if (vc_X_set_ext2flags(fd,
- (flags&VC_IATTR_IUNLINK) ? tmp : 0,
- (flags&VC_IATTR_IUNLINK) ? 0 : tmp)==-1)
- goto err;
- }
-
- if ( (mask&VC_IATTR_BARRIER) ) {
- mode_t m = ((flags&VC_IATTR_BARRIER) ? 0 :
- st.st_mode ? st.st_mode : 0500);
-
- if (fchmod(fd, m)==-1)
- goto err;
- }
-
- if ( (mask&VC_IATTR_XID) &&
- vc_X_set_filecontext(fd, xid)==-1)
- goto err;
-
- if ( (mask&(VC_IATTR_HIDE|VC_IATTR_WATCH)) ) {
- long tmp;
- if (vc_X_get_xflg(fd, &tmp)==-1) goto err;
-
- tmp &= ~( ((mask&VC_IATTR_HIDE) ? 1 : 0) |
- ((mask&VC_IATTR_WATCH) ? 2 : 0) );
- tmp |= ( ((flags&VC_IATTR_HIDE) ? 1 : 0) |
- ((flags&VC_IATTR_WATCH) ? 2 : 0) );
-
- if (vc_X_set_xflg(fd, tmp)==-1) goto err;
- }
-
- close(fd);
- return 0;
- err:
- {
- int old_errno = errno;
- close(fd);
- errno = old_errno;
- return -1;
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-
-static inline ALWAYSINLINE int
-vc_set_iattr_v13(char const *filename, xid_t xid, uint32_t flags, uint32_t mask)
-{
- struct vcmd_ctx_iattr_v1 attr;
-
- attr.name = filename;
- attr.xid = CTX_USER2KERNEL(xid);
- attr.flags = flags;
- attr.mask = mask;
- return vserver(VCMD_set_iattr, 0, &attr);
-}
+++ /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 "vserver.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_FSCOMPAT) && defined(VC_ENABLE_API_V13)
-# define VC_MULTIVERSION_SYSCALL 1
-#endif
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_setiattr-v13.hc"
-#endif
-
-#ifdef VC_ENABLE_API_FSCOMPAT
-# include "syscall_setiattr-fscompat.hc"
-#endif
-
-int
-vc_set_iattr(char const *filename, xid_t xid, uint32_t flags, uint32_t mask)
-{
- CALL_VC(CALL_VC_V13 (vc_set_iattr, filename, xid, flags, mask),
- CALL_VC_FSCOMPAT(vc_set_iattr, filename, xid, flags, mask));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-
-static inline ALWAYSINLINE int
-vc_set_namespace_v13(int UNUSED tmp)
-{
- return vserver(VCMD_set_namespace, 0, 0);
-}
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_setnamespace-v13.hc"
-#endif
-
-int
-vc_set_namespace()
-{
- CALL_VC(CALL_VC_V13(vc_set_namespace,0));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_set_ncaps_net(nid_t nid, struct vc_net_caps const *caps)
-{
- struct vcmd_net_caps_v0 k_caps;
-
- k_caps.ncaps = caps->ncaps;
- k_caps.cmask = caps->cmask;
-
- return vserver(VCMD_set_ncaps, NID_USER2KERNEL(nid), &k_caps);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_NET)
-# include "syscall_setncaps-net.hc"
-#endif
-
-#if defined(VC_ENABLE_API_NET)
-int
-vc_set_ncaps(nid_t nid, struct vc_net_caps const *caps)
-{
- if (caps==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_NET(vc_set_ncaps, nid, caps));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_set_nflags_net(nid_t nid, struct vc_net_flags const *flags)
-{
- struct vcmd_net_flags_v0 k_flags;
-
- if (flags==0) {
- errno = EFAULT;
- return -1;
- }
-
- k_flags.flagword = flags->flagword;
- k_flags.mask = flags->mask;
-
- return vserver(VCMD_set_nflags, NID_USER2KERNEL(nid), &k_flags);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "vserver-internal.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_NET)
-# include "syscall_setnflags-net.hc"
-#endif
-
-#if defined(VC_ENABLE_API_NET)
-int
-vc_set_nflags(nid_t nid, struct vc_net_flags const *flags)
-{
- if (flags==0) {
- errno = EFAULT;
- return -1;
- }
-
- CALL_VC(CALL_VC_NET(vc_set_nflags, nid, flags));
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include <lib_internal/util.h>
-
-#define VCGET(MASK,VAL) ((data->set_mask & (MASK)) ? (VAL) : SCHED_KEEP);
-
-static inline ALWAYSINLINE int
-vc_set_sched_v13obs(xid_t xid, struct vc_set_sched const *data)
-{
-#warning vc_set_sched_v13() uses an obsolete interface; remove it in the final version
- struct vcmd_set_sched_v2 k_data;
-
-
- k_data.cpu_mask = 0;
- k_data.fill_rate = VCGET(VC_VXSM_FILL_RATE, data->fill_rate);
- k_data.interval = VCGET(VC_VXSM_INTERVAL, data->interval);
- k_data.tokens = VCGET(VC_VXSM_TOKENS, data->tokens);
- k_data.tokens_min = VCGET(VC_VXSM_TOKENS_MIN, data->tokens_min);
- k_data.tokens_max = VCGET(VC_VXSM_TOKENS_MAX, data->tokens_max);
-
- return vserver(VCMD_set_sched_v2, CTX_USER2KERNEL(xid), &k_data);
-}
-
-#define X(ATTR) ENSC_SAME_STRUCT_IDX(k_data, *data, ATTR)
-
-static inline ALWAYSINLINE int
-vc_set_sched_v13b(xid_t xid, struct vc_set_sched const *data)
-{
- struct vcmd_set_sched_v3 k_data;
-
- // This expression will be evaluated at compile-time
- if (sizeof(struct vcmd_set_sched_v3)==sizeof(struct vc_set_sched) &&
- X(set_mask) && X(fill_rate) && X(interval) && X(tokens) &&
- X(tokens_min) && X(tokens_max) && X(priority_bias))
- return vserver(VCMD_set_sched, CTX_USER2KERNEL(xid),
- const_cast(struct vc_set_sched *)(data));
- else {
- k_data.set_mask = data->set_mask;
- k_data.fill_rate = data->fill_rate;
- k_data.interval = data->interval;
- k_data.tokens = data->tokens;
- k_data.tokens_min = data->tokens_min;
- k_data.tokens_max = data->tokens_max;
- k_data.priority_bias = data->priority_bias;
-
- return vserver(VCMD_set_sched, CTX_USER2KERNEL(xid), &k_data);
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#define VC_MULTIVERSION_SYSCALL 1
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_setsched-v13.hc"
-#endif
-
-int
-vc_set_sched(xid_t xid, struct vc_set_sched const *data)
-{
- CALL_VC(CALL_VC_V13B (vc_set_sched,xid,data),
- CALL_VC_V13OBS(vc_set_sched,xid,data));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-static inline ALWAYSINLINE int
-vc_set_vhi_name_olduts(xid_t xid, vc_uts_type type, char const *val, size_t len)
-{
- if (xid!=VC_SAMECTX) {
- errno = ESRCH;
- return -1;
- }
-
- switch (type) {
- case vcVHI_NODENAME : return sethostname (val, len);
- case vcVHI_DOMAINNAME : return setdomainname(val, len);
- default :
- errno = ENOENT;
- return -1;
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 <string.h>
-
-static inline ALWAYSINLINE int
-vc_set_vhi_name_v13(xid_t xid, vc_uts_type type, char const *val, size_t len)
-{
- struct vcmd_vx_vhi_name_v0 cmd;
- int rc;
-
- if (len>=sizeof(cmd.name)) {
- errno = E2BIG;
- return -1;
- }
-
- cmd.field = VHI_USER2KERNEL(type);
- memcpy(cmd.name, val, len);
- cmd.name[len] = '\0';
-
- rc = vserver(VCMD_vx_set_vhi_name, CTX_USER2KERNEL(xid), &cmd);
- ENSC_FIX_IOCTL(rc);
-
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "linuxvirtual.h"
-
-#if defined(VC_ENABLE_API_OLDUTS) && defined(VC_ENABLE_API_V13)
-# define VC_MULTIVERSION_SYSCALL 1
-#endif
-#include "vserver-internal.h"
-
-#ifdef VC_ENABLE_API_V13
-# include "syscall_setvhiname-v13.hc"
-#endif
-
-#ifdef VC_ENABLE_API_OLDUTS
-# include "syscall_setvhiname-olduts.hc"
-#endif
-
-int
-vc_set_vhi_name(xid_t xid, vc_uts_type type, char const *val, size_t len)
-{
- if (len==(size_t)(-1)) len=strlen(val);
-
- CALL_VC(CALL_VC_V13 (vc_set_vhi_name, xid, type, val, len),
- CALL_VC_OLDUTS(vc_set_vhi_name, xid, type, val, len));
-}
+++ /dev/null
-.deps
-.dirstamp
-.gdb_history
-.libs
-cflags
-flags
-fmt
-parselimit
+++ /dev/null
-## $Id$ --*- makefile -*--
-
-## Copyright (C) 2004 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.
-
-DIETPROGS += lib/testsuite/cflags \
- lib/testsuite/fmt
-
-check_PROGRAMS += lib/testsuite/cflags \
- lib/testsuite/fmt \
- lib/testsuite/parselimit
-TESTS += lib/testsuite/cflags \
- lib/testsuite/fmt \
- lib/testsuite/parselimit
-
-lib_testsuite_cflags_SOURCES = lib/testsuite/cflags.c
-lib_testsuite_cflags_LDADD = $(LIBVSERVER)
-lib_testsuite_cflags_LDFLAGS = $(VSERVER_LDFLGS)
-lib_testsuite_cflags_CPPFLAGS = $(AM_CPPFLAGS) -DENSC_TESTSUITE
-
-lib_testsuite_fmt_SOURCES = lib/testsuite/fmt.c
-lib_testsuite_fmt_LDADD = $(LIBVSERVER)
-lib_testsuite_fmt_LDFLAGS = $(VSERVER_LDFLGS)
-lib_testsuite_fmt_CPPFLAGS = $(AM_CPPFLAGS) -DENSC_TESTSUITE
-
-lib_testsuite_parselimit_SOURCES = lib/testsuite/parselimit.c
-lib_testsuite_parselimit_LDADD = $(LIBVSERVER)
-lib_testsuite_parselimit_LDFLAGS = $(VSERVER_LDFLGS)
-lib_testsuite_parselimit_CPPFLAGS = $(AM_CPPFLAGS) -DENSC_TESTSUITE
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-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 "lib_internal/coreassert.h"
-#include "vserver.h"
-
-#include <string.h>
-#include <unistd.h>
-
-
-#define TEST_T2F_C(X,Y,Z) assert(vc_text2cflag_compat(X,Y)==Z)
-#define TEST_F2T_C(Y,X) { \
- char const *x=vc_hicflag2text_compat(X); \
- assert((x==0 && Y==0) || (x!=0 && Y!=0)); \
- if (x!=0 && Y!=0) assert(strcmp(x, Y ? Y : "")==0); \
- }
-
-#define TEST_LIST_C(STR,LEN,EXP,ERR_POS,ERR_LEN) { \
- struct vc_err_listparser err; \
- char buf[] = STR; \
- uint32_t res; \
- res = vc_list2cflag_compat(buf, LEN, &err); \
- assert(res==(EXP)); \
- assert(err.len==ERR_LEN); \
- if (ERR_POS==-1) assert(err.ptr==0); \
- else assert(err.ptr==buf+(ERR_POS)); \
- }
-
-//----
-
-#define TEST_T2F(X,Y,Z) assert(vc_text2cflag(X,Y)==Z)
-#define TEST_F2T(Y,X) { \
- uint_least64_t x = (X); \
- char const *rc=vc_locflag2text(&x); \
- assert((rc==0 && Y==0) || (rc!=0 && Y!=0)); \
- if (rc!=0 && Y!=0) assert(strcmp(rc, Y ? Y : "")==0); \
- }
-#define TEST_LIST(STR,LEN,EXP_RES,EXP_FLAG,EXP_MASK,ERR_POS,ERR_LEN) { \
- struct vc_err_listparser err; \
- char buf[] = STR; \
- volatile int res; \
- struct vc_ctx_flags flags = {0,0}; \
- res = vc_list2cflag(buf, LEN, &err, &flags); \
- assert(res==(EXP_RES)); \
- assert(flags.flagword==(uint_least64_t)(EXP_FLAG)); \
- assert(flags.mask ==(uint_least64_t)(EXP_MASK)); \
- assert(err.len==ERR_LEN); \
- if (ERR_POS==-1) assert(err.ptr==0); \
- else assert(err.ptr==buf+(ERR_POS)); \
- }
-
-#define ALL64 (~(uint_least64_t)(0))
-
-int main()
-{
- TEST_T2F_C("lock", 0, S_CTX_INFO_LOCK);
- TEST_T2F_C("lockXXXX", 4, S_CTX_INFO_LOCK);
- TEST_T2F_C("locXXXXX", 3, 0);
- TEST_T2F_C("sched", 0, S_CTX_INFO_SCHED);
- TEST_T2F_C("nproc", 0, S_CTX_INFO_NPROC);
- TEST_T2F_C("private", 0, S_CTX_INFO_PRIVATE);
- TEST_T2F_C("fakeinit", 0, S_CTX_INFO_INIT);
- TEST_T2F_C("hideinfo", 0, S_CTX_INFO_HIDEINFO);
- TEST_T2F_C("ulimit", 0, S_CTX_INFO_ULIMIT);
- TEST_T2F_C("XXX", 0, 0);
- TEST_T2F_C("", 0, 0);
-
- TEST_F2T_C("lock", S_CTX_INFO_LOCK);
- TEST_F2T_C("sched", S_CTX_INFO_SCHED);
- TEST_F2T_C("nproc", S_CTX_INFO_NPROC);
- TEST_F2T_C("private", S_CTX_INFO_PRIVATE);
- TEST_F2T_C("fakeinit", S_CTX_INFO_INIT);
- TEST_F2T_C("hideinfo", S_CTX_INFO_HIDEINFO);
- TEST_F2T_C("ulimit", S_CTX_INFO_ULIMIT);
- TEST_F2T_C(0, 0);
- TEST_F2T_C("ulimit", 64 | 128 | 23 );
- TEST_F2T_C("fakeinit", 23);
-
- TEST_LIST_C("lock", 0, S_CTX_INFO_LOCK, -1,0);
- TEST_LIST_C("lock,sched,", 0, S_CTX_INFO_LOCK|S_CTX_INFO_SCHED, -1,0);
- TEST_LIST_C("lock,XXX", 0, S_CTX_INFO_LOCK, 5,3);
- TEST_LIST_C("", 0, 0, -1,0);
- TEST_LIST_C("X", 0, 0, 0,1);
- TEST_LIST_C("lock,sched,", 10, S_CTX_INFO_LOCK|S_CTX_INFO_SCHED, -1,0);
-
- //-------
-
- TEST_T2F("fakeinit", 0, VC_VXF_INFO_INIT);
- TEST_T2F("XXX", 0, 0);
- TEST_T2F("", 0, 0);
-
- TEST_F2T("fakeinit", VC_VXF_INFO_INIT);
- TEST_F2T(0, 0);
-
- TEST_LIST("fakeinit", 0, 0, VC_VXF_INFO_INIT, VC_VXF_INFO_INIT,-1,0);
- TEST_LIST("FaKeInIt", 0, 0, VC_VXF_INFO_INIT, VC_VXF_INFO_INIT,-1,0);
- TEST_LIST("~fakeinit", 0, 0, 0, VC_VXF_INFO_INIT,-1,0);
- TEST_LIST("!fakeinit", 0, 0, 0, VC_VXF_INFO_INIT,-1,0);
- TEST_LIST("fakeinit,XXX", 0, -1, VC_VXF_INFO_INIT, VC_VXF_INFO_INIT, 9,3);
- TEST_LIST("", 0, 0, 0, 0, -1,0);
- TEST_LIST("0", 0, 0, 0, 0, -1,0);
- TEST_LIST("00", 0, 0, 0, 0, -1,0);
- TEST_LIST("X", 0, -1, 0, 0, 0,1);
- TEST_LIST("all", 0, 0, ALL64, ALL64, -1,0);
- TEST_LIST("ALL", 0, 0, ALL64, ALL64, -1,0);
- TEST_LIST("any", 0, 0, ALL64, ALL64, -1,0);
- TEST_LIST("ANY", 0, 0, ALL64, ALL64, -1,0);
- TEST_LIST("~all", 0, 0, 0, ALL64, -1,0);
- TEST_LIST("~ALL", 0, 0, 0, ALL64, -1,0);
- TEST_LIST("none", 0, 0, 0, 0, -1,0);
- TEST_LIST("NONE", 0, 0, 0, 0, -1,0);
- TEST_LIST("~none", 0, 0, 0, 0, -1,0);
- TEST_LIST("~NONE", 0, 0, 0, 0, -1,0);
- TEST_LIST("all,~fakeinit",0, 0, ~VC_VXF_INFO_INIT,ALL64, -1,0);
- TEST_LIST("~all,fakeinit",0, 0, VC_VXF_INFO_INIT, ALL64, -1,0);
- TEST_LIST("fakeinit,~all",0, 0, 0, ALL64, -1,0);
- TEST_LIST("none,~lock", 0, 0, 0, VC_VXF_INFO_LOCK,-1,0);
- TEST_LIST("~none,lock", 0, 0, VC_VXF_INFO_LOCK,VC_VXF_INFO_LOCK,-1,0);
- TEST_LIST("lock,none", 0, 0, VC_VXF_INFO_LOCK,VC_VXF_INFO_LOCK,-1,0);
- TEST_LIST("lock,~none", 0, 0, VC_VXF_INFO_LOCK,VC_VXF_INFO_LOCK,-1,0);
- TEST_LIST("~", 0, -1, 0, 0, 1,0);
- TEST_LIST("~~", 0, -1, 0, 0, 2,0);
- TEST_LIST("!", 0, -1, 0, 0, 1,0);
- TEST_LIST("^", 0, -1, 0, 0, 1,0);
- TEST_LIST("fakeinit,~", 0, -1, VC_VXF_INFO_INIT, VC_VXF_INFO_INIT,10,0);
- TEST_LIST("1", 0, 0, 1, 1, -1,0);
- TEST_LIST("1,23,42", 0, 0, 1|23|42, 1|23|42, -1,0);
- TEST_LIST("~1", 0, 0, 0, 1, -1,0);
- TEST_LIST("!1", 0, 0, 0, 1, -1,0);
- TEST_LIST("~~1", 0, 0, 1, 1, -1,0);
- TEST_LIST("~~~1", 0, 0, 0, 1, -1,0);
- TEST_LIST("~!~1", 0, 0, 0, 1, -1,0);
- TEST_LIST("42,fakeinit", 0, 0, VC_VXF_INFO_INIT|42, VC_VXF_INFO_INIT|42, -1,0);
- TEST_LIST("42x,1", 0, -1, 0, 0, 0,3);
-
- TEST_LIST("^4,~^2", 0, 0, 0x10, 0x14, -1,0);
- TEST_LIST("^4,~~^2", 0, 0, 0x14, 0x14, -1,0);
- TEST_LIST("^4,~~~^2", 0, 0, 0x10, 0x14, -1,0);
- TEST_LIST("~^2,^4", 0, 0, 0x10, 0x14, -1,0);
- TEST_LIST("1,^1,~^2,8", 0, 0, 0x0b, 0x0f, -1,0);
-
- TEST_LIST("lock,nproc,private,fakeinit,hideinfo,ulimit,namespace,"
- "sched_hard,sched_prio,sched_pause,"
- "virt_mem,virt_uptime,virt_cpu,virt_load,"
- "hide_mount,hide_netif,state_setup,state_init,"
- "fork_rss,prolific,igneg_nice",
- 0, 0,
- VC_VXF_INFO_LOCK|VC_VXF_INFO_NPROC|VC_VXF_INFO_PRIVATE|VC_VXF_INFO_INIT|
- VC_VXF_INFO_HIDEINFO|VC_VXF_INFO_ULIMIT|VC_VXF_INFO_NAMESPACE|
- VC_VXF_SCHED_HARD|VC_VXF_SCHED_PRIO|VC_VXF_SCHED_PAUSE|
- VC_VXF_VIRT_MEM|VC_VXF_VIRT_UPTIME|VC_VXF_VIRT_CPU|VC_VXF_VIRT_LOAD|
- VC_VXF_HIDE_MOUNT|VC_VXF_HIDE_NETIF|
- VC_VXF_STATE_SETUP|VC_VXF_STATE_INIT|
- VC_VXF_FORK_RSS|VC_VXF_PROLIFIC|VC_VXF_IGNEG_NICE,
-
- VC_VXF_INFO_LOCK|VC_VXF_INFO_NPROC|VC_VXF_INFO_PRIVATE|VC_VXF_INFO_INIT|
- VC_VXF_INFO_HIDEINFO|VC_VXF_INFO_ULIMIT|VC_VXF_INFO_NAMESPACE|
- VC_VXF_SCHED_HARD|VC_VXF_SCHED_PRIO|VC_VXF_SCHED_PAUSE|
- VC_VXF_VIRT_MEM|VC_VXF_VIRT_UPTIME|VC_VXF_VIRT_CPU|VC_VXF_VIRT_LOAD|
- VC_VXF_HIDE_MOUNT|VC_VXF_HIDE_NETIF|
- VC_VXF_STATE_SETUP|VC_VXF_STATE_INIT|
- VC_VXF_FORK_RSS|VC_VXF_PROLIFIC|VC_VXF_IGNEG_NICE,
-
- -1,0);
-
- TEST_LIST("~lock,~nproc,~private,~fakeinit,~hideinfo,~ulimit,~namespace,"
- "~sched_hard,~sched_prio,~sched_pause,"
- "~virt_mem,~virt_uptime,~virt_cpu,~virt_load,"
- "~hide_mount,~hide_netif,~state_setup,~state_init,"
- "~fork_rss,~prolific,~igneg_nice",
- 0, 0,
- 0,
- VC_VXF_INFO_LOCK|VC_VXF_INFO_NPROC|VC_VXF_INFO_PRIVATE|VC_VXF_INFO_INIT|
- VC_VXF_INFO_HIDEINFO|VC_VXF_INFO_ULIMIT|VC_VXF_INFO_NAMESPACE|
- VC_VXF_SCHED_HARD|VC_VXF_SCHED_PRIO|VC_VXF_SCHED_PAUSE|
- VC_VXF_VIRT_MEM|VC_VXF_VIRT_UPTIME|VC_VXF_VIRT_CPU|VC_VXF_VIRT_LOAD|
- VC_VXF_HIDE_MOUNT|VC_VXF_HIDE_NETIF|
- VC_VXF_STATE_SETUP|VC_VXF_STATE_INIT|
- VC_VXF_FORK_RSS|VC_VXF_PROLIFIC|VC_VXF_IGNEG_NICE,
-
- -1,0);
-
-
- return 0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "lib_internal/coreassert.h"
-
-#include "lib/fmt.h"
-#include <string.h>
-
-#define TEST(VAL, EXP) { \
- char buf[512]; \
- size_t l; \
- memset(buf, '\23', sizeof buf); \
- l = FUNC(buf+1, VAL); \
- assert(l==sizeof(EXP)-1); \
- assert(memcmp(buf+1, EXP, l)==0); \
- assert(buf[l+1]=='\23'); \
- }
-
-int main()
-{
- #define FUNC utilvserver_fmt_xuint64
- TEST(0, "0");
- TEST(1, "1");
- TEST(15, "f");
- TEST(16, "10");
- TEST(100, "64");
- TEST(1000, "3e8");
- TEST(65535, "ffff");
- TEST(65536, "10000");
- TEST(68719476736ul, "1000000000");
-
- return 0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "lib_internal/coreassert.h"
-#include "vserver.h"
-
-#define TEST(BUF, RES, VAL) \
- do { \
- vc_limit_t res = 0xdeadbeaf; \
- assert(vc_parseLimit(BUF, &res)==(RES)); \
- assert(res==(VAL)); \
- } while (0)
-
-#define TESTT(BUF,VAL) TEST(BUF, true, VAL)
-#define TESTF(BUF,VAL) TEST(BUF, false, VAL)
-
-int main()
-{
- TESTT("0", 0);
- TESTT("1", 1);
- TESTT("1k", 1000);
- TESTT("1K", 1024);
- TESTT("1m", 1000000);
- TESTT("1M", 1048576);
- TESTT("1234", 1234);
- TESTT("1234\n", 1234);
- TESTT("inf", VC_LIM_INFINITY);
-
- TESTF("x", 0);
- TESTF("k", 0);
- TESTF("1kX", 1000);
- TESTF("", 0);
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: @PACKAGE@
-Description: vserver libraries
-Version: @VERSION@
-Requires:
-Libs: @libflags@-lvserver
-Cflags: @incflags@
+++ /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_LIB_UTILS_COMPAT_H
-#define H_UTIL_VSERVER_LIB_UTILS_COMPAT_H
-
-#include <stdlib.h>
-#include <sys/types.h>
-
- // read /proc/<pid>/status into 'buf' which has the size bufsize. When 'str'
- // is non-null, search this string and return a pointer *after* it. When no
- // such string could be found, return 0. When 'str' is null return 'buf'.
- //
- // When this function fails (result==0) and errno is EAGAIN, the buffersize
- // was too small and this function should be called again with a larger
- // buffer.
-char * utilvserver_getProcEntry(pid_t pid, char *str,
- char *buf, size_t bufsize);
-
- // Returns the suggested buffersize for reading a /proc/.../status
- // file. Return-value can change when utilvserver_getProcEntry() was called.
-size_t utilvserver_getProcEntryBufsize();
-
-#endif // H_UTIL_VSERVER_LIB_UTILS_COMPAT_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "internal.h"
-#include "val2text.hc"
-
-TEXT2VAL(uint_least32_t, uint32)
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "internal.h"
-#include "val2text.hc"
-
-TEXT2VAL(uint_least64_t, uint64)
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "internal.h"
-#include "val2text.hc"
-
-VAL2TEXT(uint_least32_t, uint32)
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "internal.h"
-#include "val2text.hc"
-
-VAL2TEXT(uint_least64_t, uint64)
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 <stdlib.h>
-#include <string.h>
-#include <strings.h>
-
-#define VAL2TEXT(TYPE,SHORT) \
- ssize_t \
- utilvserver_value2text_##SHORT(char const *str, size_t len, \
- struct Mapping_ ##SHORT const *map, \
- size_t map_len) \
- { \
- size_t i; \
- if (len==0) len=strlen(str); \
- \
- for (i=0; i<map_len; ++i) \
- if (len==map[i].len && \
- strncasecmp(map[i].id, str, len)==0) \
- return i; \
- \
- return -1; \
- }
-
-#define TEXT2VAL(TYPE,SHORT) \
- static ssize_t \
- searchValue(TYPE val, \
- struct Mapping_##SHORT const *map, size_t map_len) \
- { \
- size_t i; \
- for (i=0; i<map_len; ++i) \
- if (val == map[i].val) return i; \
- return -1; \
- } \
- \
- ssize_t \
- utilvserver_text2value_##SHORT(TYPE *val, \
- struct Mapping_##SHORT const *map, \
- size_t map_len) \
- { \
- ssize_t idx; \
- TYPE del_val; \
- if (*val==0) \
- return -1; \
- \
- del_val = *val; \
- idx = searchValue(del_val, map, map_len); \
- \
- if (idx==-1) { \
- size_t i; \
- for (i=0; i<sizeof(*val)*8 && (*val&(1<<i))==0; ++i) {} \
- del_val = (1<<i); \
- idx = searchValue(del_val, map, map_len); \
- } \
- *val &= ~del_val; \
- return idx; \
- }
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_VIRTUAL_H
-#define H_UTIL_VSERVER_LIB_VIRTUAL_H
-
-#include <kernel/context.h>
-#include <kernel/legacy.h>
-#include <kernel/limit.h>
-#include <kernel/signal.h>
-#include <kernel/namespace.h>
-#include <kernel/inode.h>
-#include <kernel/sched.h>
-#include <kernel/dlimit.h>
-
-#endif // H_UTIL_VSERVER_LIB_VIRTUAL_H
+++ /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 H_VSERVER_SYSCALL_INTERNAL_H
-# error vserver-internal.h must not be included more than once
-#endif
-
-#ifndef H_VSERVER_SYSCALL_INTERNAL_H
-#define H_VSERVER_SYSCALL_INTERNAL_H
-
-#include <asm/unistd.h>
-#include <syscall.h>
-#include <errno.h>
-#include <stdint.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-
-#include "internal.h"
-
-#if !defined(__NR_vserver) && defined(ENSC_SYSCALL__NR_vserver)
-# define __NR_vserver ENSC_SYSCALL__NR_vserver
-#endif
-
-inline static ALWAYSINLINE void vc_noop0() {}
-
-#define VC_PREFIX 0)
-#define VC_SUFFIX else (void)(vc_noop0()
-#define CALL_VC_NOOP vc_noop0()
-#define CALL_VC_GENERAL(ID, SUFFIX, FUNC, ...) \
- VC_PREFIX; VC_SELECT(ID) return FUNC ## _ ## SUFFIX(__VA_ARGS__); VC_SUFFIX
-
-#ifdef VC_MULTIVERSION_SYSCALL
-# define VC_SELECT(ID) if (ver>=(ID))
-# define CALL_VC(...) \
- do { \
- int ver = utilvserver_checkCompatVersion(); \
- if (ver==-1) return -1; \
- VC_SUFFIX, __VA_ARGS__, VC_PREFIX; \
- errno = ENOSYS; \
- return -1; \
- } while (0)
-#else
-# define VC_SELECT(ID) if (1)
-# define CALL_VC(...) \
- do { \
- if (1) {} VC_SUFFIX, __VA_ARGS__, VC_PREFIX; \
- errno = ENOSYS; return -1; \
- } while (0)
-#endif
-
-#ifdef VC_ENABLE_API_COMPAT
-# define CALL_VC_COMPAT(F,...) CALL_VC_GENERAL(0x00010000, compat, F, __VA_ARGS__)
-#else
-# define CALL_VC_COMPAT(F,...) CALL_VC_NOOP
-#endif
-
-#ifdef VC_ENABLE_API_LEGACY
-# define CALL_VC_LEGACY(F,...) CALL_VC_GENERAL(0x00000000, legacy, F, __VA_ARGS__)
-#else
-# define CALL_VC_LEGACY(F,...) CALL_VC_NOOP
-#endif
-
-#ifdef VC_ENABLE_API_V11
-# define CALL_VC_V11(F,...) CALL_VC_GENERAL(0x00010000, v11, F, __VA_ARGS__)
-#else
-# define CALL_VC_V11(F,...) CALL_VC_NOOP
-#endif
-
-#ifdef VC_ENABLE_API_V13
-# define CALL_VC_V13(F,...) CALL_VC_GENERAL(0x00010011, v13, F, __VA_ARGS__)
-#else
-# define CALL_VC_V13(F,...) CALL_VC_NOOP
-#endif
-
-#ifdef VC_ENABLE_API_V13
-# define CALL_VC_V13A(F,...) CALL_VC_GENERAL(0x00010012, v13, F, __VA_ARGS__)
-#else
-# define CALL_VC_V13A(F,...) CALL_VC_NOOP
-#endif
-
-#ifdef VC_ENABLE_API_V13
-# define CALL_VC_V13B(F,...) CALL_VC_GENERAL(0x00010021, v13b, F, __VA_ARGS__)
-#else
-# define CALL_VC_V13B(F,...) CALL_VC_NOOP
-#endif
-
-#ifdef VC_ENABLE_API_V13
-# define CALL_VC_V13OBS(F,...) CALL_VC_GENERAL(0x00010011, v13obs, F, __VA_ARGS__)
-#else
-# define CALL_VC_V13OBS(F,...) CALL_VC_NOOP
-#endif
-
-
-#ifdef VC_ENABLE_API_NET
-# define CALL_VC_NET(F,...) CALL_VC_GENERAL(0x00010016, net, F, __VA_ARGS__)
-#else
-# define CALL_VC_NET(F,...) CALL_VC_NOOP
-#endif
-
-#ifdef VC_ENABLE_API_FSCOMPAT
-# define CALL_VC_FSCOMPAT(F,...) CALL_VC_GENERAL(0x00010000, fscompat, F, __VA_ARGS__)
-#else
-# define CALL_VC_FSCOMPAT(F,...) CALL_VC_NOOP
-#endif
-
-#ifdef VC_ENABLE_API_OLDPROC
-# define CALL_VC_OLDPROC(F,...) CALL_VC_GENERAL(0x00000000, oldproc, F, __VA_ARGS__)
-#else
-# define CALL_VC_OLDPROC(F,...) CALL_VC_NOOP
-#endif
-
-#ifdef VC_ENABLE_API_OLDUTS
-# define CALL_VC_OLDUTS(F,...) CALL_VC_GENERAL(0x00000000, olduts, F, __VA_ARGS__)
-#else
-# define CALL_VC_OLDUTS(F,...) CALL_VC_NOOP
-#endif
-
-
- // Some kernel <-> userspace wrappers; they should be noops in most cases
-
-#if 1
-# define CTX_KERNEL2USER(X) (((X)==(uint32_t)(-1)) ? VC_NOCTX : \
- ((X)==(uint32_t)(-2)) ? VC_SAMECTX : \
- (xid_t)(X))
-
-# define CTX_USER2KERNEL(X) (((X)==VC_DYNAMIC_XID) ? (uint32_t)(-1) : \
- ((X)==VC_SAMECTX) ? (uint32_t)(-2) : \
- (uint32_t)(X))
-#else
-# define CTX_USER2KERNEL(X) (X)
-# define CTX_KERNEL2USER(X) (X)
-#endif
-
-#if 1
-# define EXT2FLAGS_USER2KERNEL(X) (((X) & ~(VC_IMMUTABLE_FILE_FL|VC_IMMUTABLE_LINK_FL)) | \
- ((X) & VC_IMMUTABLE_FILE_FL ? EXT2_IMMUTABLE_FILE_FL : 0) | \
- ((X) & VC_IMMUTABLE_LINK_FL ? EXT2_IMMUTABLE_LINK_FL : 0))
-# define EXT2FLAGS_KERNEL2USER(X) (((X) & ~(EXT2_IMMUTABLE_FILE_FL|EXT2_IMMUTABLE_LINK_FL)) | \
- ((X) & EXT2_IMMUTABLE_FILE_FL ? VC_IMMUTABLE_FILE_FL : 0) | \
- ((X) & EXT2_IMMUTABLE_LINK_FL ? VC_IMMUTABLE_LINK_FL : 0))
-#else
-# define EXT2FLAGS_KERNEL2USER(X) (X)
-# define EXT2FLAGS_USER2KERNEL(X) (X)
-#endif
-
-#if 1
-# define VHI_USER2KERNEL(X) ((((X)==vcVHI_CONTEXT) ? VHIN_CONTEXT : \
- ((X)==vcVHI_SYSNAME) ? VHIN_SYSNAME : \
- ((X)==vcVHI_NODENAME) ? VHIN_NODENAME : \
- ((X)==vcVHI_RELEASE) ? VHIN_RELEASE : \
- ((X)==vcVHI_VERSION) ? VHIN_VERSION : \
- ((X)==vcVHI_MACHINE) ? VHIN_MACHINE : \
- ((X)==vcVHI_DOMAINNAME) ? VHIN_DOMAINNAME : \
- (X)))
-# define VHI_KERNEL2USER(X) ((((X)==VHIN_CONTEXT) ? vcVHI_CONTEXT : \
- ((X)==VHIN_SYSNAME) ? vcVHI_SYSNAME : \
- ((X)==VHIN_NODENAME) ? vcVHI_NODENAME : \
- ((X)==VHIN_RELEASE) ? vcVHI_RELEASE : \
- ((X)==VHIN_VERSION) ? vcVHI_VERSION : \
- ((X)==VHIN_MACHINE) ? vcVHI_MACHINE : \
- ((X)==VHIN_DOMAINNAME) ? vcVHI_DOMAINNAME : \
- (X)))
-#else
-# define VHI_USER2KERNEL(X) (X)
-# define VHI_KERNEL2USER(X) (X)
-#endif
-
-#if 1
-# define NID_KERNEL2USER(X) (((X)==(uint32_t)(-1)) ? VC_NONID : \
- (xid_t)(X))
-
-# define NID_USER2KERNEL(X) (((X)==VC_DYNAMIC_NID) ? (uint32_t)(-1) : \
- (uint32_t)(X))
-#else
-# define NID_USER2KERNEL(X) (X)
-# define NID_KERNEL2USER(X) (X)
-#endif
-
-#if 1
-# define NETTYPE_USER2KERNEL(X) ((X)==vcNET_IPV4 ? 0 : \
- (X)==vcNET_IPV6 ? 1 : \
- (X)==vcNET_IPV4R ? 2 : \
- (X)==vcNET_IPV6R ? 3 : \
- (X))
-# define NETTYPE_KERNEL2USER(X) ((X)==0 ? vcNET_IPV4 ? : \
- (X)==1 ? vcNET_IPV6 ? : \
- (X)==2 ? vcNET_IPV4R ? : \
- (X)==3 ? vcNET_IPV6R ? : \
- (vc_net_nx_type)(X))
-#else
-# define NETTYPE_USER2KERNEL(X) (X)
-# define NETTYPE_KERNEL2USER(X) (X)
-#endif
-
-#define CDLIM_USER2KERNEL(X) ((X)==VC_CDLIM_UNSET ? CDLIM_UNSET : \
- (X)==VC_CDLIM_INFINITY ? CDLIM_INFINITY : \
- (X)==VC_CDLIM_KEEP ? CDLIM_KEEP : \
- (X))
-
- /// the __typeof__ thing is a hack to deal with the kernel interface
- /// using an unsigned long long value for a uint32_t type
-#define CDLIM_KERNEL2USER(X) ((X)==(__typeof__(X))CDLIM_UNSET ? VC_CDLIM_UNSET : \
- (X)==(__typeof__(X))CDLIM_INFINITY ? VC_CDLIM_INFINITY : \
- (X)==(__typeof__(X))CDLIM_KEEP ? VC_CDLIM_KEEP : \
- (X))
-
-
-#define ENSC_STRUCT_IDX(STRUCT,ATTR) \
- ((char*)(&(STRUCT).ATTR) - (char*)(&(STRUCT)))
-#define ENSC_SAME_STRUCT_IDX(LHS,RHS,ATTR) \
- (ENSC_STRUCT_IDX(LHS,ATTR) == ENSC_STRUCT_IDX(RHS,ATTR))
-#define ENSC_SAME_STRUCT_ITEM(LHS,RHS,ATTR) \
- (ENSC_SAME_STRUCT_IDX(LHS,RHS,ATTR) && \
- sizeof((LHS).ATTR)==sizeof((RHS).ATTR) && \
- sizeof(LHS)==sizeof(RHS))
-
-#define EXT2_IOC_GETCONTEXT _IOR('x', 1, long)
-#define EXT2_IOC_SETCONTEXT _IOW('x', 2, long)
-
-#ifndef HAVE_VSERVER
-#ifdef ENSC_SYSCALL_TRADITIONAL
-inline static UNUSED ALWAYSINLINE
-int vserver(uint32_t cmd, uint32_t id, void *data)
-{
-#if defined __dietlibc__
- extern long int syscall (long int __sysno, ...);
-#endif
-
- return syscall(__NR_vserver, cmd, id, data);
-}
-#else
-inline static UNUSED ALWAYSINLINE
-_syscall3(int, vserver,
- uint32_t, cmd, uint32_t, id, void *, data)
-#endif
-#endif
-
-#endif // H_VSERVER_SYSCALL_INTERNAL_H
+++ /dev/null
-/* $Id$
-
-* 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; either version 2, or (at your option)
-* any later version.
-*
-* 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.
-*/
-
-/** \file vserver.h
- * \brief The public interface of the the libvserver library.
- */
-
-#ifndef H_VSERVER_SYSCALL_H
-#define H_VSERVER_SYSCALL_H
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <sys/types.h>
-
-#ifndef IS_DOXYGEN
-#if defined(__GNUC__)
-# define VC_ATTR_UNUSED __attribute__((__unused__))
-# define VC_ATTR_NORETURN __attribute__((__noreturn__))
-# define VC_ATTR_CONST __attribute__((__const__))
-# define VC_ATTR_DEPRECATED __attribute__((__deprecated__))
-# if __GNUC__*0x10000 + __GNUC_MINOR__*0x100 + __GNUC_PATCHLEVEL__ >= 0x30300
-# define VC_ATTR_NONNULL(ARGS) __attribute__((__nonnull__ ARGS))
-# define VC_ATTR_ALWAYSINLINE __attribute__((__always_inline__))
-# else
-# define VC_ATTR_NONNULL(ARGS)
-# define VC_ATTR_ALWAYSINLINE
-# endif
-# if __GNUC__*0x10000 + __GNUC_MINOR__*0x100 + __GNUC_PATCHLEVEL__ >= 0x30303
-# define VC_ATTR_PURE __attribute__((__pure__))
-# else
-# define VC_ATTR_PURE
-# endif
-#else
-# define VC_ATTR_NONNULL(ARGS)
-# define VC_ATTR_UNUSED
-# define VC_ATTR_NORETURN
-# define VC_ATTR_ALWAYSINLINE
-# define VC_ATTR_DEPRECATED
-# define VC_ATTR_PURE
-# define VC_ATTR_CONST
-#endif
-#endif // IS_DOXYGEN
-
-/** the value which is returned in error-case (no ctx found) */
-#define VC_NOCTX ((xid_t)(-1))
-#define VC_NOXID ((xid_t)(-1))
-/** the value which means a random (the next free) ctx */
-#define VC_DYNAMIC_XID ((xid_t)(-1))
-/** the value which means the current ctx */
-#define VC_SAMECTX ((xid_t)(-2))
-
-#define VC_NONID ((nid_t)(-1))
-#define VC_DYNAMIC_NID ((nid_t)(-1))
-
-#define VC_LIM_INFINITY (~0ULL)
-#define VC_LIM_KEEP (~1ULL)
-
-#define VC_CDLIM_UNSET (0U)
-#define VC_CDLIM_INFINITY (~0U)
-#define VC_CDLIM_KEEP (~1U)
-
-#ifndef S_CTX_INFO_LOCK
-# define S_CTX_INFO_LOCK 1
-#endif
-
-#ifndef S_CTX_INFO_SCHED
-# define S_CTX_INFO_SCHED 2
-#endif
-
-#ifndef S_CTX_INFO_NPROC
-# define S_CTX_INFO_NPROC 4
-#endif
-
-#ifndef S_CTX_INFO_PRIVATE
-# define S_CTX_INFO_PRIVATE 8
-#endif
-
-#ifndef S_CTX_INFO_INIT
-# define S_CTX_INFO_INIT 16
-#endif
-
-#ifndef S_CTX_INFO_HIDEINFO
-# define S_CTX_INFO_HIDEINFO 32
-#endif
-
-#ifndef S_CTX_INFO_ULIMIT
-# define S_CTX_INFO_ULIMIT 64
-#endif
-
-#ifndef S_CTX_INFO_NAMESPACE
-# define S_CTX_INFO_NAMESPACE 128
-#endif
-
-#define VC_CAP_CHOWN 0
-#define VC_CAP_DAC_OVERRIDE 1
-#define VC_CAP_DAC_READ_SEARCH 2
-#define VC_CAP_FOWNER 3
-#define VC_CAP_FSETID 4
-#define VC_CAP_KILL 5
-#define VC_CAP_SETGID 6
-#define VC_CAP_SETUID 7
-#define VC_CAP_SETPCAP 8
-#define VC_CAP_LINUX_IMMUTABLE 9
-#define VC_CAP_NET_BIND_SERVICE 10
-#define VC_CAP_NET_BROADCAST 11
-#define VC_CAP_NET_ADMIN 12
-#define VC_CAP_NET_RAW 13
-#define VC_CAP_IPC_LOCK 14
-#define VC_CAP_IPC_OWNER 15
-#define VC_CAP_SYS_MODULE 16
-#define VC_CAP_SYS_RAWIO 17
-#define VC_CAP_SYS_CHROOT 18
-#define VC_CAP_SYS_PTRACE 19
-#define VC_CAP_SYS_PACCT 20
-#define VC_CAP_SYS_ADMIN 21
-#define VC_CAP_SYS_BOOT 22
-#define VC_CAP_SYS_NICE 23
-#define VC_CAP_SYS_RESOURCE 24
-#define VC_CAP_SYS_TIME 25
-#define VC_CAP_SYS_TTY_CONFIG 26
-#define VC_CAP_MKNOD 27
-#define VC_CAP_LEASE 28
-#define VC_CAP_QUOTACTL 29
-
-#define VC_IMMUTABLE_FILE_FL 0x0000010lu
-#define VC_IMMUTABLE_LINK_FL 0x0008000lu
-#define VC_IMMUTABLE_ALL (VC_IMMUTABLE_LINK_FL|VC_IMMUTABLE_FILE_FL)
-
-#define VC_IATTR_XID 0x01000000u
-
-#define VC_IATTR_ADMIN 0x00000001u
-#define VC_IATTR_WATCH 0x00000002u
-#define VC_IATTR_HIDE 0x00000004u
-#define VC_IATTR_FLAGS 0x00000007u
-
-#define VC_IATTR_BARRIER 0x00010000u
-#define VC_IATTR_IUNLINK 0x00020000u
-#define VC_IATTR_IMMUTABLE 0x00040000u
-
-
-// the flags
-#define VC_VXF_INFO_LOCK 0x00000001ull
-#define VC_VXF_INFO_NPROC 0x00000004ull
-#define VC_VXF_INFO_PRIVATE 0x00000008ull
-#define VC_VXF_INFO_INIT 0x00000010ull
-
-#define VC_VXF_INFO_HIDEINFO 0x00000020ull
-#define VC_VXF_INFO_ULIMIT 0x00000040ull
-#define VC_VXF_INFO_NAMESPACE 0x00000080ull
-
-#define VC_VXF_SCHED_HARD 0x00000100ull
-#define VC_VXF_SCHED_PRIO 0x00000200ull
-#define VC_VXF_SCHED_PAUSE 0x00000400ull
-
-#define VC_VXF_VIRT_MEM 0x00010000ull
-#define VC_VXF_VIRT_UPTIME 0x00020000ull
-#define VC_VXF_VIRT_CPU 0x00040000ull
-#define VC_VXF_VIRT_LOAD 0x00080000ull
-
-#define VC_VXF_HIDE_MOUNT 0x01000000ull
-#define VC_VXF_HIDE_NETIF 0x02000000ull
-
-#define VC_VXF_STATE_SETUP (1ULL<<32)
-#define VC_VXF_STATE_INIT (1ULL<<33)
-
-#define VC_VXF_FORK_RSS (1ULL<<48)
-#define VC_VXF_PROLIFIC (1ULL<<49)
-
-#define VC_VXF_IGNEG_NICE (1ULL<<52)
-
-
-// the ccapabilities
-#define VC_VXC_SET_UTSNAME 0x00000001ull
-#define VC_VXC_SET_RLIMIT 0x00000002ull
-
-#define VC_VXC_RAW_ICMP 0x00000100ull
-
-#define VC_VXC_SECURE_MOUNT 0x00010000ull
-#define VC_VXC_SECURE_REMOUNT 0x00020000ull
-
-
-#define VC_VXSM_FILL_RATE 0x0001
-#define VC_VXSM_INTERVAL 0x0002
-#define VC_VXSM_TOKENS 0x0010
-#define VC_VXSM_TOKENS_MIN 0x0020
-#define VC_VXSM_TOKENS_MAX 0x0040
-#define VC_VXSM_PRIO_BIAS 0x0100
-
-
-
-/** \defgroup syscalls Syscall wrappers
- * Functions which are calling the vserver syscall directly. */
-
-/** \defgroup helper Helper functions
- * Functions which are doing general helper tasks like parameter parsing. */
-
-/** \typedef an_unsigned_integer_type xid_t
- * The identifier of a context. */
-
-#ifdef IS_DOXYGEN
-typedef an_unsigned_integer_type xid_t;
-typedef an_unsigned_integer_type nid_t;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- struct vc_ip_mask_pair {
- uint32_t ip;
- uint32_t mask;
- };
-
- /** \brief The generic vserver syscall
- * \ingroup syscalls
- *
- * This function executes the generic vserver syscall. It uses the
- * correct syscallnumber (which may differ between the different
- * architectures).
- *
- * \param cmd the command to be executed
- * \param xid the xid on which the cmd shall be applied
- * \param data additional arguments; depends on \c cmd
- * \returns depends on \c cmd; usually, -1 stands for an error
- */
- int vc_syscall(uint32_t cmd, xid_t xid, void *data);
-
- /** \brief Returns the version of the current kernel API.
- * \ingroup syscalls
- * \returns The versionnumber of the kernel API
- */
- int vc_get_version();
-
- /** \brief Moves current process into a context
- * \ingroup syscalls
- *
- * Puts current process into context \a ctx, removes the capabilities
- * given in \a remove_cap and sets \a flags.
- *
- * \param ctx The new context; special values for are
- * - VC_SAMECTX which means the current context (just for changing caps and flags)
- * - VC_DYNAMIC_XID which means the next free context; this value can be used by
- * ordinary users also
- * \param remove_cap The linux capabilities which will be \b removed.
- * \param flags Special flags which will be set.
- *
- * \returns The new context-id, or VC_NOCTX on errors; \c errno
- * will be set appropriately
- *
- * See http://vserver.13thfloor.at/Stuff/Logic.txt for details */
- xid_t vc_new_s_context(xid_t ctx, unsigned int remove_cap, unsigned int flags);
-
- /** \brief Sets the ipv4root information.
- * \ingroup syscalls
- * \pre \a nb < NB_IPV4ROOT && \a ips != 0 */
- int vc_set_ipv4root(uint32_t bcast, size_t nb,
- struct vc_ip_mask_pair const *ips) VC_ATTR_NONNULL((3));
-
- /** \brief Returns the value of NB_IPV4ROOT.
- * \ingroup helper
- *
- * This function returns the value of NB_IPV4ROOT which was used when the
- * library was built, but \b not the value which is used by the currently
- * running kernel. */
- size_t vc_get_nb_ipv4root() VC_ATTR_CONST VC_ATTR_PURE;
-
- /** \brief Creates a context without starting it.
- * \ingroup syscalls
- *
- * This functions initializes a new context. When already in a freshly
- * created context, this old context will be discarded.
- *
- * \param xid The new context; special values are:
- * - VC_DYNAMIC_XID which means to create a dynamic context
- *
- * \returns the xid of the created context, or VC_NOCTX on errors. \c errno
- * will be set appropriately. */
- xid_t vc_ctx_create(xid_t xid);
-
- /** \brief Moves the current process into the specified context.
- * \ingroup syscalls
- *
- * \param xid The new context
- * \returns 0 on success, -1 on errors */
- int vc_ctx_migrate(xid_t xid);
-
- /* rlimit related functions */
-
- /** \brief The type which is used for a single limit value.
- *
- * Special values are
- * - VC_LIM_INFINITY ... which is the infinite value
- * - VC_LIM_KEEP ... which is used to mark values which shall not be
- * modified by the vc_set_rlimit() operation.
- *
- * Else, the interpretation of the value depends on the corresponding
- * resource; it might be bytes, pages, seconds or litres of beer. */
- typedef uint_least64_t vc_limit_t;
-
- /** \brief The limits of a resources.
- *
- * This is a triple consisting of a minimum, soft and hardlimit. */
- struct vc_rlimit {
- vc_limit_t min; ///< the guaranted minimum of a resources
- vc_limit_t soft; ///< the softlimit of a resource
- vc_limit_t hard; ///< the absolute hardlimit of a resource
- };
-
- /** \brief Masks describing the supported limits. */
- struct vc_rlimit_mask {
- uint_least32_t min; ///< masks the resources supporting a minimum limit
- uint_least32_t soft; ///< masks the resources supporting a soft limit
- uint_least32_t hard; ///< masks the resources supporting a hard limit
- };
-
- /** \brief Returns the limits of \a resource.
- * \ingroup syscalls
- *
- * \param xid The id of the context
- * \param resource The resource which will be queried
- * \param lim The result which will be filled with the limits
- *
- * \returns 0 on success, and -1 on errors. */
- int vc_get_rlimit(xid_t xid, int resource,
- struct vc_rlimit /*@out@*/ *lim) VC_ATTR_NONNULL((3));
- /** \brief Sets the limits of \a resource.
- * \ingroup syscalls
- *
- * \param xid The id of the context
- * \param resource The resource which will be queried
- * \param lim The new limits
- *
- * \returns 0 on success, and -1 on errors. */
- int vc_set_rlimit(xid_t xid, int resource,
- struct vc_rlimit const /*@in@*/ *lim) VC_ATTR_NONNULL((3));
- int vc_get_rlimit_mask(xid_t xid,
- struct vc_rlimit_mask *lim) VC_ATTR_NONNULL((2));
- /** \brief Parses a string describing a limit
- * \ingroup helper
- *
- * This function parses \a str and interprets special words like \p "inf"
- * or suffixes. Valid suffixes are
- * - \p k ... 1000
- * - \p m ... 1000000
- * - \p K ... 1024
- * - \p M ... 1048576
- *
- * \param str The string which shall be parsed
- * \param res Will be filled with the interpreted value; in errorcase,
- * this value is undefined.
- *
- * \returns \a true, iff the string \a str could be parsed. \a res will
- * be filled with the interpreted value in this case.
- *
- * \pre \a str!=0 && \a res!=0
- */
- bool vc_parseLimit(char const /*@in@*/ *str, vc_limit_t /*@out@*/ *res) VC_ATTR_NONNULL((1,2));
-
-
- /** \brief Sends a signal to a context/pid
- * \ingroup syscalls
- *
- * Special values for \a pid are:
- * - -1 which means every process in ctx except the init-process
- * - 0 which means every process in ctx inclusive the init-process */
- int vc_ctx_kill(xid_t ctx, pid_t pid, int sig);
-
-
- struct vc_nx_info {
- nid_t nid;
- };
-
- nid_t vc_get_task_nid(pid_t pid);
- int vc_get_nx_info(nid_t nid, struct vc_nx_info *) VC_ATTR_NONNULL((2));
-
- typedef enum { vcNET_IPV4, vcNET_IPV6, vcNET_IPV4R, vcNET_IPV6R } vc_net_nx_type;
-
- struct vc_net_nx {
- vc_net_nx_type type;
- size_t count;
- uint32_t ip;
- uint32_t mask;
- };
-
- nid_t vc_net_create(nid_t nid);
- int vc_net_migrate(nid_t nid);
-
- int vc_net_add(nid_t nid, struct vc_net_nx const *info);
- int vc_net_remove(nid_t nid, struct vc_net_nx const *info);
-
- struct vc_net_flags {
- uint_least64_t flagword;
- uint_least64_t mask;
- };
-
- int vc_get_nflags(nid_t, struct vc_net_flags *);
- int vc_set_nflags(nid_t, struct vc_net_flags const *);
-
-
- struct vc_net_caps {
- uint_least64_t ncaps;
- uint_least64_t cmask;
- };
-
- int vc_get_ncaps(nid_t, struct vc_net_caps *);
- int vc_set_ncaps(nid_t, struct vc_net_caps const *);
-
-
-
-
- int vc_set_iattr(char const *filename, xid_t xid,
- uint_least32_t flags, uint_least32_t mask) VC_ATTR_NONNULL((1));
-
- /** \brief Returns information about attributes and assigned context of a file.
- * \ingroup syscalls
- *
- * This function returns the VC_IATTR_XXX flags and about the assigned
- * context of a file. To request an information, the appropriate bit in
- * \c mask must be set and the corresponding parameter (\a xid or \a
- * flags) must not be NULL.
- *
- * E.g. to receive the assigned context, the \c VC_IATTR_XID bit must be
- * set in \a mask, and \a xid must point to valid memory.
- *
- * Possible flags are \c VC_IATTR_ADMIN, \c VC_IATTR_WATCH , \c VC_IATTR_HIDE,
- * \c VC_IATTR_BARRIER, \c VC_IATTR_IUNLINK and \c VC_IATTR_IMMUTABLE.
- *
- * \param filename The name of the file whose attributes shall be determined.
-
- * \param xid When non-zero and the VC_IATTR_XID bit is set in \a mask,
- * the assigned context of \a filename will be stored there.
- * \param flags When non-zero, a bitmask of current attributes will be
- * stored there. These attributes must be requested explicitly
- * by setting the appropriate bit in \a mask
- * \param mask Points to a bitmask which tells which attributes shall be
- * determined. On return, it will masquerade the attributes
- * which were determined.
- *
- * \pre mask!=0 && !((*mask&VC_IATTR_XID) && xid==0) && !((*mask&~VC_IATTR_XID) && flags==0) */
- int vc_get_iattr(char const *filename, xid_t * /*@null@*/ xid,
- uint_least32_t * /*@null@*/ flags,
- uint_least32_t * /*@null@*/ mask) VC_ATTR_NONNULL((1));
-
- struct vc_vx_info {
- xid_t xid;
- pid_t initpid;
- };
-
- /** \brief Returns the context of the given process.
- * \ingroup syscalls
- *
- * \param pid the process-id whose xid shall be determined;
- * pid==0 means the current process.
- * \returns the xid of process \c pid or -1 on errors
- */
- xid_t vc_get_task_xid(pid_t pid);
- int vc_get_vx_info(xid_t xid, struct vc_vx_info *info) VC_ATTR_NONNULL((2));
-
-
- typedef enum { vcVHI_CONTEXT, vcVHI_SYSNAME, vcVHI_NODENAME,
- vcVHI_RELEASE, vcVHI_VERSION, vcVHI_MACHINE,
- vcVHI_DOMAINNAME } vc_uts_type;
-
- int vc_set_vhi_name(xid_t xid, vc_uts_type type,
- char const *val, size_t len) VC_ATTR_NONNULL((3));
- int vc_get_vhi_name(xid_t xid, vc_uts_type type,
- char *val, size_t len) VC_ATTR_NONNULL((3));
-
- /** Returns true iff \a xid is a dynamic xid */
- bool vc_is_dynamic_xid(xid_t xid);
-
- int vc_enter_namespace(xid_t xid);
- int vc_set_namespace();
- int vc_cleanup_namespace();
-
-
- /** \brief Flags of process-contexts
- */
- struct vc_ctx_flags {
- /** \brief Mask of set context flags */
- uint_least64_t flagword;
- /** \brief Mask of set and unset context flags when used by set
- * operations, or modifiable flags when used by get
- * operations */
- uint_least64_t mask;
- };
-
- /** \brief Capabilities of process-contexts */
- struct vc_ctx_caps {
- /** \brief Mask of set common system capabilities */
- uint_least64_t bcaps;
- /** \brief Mask of set and unset common system capabilities when used by
- * set operations, or the modifiable capabilities when used by
- * get operations */
- uint_least64_t bmask;
- /** \brief Mask of set process context capabilities */
- uint_least64_t ccaps;
- /** \brief Mask of set and unset process context capabilities when used
- * by set operations, or the modifiable capabilities when used
- * by get operations */
- uint_least64_t cmask;
- };
-
- /** \brief Information about parsing errors
- * \ingroup helper
- */
- struct vc_err_listparser {
- char const *ptr; ///< Pointer to the first character of an erroneous string
- size_t len; ///< Length of the erroneous string
- };
-
- int vc_get_cflags(xid_t xid, struct vc_ctx_flags *) VC_ATTR_NONNULL((2));
- int vc_set_cflags(xid_t xid, struct vc_ctx_flags const *) VC_ATTR_NONNULL((2));
-
- int vc_get_ccaps(xid_t xid, struct vc_ctx_caps *);
- int vc_set_ccaps(xid_t xid, struct vc_ctx_caps const *);
-
- /** \brief Converts a single string into bcapability
- * \ingroup helper
- *
- * \param str The string to be parsed;
- * both "CAP_xxx" and "xxx" will be accepted
- * \param len The length of the string, or \c 0 for automatic detection
- *
- * \returns 0 on error; a bitmask on success
- * \pre \a str != 0
- */
- uint_least64_t vc_text2bcap(char const *str, size_t len);
-
- /** \brief Converts the lowest bit of a bcapability or the entire value
- * (when possible) to a textual representation
- * \ingroup helper
- *
- * \param val The string to be converted; on success, the detected bit(s)
- * will be unset, in errorcase only the lowest set bit
- *
- * \returns A textual representation of \a val resp. of its lowest set bit;
- * or \c NULL in errorcase.
- * \pre \a val!=0
- * \post \a *val<sub>old</sub> \c != 0 \c <-->
- * \a *val<sub>old</sub> > \a *val<sub>new</sub>
- * \post \a *val<sub>old</sub> \c == 0 \c ---> \a result == 0
- */
- char const * vc_lobcap2text(uint_least64_t *val) VC_ATTR_NONNULL((1));
-
- /** \brief Converts a string into a bcapability-bitmask
- * \ingroup helper
- *
- * Syntax of \a str: \verbinclude list2xxx.syntax
- *
- * When the \c `~' prefix is used, the bits will be unset and a `~' after
- * another `~' will cancel both ones. The \c `^' prefix specifies a
- * bitnumber instead of a bitmask.
- *
- * "literal name" is everything which will be accepted by the
- * vc_text2bcap() function. The special values for \c NAME will be
- * recognized case insensitively
- *
- * \param str The string to be parsed
- * \param len The length of the string, or \c 0 for automatic detection
- * \param err Pointer to a structure for error-information, or \c NULL.
- * \param cap Pointer to a vc_ctx_caps structure holding the results;
- * only the \a bcaps and \a bmask fields will be changed and
- * already set values will not be honored. When an error
- * occured, \a cap will have the value of all processed valid
- * \c BCAP parts.
- *
- * \returns 0 on success, -1 on error. In error case, \a err will hold
- * position and length of the first not understood BCAP part
- * \pre \a str != 0 && \a cap != 0;
- * \a cap->bcaps and \a cap->bmask must be initialized
- */
- int vc_list2bcap(char const *str, size_t len,
- struct vc_err_listparser *err,
- struct vc_ctx_caps *cap) VC_ATTR_NONNULL((1,4));
-
- uint_least64_t vc_text2ccap(char const *, size_t len);
- char const * vc_loccap2text(uint_least64_t *);
- int vc_list2ccap(char const *, size_t len,
- struct vc_err_listparser *err,
- struct vc_ctx_caps *);
-
- int vc_list2cflag(char const *, size_t len,
- struct vc_err_listparser *err,
- struct vc_ctx_flags *flags);
- uint_least64_t vc_text2cflag(char const *, size_t len);
- char const * vc_locflag2text(uint_least64_t *);
-
- uint_least32_t vc_list2cflag_compat(char const *, size_t len,
- struct vc_err_listparser *err);
- uint_least32_t vc_text2cflag_compat(char const *, size_t len);
- char const * vc_hicflag2text_compat(uint_least32_t);
-
- int vc_text2cap(char const *);
- char const * vc_cap2text(unsigned int);
-
-
- int vc_list2nflag(char const *, size_t len,
- struct vc_err_listparser *err,
- struct vc_net_flags *flags);
- uint_least64_t vc_text2nflag(char const *, size_t len);
- char const * vc_lonflag2text(uint_least64_t *);
-
- uint_least64_t vc_text2ncap(char const *, size_t len);
- char const * vc_loncap2text(uint_least64_t *);
- int vc_list2ncap(char const *, size_t len,
- struct vc_err_listparser *err,
- struct vc_net_caps *);
-
- uint_least64_t vc_get_insecurebcaps() VC_ATTR_CONST;
- inline static uint_least64_t vc_get_insecureccaps() {
- return ~(VC_VXC_SET_UTSNAME|VC_VXC_RAW_ICMP);
- }
-
- inline static int vc_setfilecontext(char const *filename, xid_t xid) {
- return vc_set_iattr(filename, xid, 0, VC_IATTR_XID);
- }
-
- /** \brief Returns the context of \c filename
- * \ingroup syscalls
- *
- * This function calls vc_get_iattr() with appropriate arguments to
- * determine the context of \c filename. In error-case or when no context
- * is assigned, \c VC_NOCTX will be returned. To differ between both cases,
- * \c errno must be examined.
- *
- * \b WARNING: this function can modify \c errno although no error happened.
- *
- * \param filename The file to check
- * \returns The assigned context, or VC_NOCTX when an error occured or no
- * such assignment exists. \c errno will be 0 in the latter case */
- xid_t vc_getfilecontext(char const *filename) VC_ATTR_NONNULL((1));
-
-
- struct vc_set_sched {
- uint_least32_t set_mask;
- int_least32_t fill_rate;
- int_least32_t interval;
- int_least32_t tokens;
- int_least32_t tokens_min;
- int_least32_t tokens_max;
- int_least32_t priority_bias;
- };
-
- int vc_set_sched(xid_t xid, struct vc_set_sched const *);
-
-
- struct vc_ctx_dlimit {
- uint_least32_t space_used;
- uint_least32_t space_total;
- uint_least32_t inodes_used;
- uint_least32_t inodes_total;
- uint_least32_t reserved;
- };
-
-
- /** Add a disk limit to a file system. */
- int vc_add_dlimit(char const *filename, xid_t xid,
- uint_least32_t flags) VC_ATTR_NONNULL((1));
- /** Remove a disk limit from a file system. */
- int vc_rem_dlimit(char const *filename, xid_t xid,
- uint_least32_t flags) VC_ATTR_NONNULL((1));
-
- /** Set a disk limit. */
- int vc_set_dlimit(char const *filename, xid_t xid,
- uint_least32_t flags,
- struct vc_ctx_dlimit const *limits) VC_ATTR_NONNULL((1,4));
- /** Get a disk limit. */
- int vc_get_dlimit(char const *filename, xid_t xid,
- uint_least32_t flags,
- struct vc_ctx_dlimit *limits) VC_ATTR_NONNULL((1));
-
-
- typedef enum { vcFEATURE_VKILL, vcFEATURE_IATTR, vcFEATURE_RLIMIT,
- vcFEATURE_COMPAT, vcFEATURE_MIGRATE, vcFEATURE_NAMESPACE,
- vcFEATURE_SCHED, vcFEATURE_VINFO, vcFEATURE_VHI,
- vcFEATURE_VSHELPER0, vcFEATURE_VSHELPER }
- vcFeatureSet;
-
- bool vc_isSupported(vcFeatureSet) VC_ATTR_CONST;
- bool vc_isSupportedString(char const *);
-
-
- typedef enum { vcTYPE_INVALID, vcTYPE_MAIN, vcTYPE_WATCH,
- vcTYPE_STATIC, vcTYPE_DYNAMIC }
- vcXidType;
-
- vcXidType vc_getXIDType(xid_t xid) VC_ATTR_CONST;
-
- /* The management part */
-
-#define VC_LIMIT_VSERVER_NAME_LEN 1024
-
- typedef enum { vcCFG_NONE, vcCFG_AUTO,
- vcCFG_LEGACY,
- vcCFG_RECENT_SHORT,
- vcCFG_RECENT_FULL } vcCfgStyle;
-
-
- /** Maps an xid given at '--xid' options to an xid_t */
- xid_t vc_xidopt2xid(char const *, bool honor_static, char const **err_info);
-
- vcCfgStyle vc_getVserverCfgStyle(char const *id);
-
- /** Resolves the name of the vserver. The result will be allocated and must
- be freed by the caller. */
- char * vc_getVserverName(char const *id, vcCfgStyle style);
-
- /** Returns the path of the vserver configuration directory. When the given
- * vserver does not exist, or when it does not have such a directory, NULL
- * will be returned. Else, the result will be allocated and must be freed
- * by the caller. */
- char * vc_getVserverCfgDir(char const *id, vcCfgStyle style);
-
- /** Returns the path of the configuration directory for the given
- * application. The result will be allocated and must be freed by the
- * caller. */
- char * vc_getVserverAppDir(char const *id, vcCfgStyle style, char const *app);
-
- /** Returns the path to the vserver root-directory. The result will be
- * allocated and must be freed by the caller. */
- char * vc_getVserverVdir(char const *id, vcCfgStyle style, bool physical);
-
- /** Returns the ctx of the given vserver. When vserver is not running and
- * 'honor_static' is false, VC_NOCTX will be returned. Else, when
- * 'honor_static' is true and a static assignment exists, those value will
- * be returned. Else, the result will be VC_NOCTX.
- *
- * When 'is_running' is not null, the status of the vserver will be
- * assigned to this variable. */
- xid_t vc_getVserverCtx(char const *id, vcCfgStyle style,
- bool honor_static, bool /*@null@*/ *is_running);
-
- /** Resolves the cfg-path of the vserver owning the given ctx. 'revdir' will
- be used as the directory holding the mapping-links; when NULL, the
- default value will be assumed. The result will be allocated and must be
- freed by the caller. */
- char * vc_getVserverByCtx(xid_t ctx, /*@null@*/vcCfgStyle *style,
- /*@null@*/char const *revdir);
-
-#define vcSKEL_INTERFACES 1u
-#define vcSKEL_PKGMGMT 2u
-#define vcSKEL_FILESYSTEM 4u
-
- /** Create a basic configuration skeleton for a vserver plus toplevel
- * directories for pkgmanagemt and filesystem (when requested). */
- int vc_createSkeleton(char const *id, vcCfgStyle style, int flags);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#undef VC_ATTR_PURE
-#undef VC_ATTR_ALWAYSINLINE
-#undef VC_ATTR_NORETURN
-#undef VC_ATTR_UNUSED
-#undef VC_ATTR_NONNULL
-
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include <string.h>
-#include <stdlib.h>
-
-static xid_t
-getVserverXid(char const *id, bool honor_static, char const **err)
-{
- *err = "vc_getVserverCtx";
- return vc_getVserverCtx(id, vcCFG_AUTO, honor_static, 0);
-}
-
-xid_t
-vc_xidopt2xid(char const *str, bool honor_static, char const **err_info)
-{
- char const * err;
- xid_t res = VC_NOCTX;
-
- err = "vc_get_task_xid()";
- if (strcmp(str,"self")==0) res = vc_get_task_xid(0);
- else if (str[0]==':') res = getVserverXid(str+1, honor_static, &err);
- else {
- char * endptr;
- xid_t xid = strtol(str, &endptr, 10);
-
- if (endptr!=str && (*endptr=='\0' || *endptr=='\n'))
- res = xid;
- else
- res = getVserverXid(str, honor_static, &err);
- }
-
- if (res==VC_NOCTX && err_info) *err_info = err;
-
- return res;
-}
+++ /dev/null
-.deps
-.dirstamp
+++ /dev/null
-## $Id$ -*- makefile -*-
-
-## Copyright (C) 2003,2004 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; either version 2, or (at your option)
-## any later version.
-##
-## 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.
-##
-
-
-LIBINTERNAL_GLIBC = lib_internal/libinternal-glibc.a
-noinst_LIBRARIES += $(LIBINTERNAL_GLIBC)
-
-if USE_DIETLIBC
-LIBINTERNAL_DIET = lib_internal/libinternal-diet.a
-LIBINTERNAL = $(LIBINTERNAL_DIET)
-noinst_LIBRARIES += $(LIBINTERNAL_DIET)
-else
-LIBINTERNAL_DIET = lib-dietlibc-not-enabled-error.a
-LIBINTERNAL = $(LIBINTERNAL_GLIBC)
-endif
-
-
-command_SRCS = lib_internal/command-appendparameter.c \
- lib_internal/command-setparams.c \
- lib_internal/command-exec.c\
- lib_internal/command-free.c \
- lib_internal/command-init.c \
- lib_internal/command-reset.c \
- lib_internal/command-wait.c \
- lib_internal/command.h
-
-if ENSC_HAVE_C99_COMPILER
-filecfg_SRCS = lib_internal/filecfg.h \
- lib_internal/filecfg-iteratemultiline.c \
- lib_internal/filecfg-readentryflag.c \
- lib_internal/filecfg-readentrystr.c \
- lib_internal/matchlist-initbyvserver.c \
- lib_internal/matchvserverinfo-init.c \
- lib_internal/unify-copy.c
-endif
-
-noinst_HEADERS += \
- lib_internal/coreassert.h \
- lib_internal/errinfo.h \
- lib_internal/jail.h \
- lib_internal/matchlist.h \
- lib_internal/pathinfo.h \
- lib_internal/string.h \
- lib_internal/sys_clone.h \
- lib_internal/unify.h \
- lib_internal/util.h \
- lib_internal/util-cast.h \
- lib_internal/util-commonstrings.h \
- lib_internal/util-debug.h \
- lib_internal/util-declarecmd.h \
- lib_internal/util-dimof.h \
- lib_internal/util-dotfile.h \
- lib_internal/util-exitlikeprocess.h \
- lib_internal/util-io.h \
- lib_internal/util-lockfile.h \
- lib_internal/util-mem.h \
- lib_internal/util-perror.h \
- lib_internal/util-safechdir.h \
- lib_internal/util-unixsock.h \
- lib_internal/string.hc
-
-lib_internal_libinternal_common_SRCS = \
- lib_internal/errinfo-writeerrno.c \
- lib_internal/jailintotempdir.c \
- lib_internal/matchlist-appendfiles.c \
- lib_internal/matchlist-compare.c \
- lib_internal/matchlist-destroy.c \
- lib_internal/matchlist-init.c \
- lib_internal/matchlist-initmanually.c \
- lib_internal/matchlist-initrefserverlist.c \
- lib_internal/matchlist-printid.c \
- lib_internal/matchvserverinfo-free.c \
- lib_internal/pathinfo-append.c \
- lib_internal/pathinfo-test.c \
- lib_internal/switchtowatchxid.c \
- lib_internal/unify-deunify.c \
- lib_internal/unify-settime.c \
- lib_internal/unify-unify.c \
- lib_internal/unify-isiunlinkable.c \
- lib_internal/util-canonify.c \
- lib_internal/util-exitlikeprocess.c \
- lib_internal/util-lockfile.c \
- lib_internal/util-safechdir.c \
- $(command_SRCS) \
- $(filecfg_SRCS)
-
-lib_internal_libinternal_diet_a_SOURCES = \
- $(lib_internal_libinternal_common_SRCS)
-
-lib_internal_libinternal_glibc_a_SOURCES = \
- $(lib_internal_libinternal_common_SRCS)
-
-lib_internal_libinternal_diet_a_CPPFLAGS = $(AM_CPPFLAGS) $(LIB_DEBUG_CPPFLAGS)
-lib_internal_libinternal_glibc_a_CPPFLAGS = $(AM_CPPFLAGS) $(LIB_DEBUG_CPPFLAGS)
-
-DIETPROGS += lib_internal/libinternal-diet.a
-
-CLEANFILES += lib_internal/libinternal-diet.a \
- lib_internal/libinternal-glibc.a
-
-include $(top_srcdir)/lib_internal/testsuite/Makefile-files
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "command.h"
-#include "util.h"
-
-void
-Command_appendParameter(struct Command *cmd, char const *param)
-{
- switch (cmd->params_style_) {
- case parNONE :
- Vector_init(&cmd->params.v, 10);
- cmd->params_style_ = parVEC;
- /*@fallthrough@*/
- case parVEC : {
- char const **p = Vector_pushback(&cmd->params.v);
- *p = param;
- break;
- }
-
- default :
- WRITE_MSG(2, "internal error: conflicting functions Command_appendParameter() and Command_setParams() used together; aborting...\n");
- abort();
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "command.h"
-#include "util.h"
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <assert.h>
-
-static inline bool
-initPipes(int p[2])
-{
- return (pipe(p)!=-1 &&
- fcntl(p[1], F_SETFD, FD_CLOEXEC)!=-1);
-}
-
-bool
-Command_exec(struct Command *cmd, bool do_fork)
-{
- int p[2];
-
- if (cmd->params_style_==parVEC)
- Vector_zeroEnd(&cmd->params.v);
-
- if (!do_fork)
- cmd->pid = 0;
- else if (!initPipes(p) ||
- (cmd->pid = fork())==-1) {
- cmd->err = errno;
- return false;
- }
-
- if (cmd->pid==0) {
- char const ** argv = { 0 };
-
- if (do_fork) close(p[0]);
-
- switch (cmd->params_style_) {
- case parVEC : argv = cmd->params.v.data; break;
- case parDATA : argv = cmd->params.d; break;
- default : break;
- }
-
- execv(cmd->filename ? cmd->filename : argv[0],
- reinterpret_cast(char **const)(argv));
- cmd->err = errno;
- assert(cmd->err != 0);
-
- if (do_fork) {
- TEMP_FAILURE_RETRY(write(p[1], &cmd->err, sizeof(cmd->err)));
- _exit(1); // implicates 'close(p[1])'
- }
- }
- else {
- close(p[1]);
- if (read(p[0], &cmd->err, sizeof(cmd->err))==0)
- cmd->err = 0;
- else // cleanup zombies
- while (wait4(cmd->pid, 0,0,0)==-1 &&
- (errno==EINTR || errno==EAGAIN)) {};
- close(p[0]);
- }
-
- return cmd->err==0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "command.h"
-
-void
-Command_free(struct Command *cmd)
-{
- if (cmd->params_style_==parVEC)
- Vector_free(&cmd->params.v);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "command.h"
-
-void
-Command_init(struct Command *cmd)
-{
- cmd->filename = 0;
- cmd->pid = -1;
- cmd->rc = -1;
- cmd->err = 0;
- cmd->params_style_ = parNONE;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "command.h"
-
-void
-Command_reset(struct Command *cmd)
-{
- cmd->pid = -1;
- cmd->rc = -1;
- cmd->err = 0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "command.h"
-#include "util.h"
-
-void
-Command_setParams(struct Command *cmd, char const **par)
-{
- switch (cmd->params_style_) {
- case parNONE :
- cmd->params_style_ = parDATA;
- /*@fallthrough@*/
- case parDATA :
- cmd->params.d = par;
- break;
- default :
- WRITE_MSG(2, "internal error: conflicting functions Command_appendParameter() and Command_setParams() used together; aborting...\n");
- abort();
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "command.h"
-#include <errno.h>
-
-bool
-Command_wait(struct Command *cmd, bool do_block)
-{
- int rc;
-
- if (cmd->rc!=-1) return true;
-
- switch (wait4(cmd->pid, &rc, (!do_block ? WNOHANG : 0), &cmd->rusage)) {
- case 0 : break;
- case -1 : cmd->err = errno; break;
- default : cmd->rc = rc; return true;
- }
-
- return false;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_COMMAND_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_COMMAND_H
-
-#include <ensc_vector/vector.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-#include <stdbool.h>
-
-struct Command
-{
- char const * filename;
- union {
- struct Vector v;
- char const ** d;
- } params;
- pid_t pid;
- int rc;
- int err;
- struct rusage rusage;
-
- enum { parNONE, parVEC, parDATA } params_style_;
-};
-
-void Command_init(struct Command *);
-void Command_free(struct Command *);
-void Command_reset(struct Command *);
-bool Command_exec(struct Command *, bool do_fork);
-void Command_appendParameter(struct Command *, char const *);
-void Command_setParams(struct Command *, char const **);
-/**
- * \args do_hang when true, do not return before command exited, or
- * an error (e.g. signal) occured
- * \returns \c true iff command/processes exited; in this case,
- * exitcode is available in the \c rc member
- */
-bool Command_wait(struct Command *, bool do_block);
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_COMMAND_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_UTILVSERVER_LIB_INTERNAL_COREASSERT_H
-#define H_UTILVSERVER_LIB_INTERNAL_COREASSERT_H
-
-#ifndef ENSC_TESTSUITE
-# error Do not use <coreassert.h> outside of testenvironemnts!
-#endif
-
-#include "lib_internal/util-io.h"
-
-#include <assert.h>
-#include <unistd.h>
-
-#undef assert
-#define ASSERT_STRX(X) #X
-#define ASSERT_STR(X) ASSERT_STRX(X)
-#define ASSERT_WRITE(X) Vwrite(2, (X), sizeof(X)-1)
-#define assert(X) \
- (!(X)) ? \
- ASSERT_WRITE(__FILE__ ":" ASSERT_STR(__LINE__) \
- " Assertion: '" #X "' failed\n"), \
- *(char *)(0)=0 : 0
-
-
-#endif // H_UTILVSERVER_LIB_INTERNAL_COREASSERT_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "errinfo.h"
-#include "util.h"
-
-void
-ErrInfo_writeErrno(struct ErrorInformation const *info)
-{
- if (info->app) {
- WRITE_STR(2, info->app);
- WRITE_MSG(2, ": ");
- }
-
- if (info->pos) {
- WRITE_STR(2, info->pos);
- if (info->id!=0) WRITE_MSG(2, ": ");
- }
-
- if (info->id!=0) {
- WRITE_STR(2, strerror(info->id));
- }
-
- WRITE_MSG(2, "\n");
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_ERRINFO_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_ERRINFO_H
-
-struct ErrorInformation
-{
- char const * app; // the application-name
- char const * pos; // the detailed position of the error
- int id; // usually errno
-};
-
-void ErrInfo_writeErrno(struct ErrorInformation const *);
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_ERRINFO_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "filecfg.h"
-#include <string.h>
-
-bool
-FileCfg_iterateOverMultiLine(char const *str,
- FileCfg_MultiLineHandler handler,
- void *data)
-{
- char const *ptr = str;
- size_t line_nr = 1;
-
- while (*ptr!='\0') {
- while (*ptr==' ' || *ptr=='\t') ++ptr; // left-trim line
-
- char const *eol = strchr(ptr, '\n');
- if (eol==0) eol=ptr+strlen(ptr); // handle unterminated lines
-
- if (*ptr!='#') { // skip commented lines
- size_t len = eol-ptr;
- while (len>0 && (ptr[len-1]==' ' || ptr[len-1]=='\t'))
- --len; // right-trim line
-
- // handle only non-empty lines
- if (len>0 && !(*handler)(data, ptr, len))
- return false; // some parsing-error occured...
- }
-
- ++line_nr;
- ptr = eol;
- if (*ptr) ++ptr;
- }
-
- return true;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "filecfg.h"
-
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-
-bool
-FileCfg_readEntryFlag(PathInfo const *base, char const *file, bool dflt)
-{
- PathInfo filepath = { .d = file, .l = strlen(file) };
- PathInfo path = *base;
- char path_buf[ENSC_PI_APPSZ(path, filepath)];
- struct stat st;
-
- PathInfo_append(&path, &filepath, path_buf);
- return stat(path.d, &st)!=-1 || dflt;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "filecfg.h"
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-char *
-FileCfg_readEntryStr (PathInfo const *base, char const *file,
- bool allow_multiline, char const *dflt)
-{
- PathInfo filepath = { .d = file, .l = strlen(file) };
- PathInfo path = *base;
- char path_buf[ENSC_PI_APPSZ(path, filepath)];
- int fd = -1;
- off_t sz;
- char * res = 0;
-
- PathInfo_append(&path, &filepath, path_buf);
- fd = open(path.d, O_RDONLY);
- if (fd==-1) goto err;
-
- sz = lseek(fd, 0, SEEK_END);
- if (sz==-1 ||
- lseek(fd, 0, SEEK_SET)==-1) goto err;
-
-
- if (sz>0 && sz<FILECFG_MAX_FILESIZE) {
- char buf[sz+1];
-
- if (read(fd, buf, sz+1)!=sz) goto err;
-
- if (!allow_multiline) {
- char * pos;
-
- buf[sz] = '\0';
- pos = strchr(buf, '\n');
- if (pos) *pos = '\0';
- }
- else {
- while (sz>0 && buf[sz-1]=='\n') --sz;
- buf[sz] = '\0';
- }
-
- res = strdup(buf);
- }
-
- err:
- if (res==0 && dflt)
- res = strdup(dflt);
-
- if (fd!=-1) close(fd);
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_FILECFG_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_FILECFG_H
-
-#include "pathinfo.h"
-#include <stdbool.h>
-
-// 1MiB should be enough for all applications
-#define FILECFG_MAX_FILESIZE 0x100000
-
-char * FileCfg_readEntryStr (PathInfo const *base, char const *file, bool allow_multiline, char const *dflt);
-bool FileCfg_readEntryFlag(PathInfo const *base, char const *file, bool dflt);
-
-typedef bool (*FileCfg_MultiLineHandler)(void *res, char const *data, size_t len);
-
-bool FileCfg_iterateOverMultiLine(char const *str, FileCfg_MultiLineHandler handler,
- void *data);
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_FILECFG_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_JAIL_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_JAIL_H
-
-#include <stdbool.h>
-
-bool jailIntoTempDir(char const **err_pos);
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_JAIL_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "jail.h"
-
-#include <stdlib.h>
-#include <grp.h>
-#include <unistd.h>
-
-bool
-jailIntoTempDir(char const **err_pos)
-{
- gid_t const id = 1;
- char buf[] = "/tmp/jaildir.XXXXXX";
- char const * d = mkdtemp(buf);
- char const * err = "mkdtemp()";
-
- if (d==0 ||
- (err="chdir()", chdir(d)==-1) ||
- (err="rmdir()", rmdir(d)==-1) ||
- (err="chroot()", chroot(".")==-1) ||
- (err="setgroups()",setgroups(1, &id)==-1) ||
- (err="setgid()", setgid(id)==-1) ||
- (err="setuid()", setuid(id)==-1) ||
- (err="getgid()", getgid()!=id) ||
- (err="getuid()", getuid()!=id)) {
- if (err_pos!=0) *err_pos = err;
- return false;
- }
-
- return true;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "matchlist.h"
-#include <fnmatch.h>
-#include <assert.h>
-
-static int
-fnmatchWrap(char const *a, char const *b)
-{
- return fnmatch(a, b, 0);
-}
-
-static MatchItemCompareFunc
-determineCompareFunc(char const UNUSED *fname)
-{
- return fnmatchWrap;
-}
-
-void
-MatchList_appendFiles(struct MatchList *list, size_t idx,
- char **files, size_t count,
- bool auto_type)
-{
- struct MatchItem *ptr = list->data + idx;
- size_t i;
-
- assert(idx+count <= list->count);
-
- if (auto_type) {
- for (i=0; i<count; ++i) {
- char *file = files[i];
- switch (file[0]) {
- case '+' : ptr->type = stINCLUDE; ++file; break;
- case '~' : ptr->type = stSKIP; ++file; break;
- case '-' : ++file; /*@fallthrough@*/
- default : ptr->type = stEXCLUDE; break;
- }
- ptr->cmp = determineCompareFunc(file);
- ptr->name = file;
- ++ptr;
- }
- }
- else {
- for (i=0; i<count; ++i) {
- ptr->type = stEXCLUDE;
- ptr->name = files[i];
- ptr->cmp = 0;
- ++ptr;
- }
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "matchlist.h"
-#include <string.h>
-
-MatchType
-MatchList_compare(struct MatchList const *list, char const *path)
-{
- struct MatchItem const * ptr = list->data;
- struct MatchItem const * const end_ptr = list->data + list->count;
-
- //write(1, path, strlen(path));
- //write(1, "\n", 1);
- for (; ptr<end_ptr; ++ptr) {
- if ((ptr->cmp==0 && strcmp(ptr->name, path)==0) ||
- (ptr->cmp!=0 && (ptr->cmp)(ptr->name, path)==0))
- return ptr->type;
- }
-
- return stINCLUDE;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "matchlist.h"
-
-void
-MatchList_destroy(struct MatchList *list)
-{
- size_t i;
-
- String_free(&list->id);
- free(list->data);
-
- for (i=0; i<list->buf_count; ++i)
- free((void *)(list->buf[i]));
-
- free(list->buf);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "matchlist.h"
-#include <string.h>
-#include <stdlib.h>
-
-#define ENSC_WRAPPERS_STDLIB 1
-#include <wrappers.h>
-void
-MatchList_init(struct MatchList *list, char const *root, size_t count)
-{
- list->skip_depth = 0;
- list->root.d = root;
- list->root.l = strlen(root);
- list->data = Emalloc(sizeof(struct MatchItem) * count);
- list->count = count;
- list->buf = 0;
- list->buf_count = 0;
-
- String_init(&list->id);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "pathconfig.h"
-
-#include "matchlist.h"
-#include "util-io.h"
-
-#include "vserver.h"
-
-#include <assert.h>
-
-bool
-MatchList_initByVserver(struct MatchList *list,
- struct MatchVserverInfo const *vserver)
-{
- assert(vserver->appdir!=0 && vserver->vdir!=0);
-
- size_t const l = vserver->appdir.l;
- char tmp[l + sizeof("/exclude")];
- char const * excl_list;
-
- memcpy(tmp, vserver->appdir.d, l);
- memcpy(tmp+l, "/exclude", 9);
-
- excl_list = tmp;
- if (access(excl_list, R_OK)==-1) excl_list = CONFDIR "/.defaults/apps/vunify/exclude";
- if (access(excl_list, R_OK)==-1) excl_list = PKGLIBDIR "/defaults/vunify-exclude";
-
- MatchList_initManually(list, vserver, 0, excl_list);
-
- return true;
-}
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "pathconfig.h"
-
-#include "matchlist.h"
-#include "util-io.h"
-
-#include <wait.h>
-#include <errno.h>
-#include <assert.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_STDLIB 1
-#define ENSC_WRAPPERS_IO 1
-#include <wrappers.h>
-
-
-extern int Global_getVerbosity() PURE CONST;
-extern bool Global_doRenew() PURE CONST;
-
-static void
-readExcludeListFD(int fd,
- char ***files, size_t *size,
- char **buf)
-{
- off_t len;
- size_t lines = 0;
- char *ptr;
-
- if (fd==-1) return; // todo: message on verbose?
-
- len = Elseek(fd, 0, SEEK_END);
- Elseek(fd, 0, SEEK_SET);
-
- *buf = Emalloc(sizeof(*buf) * (len+1));
- EreadAll(fd, *buf, len);
- (*buf)[len] = '\0';
-
- ptr = *buf;
- while ((ptr=strchr(ptr, '\n'))) {
- ++lines;
- ++ptr;
- }
-
- ++lines;
- *files = Emalloc(sizeof(**files) * lines);
-
- *size = 0;
- ptr = *buf;
- while (*ptr) {
- char *end_ptr = strchr(ptr, '\n');
-
- assert(*size<lines);
- if (end_ptr==0) break;
-
- if (*ptr!='#') {
- char *tmp = end_ptr;
- do {
- *tmp-- = '\0';
- } while (tmp>ptr && *tmp==' ');
-
- if (tmp>ptr) (*files)[(*size)++] = ptr;
- }
-
- ptr = end_ptr+1;
- }
-}
-
-static void
-readExcludeList(char const *filename,
- char ***files, size_t *size,
- char **buf)
-{
- int fd = open(filename, O_RDONLY);
- if (fd==-1) return; // todo: message on verbose?
-
- readExcludeListFD(fd, files, size, buf);
- Eclose(fd);
-}
-
-static void
-getConfigfileList(char const *vserver,
- char ***files, size_t *size,
- char **buf)
-{
- char tmpname[] = "/tmp/vunify.XXXXXX";
- pid_t pid;
- int fd = Emkstemp(tmpname);
-
- Eunlink(tmpname);
- pid = Efork();
-
- if (pid==0) {
- char *args[10];
- char const **ptr = (char const **)(args)+0;
-
- Edup2(fd, 1);
- //Eclose(0);
- if (fd!=1) Eclose(fd);
-
- *ptr++ = VPKG_PROG;
- *ptr++ = vserver;
- *ptr++ = "get-conffiles";
- *ptr = 0;
-
- Eexecv(args[0], args);
- }
- else {
- int status;
-
- if (TEMP_FAILURE_RETRY(wait4(pid, &status, 0,0))==-1) {
- perror("wait4()");
- exit(1);
- }
-
- if (!WIFEXITED(status) || WEXITSTATUS(status)!=0) {
- WRITE_MSG(2, "failed to determine configfiles\n");
- exit(1);
- }
-
- readExcludeListFD(fd, files, size, buf);
- Eclose(fd);
- }
-}
-
-void
-MatchList_initManually(struct MatchList *list,
- struct MatchVserverInfo const *vserver,
- char const *vdir, char const *exclude_file)
-{
- char *buf[2] = { 0,0 };
-
- char **fixed_files = 0;
- size_t fixed_count = 0;
-
- char **expr_files = 0;
- size_t expr_count = 0;
- size_t len;
-
- assert((vdir==0 && vserver!=0) || (vdir!=0 && vserver==0));
-
- if (vserver) {
- vdir = vserver->vdir.d;
- len = vserver->vdir.l;
- }
- else
- len = strlen(vdir);
-
- if (Global_getVerbosity()>=1) {
- WRITE_MSG(1, "Initializing exclude-list for ");
- Vwrite(1, vdir, len);
- if (vserver!=0) {
- WRITE_MSG(1, " (");
- WRITE_STR(1, vserver->name);
- WRITE_MSG(1, ")");
- }
- WRITE_MSG(1, "\n");
- }
- if (vserver && vserver->use_pkgmgmt && Global_doRenew()) {
- if (Global_getVerbosity()>=2)
- WRITE_MSG(1, " Fetching configuration-file list from packagemanagement\n");
- getConfigfileList(vserver->name, &fixed_files, &fixed_count, buf+0);
- }
-
- // abuse special values (NULL, empty string) to skip the next step
- if (exclude_file && *exclude_file) {
- if (Global_getVerbosity()>=6) WRITE_MSG(1, " Reading exclude file\n");
- readExcludeList(exclude_file,
- &expr_files, &expr_count,
- buf+1);
- }
-
- MatchList_init(list, strdup(vdir), fixed_count + expr_count);
- list->buf = Emalloc(sizeof(void *) * 3);
- list->buf[0] = buf[0];
- list->buf[1] = buf[1];
- list->buf[2] = list->root.d;
- list->buf_count = 3;
-
- MatchList_appendFiles(list, 0, fixed_files, fixed_count, false);
- MatchList_appendFiles(list, fixed_count, expr_files, expr_count, true);
-
- free(expr_files);
- free(fixed_files);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "matchlist.h"
-#include "util-io.h"
-
-#include <dirent.h>
-#include <string.h>
-#include <fcntl.h>
-
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_STDLIB 1
-#include <wrappers.h>
-
-static int
-selectRefserver(struct dirent const *ent)
-{
- return strncmp(ent->d_name, "refserver.", 10)==0;
-}
-
-void
-MatchList_initRefserverList(struct MatchList **lst, size_t *cnt,
- char const *dir)
-{
- int cur_dir = Eopen(".", O_RDONLY, 0);
- struct dirent **entries;
- int count,i;
-
- Echdir(dir);
- count = scandir(".", &entries, selectRefserver, alphasort);
- if (count==-1) {
- perror("scandir()");
- exit(1);
- }
-
- if (count==0) {
- WRITE_MSG(2, "no reference vserver configured\n");
- exit(1);
- }
-
- *lst = Emalloc(sizeof(struct MatchList) * count);
- *cnt = count;
- for (i=0; i<count; ++i) {
- char const *tmp = entries[i]->d_name;
- size_t l = strlen(tmp);
- char vname[sizeof("./") + l];
- struct MatchVserverInfo vserver = {
- .name = vname,
- .use_pkgmgmt = true
- };
-
- memcpy(vname, "./", 2);
- memcpy(vname+2, tmp, l+1);
-
- if (!MatchVserverInfo_init(&vserver)) {
- WRITE_MSG(2, "failed to initialize unification of reference vserver\n");
- exit(1);
- }
-
- if (!MatchList_initByVserver((*lst)+i, &vserver)) {
- WRITE_MSG(2, "unification for reference vserver not configured\n");
- exit(1);
- }
-
- free(entries[i]);
- MatchVserverInfo_free(&vserver);
- }
- free(entries);
-
- Efchdir(cur_dir);
- Eclose(cur_dir);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "matchlist.h"
-#include "util-io.h"
-
-void
-MatchList_printId(struct MatchList const *l, int fd)
-{
- if (l->id.l>0) {
- WRITE_MSG(fd, "'");
- Vwrite(fd, l->id.d, l->id.l);
- WRITE_MSG(1, "'");
- }
- else if (l->root.l>0) {
- Vwrite(fd, l->root.d, l->root.l);
- }
- else
- WRITE_MSG(fd, "???");
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_MATCHLIST_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_MATCHLIST_H
-
-#include "pathinfo.h"
-#include "string.h"
-#include "pathinfo.h"
-
-#include <lib/vserver.h>
-
-#include <stdlib.h>
-#include <stdbool.h>
-
-typedef int (*MatchItemCompareFunc)(char const *, char const *);
-typedef enum { stINCLUDE,stEXCLUDE,stSKIP } MatchType;
-
-struct MatchItem
-{
- MatchType type;
- char const * name;
- MatchItemCompareFunc cmp;
-};
-
-struct MatchList
-{
- size_t skip_depth;
- PathInfo root;
- String id;
- struct MatchItem *data;
- size_t count;
-
- void const **buf;
- size_t buf_count;
-};
-
-struct MatchVserverInfo
-{
- char const *name;
-
- vcCfgStyle style;
- PathInfo vdir;
- PathInfo appdir;
-
- bool use_pkgmgmt;
-};
-
-void MatchList_init(struct MatchList *, char const *root,
- size_t count) NONNULL((1,2));
-bool MatchList_initByVserver(struct MatchList *,
- struct MatchVserverInfo const *vserver) NONNULL((1,2));
-void MatchList_initManually(struct MatchList *list,
- struct MatchVserverInfo const *vserver,
- char const *vdir,
- char const *exclude_file) NONNULL((1,4));
-void MatchList_initRefserverList(struct MatchList **, size_t *cnt,
- char const *dir) NONNULL((1,2,3));
-void MatchList_destroy(struct MatchList *) NONNULL((1));
-void MatchList_appendFiles(struct MatchList *, size_t idx,
- char **files, size_t count,
- bool auto_type) NONNULL((1,3));
-
-MatchType MatchList_compare(struct MatchList const *,
- char const *path) NONNULL((1,2));
-struct MatchItem
-const * MatchList_find(struct MatchList const *,
- char const *path) NONNULL((1,2));
-
-void MatchList_printId(struct MatchList const *, int fd) NONNULL((1));
-
-
-bool MatchVserverInfo_init(struct MatchVserverInfo *);
-void MatchVserverInfo_free(struct MatchVserverInfo *);
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_MATCHLIST_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "matchlist.h"
-#include "util.h"
-
-void
-MatchVserverInfo_free(struct MatchVserverInfo *info)
-{
- String_free(&info->vdir);
- String_free(&info->appdir);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "matchlist.h"
-#include "util.h"
-
-#include <pathconfig.h>
-
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <sys/param.h>
-
-static bool
-exists(char *path, size_t len, char const *name)
-{
- if (name) strcpy(path + len, name);
-
- return access(path, R_OK)!=-1;
-}
-
-#define EXISTS(X) exists(X, sizeof(X)-1, 0)
-#define DEFAULT_EXISTS(X) EXISTS(CONFDIR "/.defaults/apps/vunify/" X)
-
-bool
-MatchVserverInfo_init(struct MatchVserverInfo *info)
-{
- assert(info->name!=0);
- assert(info->vdir.d==0 && info->appdir.d==0);
-
- info->style = vc_getVserverCfgStyle(info->name);
- info->vdir.d = vc_getVserverVdir (info->name, info->style, true);
- info->appdir.d = vc_getVserverAppDir (info->name, info->style, "vunify");
-
- if (info->vdir.d==0 || info->appdir.d==0) {
- free(const_cast(char *)(info->vdir.d));
- free(const_cast(char *)(info->appdir.d));
-
- return false;
- }
-
- info->vdir.l = strlen(info->vdir.d);
- info->appdir.l = strlen(info->appdir.d);
-
- size_t const l = info->appdir.l;
- char tmp[l + MAX(sizeof("/pkgmgmt-ignore"),sizeof("/pkgmgmt-force"))];
-
- memcpy(tmp, info->appdir.d, l);
-
- if (exists(tmp, l, "/pkgmgmt-ignore")) info->use_pkgmgmt = false;
- else if (exists(tmp, l, "/pkgmgmt-force")) info->use_pkgmgmt = true;
- else if (DEFAULT_EXISTS ("pkgmgmt-ignore")) info->use_pkgmgmt = false;
- else if (DEFAULT_EXISTS ("pkgmgmt-force")) info->use_pkgmgmt = true;
-
- return true;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "pathinfo.h"
-#include "util-mem.h"
-
-void
-PathInfo_append(PathInfo * restrict lhs,
- PathInfo const * restrict rhs,
- char *buf)
-{
- char * ptr = buf;
- char const * rhs_ptr = rhs->d;
- size_t rhs_len = rhs->l;
-
- while (lhs->l>1 && lhs->d[lhs->l-1]=='/') --lhs->l;
-
- if (lhs->l>0) {
- while (rhs->l>0 && *rhs_ptr=='/') {
- ++rhs_ptr;
- --rhs_len;
- }
-
- ptr = Xmemcpy(ptr, lhs->d, lhs->l);
- if (ptr[-1]!='/')
- ptr = Xmemcpy(ptr, "/", 1);
- }
-// else if (*rhs_ptr!='/')
-// ptr = Xmemcpy(ptr, "/", 1);
-
- ptr = Xmemcpy(ptr, rhs_ptr, rhs_len+1);
-
- lhs->d = buf;
- lhs->l = ptr-buf-1;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "pathinfo.h"
-#include <string.h>
-#include <assert.h>
-
-#define CHECK(LHS,RHS, EXP) \
- do { \
- PathInfo lhs = { LHS, sizeof(LHS)-1 }; \
- PathInfo rhs = { RHS, sizeof(RHS)-1 }; \
- char *buf = malloc(ENSC_PI_APPSZ(lhs,rhs)); \
- assert(ENSC_PI_APPSZ(lhs,rhs)>=sizeof(EXP)); \
- PathInfo_append(&lhs, &rhs, buf); \
- assert(memcmp(lhs.d, EXP, sizeof(EXP))==0); \
- assert(lhs.l == sizeof(EXP)-1); \
- free(buf); \
- } while (0)
-
-
-void
-PathInfo_test()
-{
- CHECK("/var", "/tmp", "/var/tmp");
- CHECK("/var", "tmp", "/var/tmp");
- CHECK("/var/", "/tmp", "/var/tmp");
- CHECK("/var/", "tmp", "/var/tmp");
-
- CHECK("/", "tmp", "/tmp");
- CHECK("/", "/tmp", "/tmp");
-
- CHECK("", "/tmp", "/tmp");
-
- CHECK("", "tmp", "tmp");
- CHECK("", "", "");
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_PATHINFO_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_PATHINFO_H
-
-#include "string.h"
-
-#define ENSC_PI_DECLARE(VAR,VAL) PathInfo VAR={.d = VAL,.l = sizeof(VAL)-1}
-#define ENSC_PI_APPSZ(P1,P2) ((P1).l + sizeof("/") + (P2).l)
-
-typedef String PathInfo;
-
-void PathInfo_append(PathInfo * restrict,
- PathInfo const * restrict,
- char *buf) NONNULL((1,2,3));
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_PATHINFO_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_STRING_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_STRING_H
-
-#include <stdlib.h>
-
-typedef struct
-{
- char const * d;
- size_t l;
-} String;
-
-static void String_init(String *);
-static void String_free(String *);
-
-#define ENSC_STRING_FIXED(VAL) { .d = VAL, .l = (sizeof(VAL)-1) }
-#define ENSC_STRING_ASSIGN_FIXED(DST,VAL) \
- { DST.d = (VAL); DST.l = (sizeof(VAL)-1); }
-
-#include "string.hc"
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_STRING_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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.
-
-static inline UNUSED void
-String_init(String *str)
-{
- str->d = 0;
- str->l = 0;
-}
-
-static inline UNUSED char const *
-String_c_str(String const *str, char *buf)
-{
- if (str->l==0) return "";
-
- if (buf!=str->d)
- abort(); // TODO: copy content
-
- buf[str->l] = '\0';
- return buf;
-}
-
-
-static inline UNUSED void
-String_free(String *str)
-{
- free((char *)(str->d));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 <vserver.h>
-#include <errno.h>
-#include <unistd.h>
-
- // try to switch into context 1
-bool
-switchToWatchXid(char const **errptr)
-{
-#if 0
-# warning Compiling in debug-code
- return;
-#endif
- if (vc_get_task_xid(0)==1) return true;
-
- if (vc_isSupported(vcFEATURE_MIGRATE)) {
- if (vc_ctx_migrate(1)==-1) {
- if (errptr) *errptr = "vc_migrate_context()";
- return false;
- }
- }
- else {
-#if VC_ENABLE_API_COMPAT
- if (vc_new_s_context(1,0,0)==VC_NOCTX) {
- if (errptr) *errptr = "vc_new_s_context()";
- return false;
- }
-#else
- if (errptr) *errptr = "can not change context: migrate kernel feature missing and 'compat' API disabled";
- errno = ENOSYS;
- return false;
-#endif
- }
-
- return true;
-}
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_SRC_SYS_CLONE_H
-#define H_UTIL_VSERVER_SRC_SYS_CLONE_H
-
-#include <asm/unistd.h>
-#define __NR_sys_clone __NR_clone
-
-#ifndef CLONE_NEWNS
-# define CLONE_NEWNS 0x00020000
-#endif
-
-#ifdef ENSC_SYSCALL_TRADITIONAL
-#include <sys/syscall.h>
-#include <unistd.h>
-
-inline static UNUSED ALWAYSINLINE
-int sys_clone(int flags, void *stack)
-{
-#if defined __dietlibc__
- extern long int syscall (long int __sysno, ...);
-#endif
-
- return syscall(__NR_sys_clone, flags, stack);
-}
-#else
-#include <errno.h>
-
-inline static UNUSED ALWAYSINLINE
-_syscall2(int, sys_clone, int, flags, void *, child_stack)
-#endif
-
-#undef __NR_sys_clone
-
-#define ENSC_HAVE_SYSCLONE 1
-
-#endif // H_UTIL_VSERVER_SRC_SYS_CLONE_H
+++ /dev/null
-.deps
-.dirstamp
-.libs
-.libs
-.nfs0*
-command
-copy
-filecfg-ml
-sigbus
+++ /dev/null
-## $Id$ --*- makefile -*--
-
-## Copyright (C) 2004 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.
-
-check_PROGRAMS += lib_internal/testsuite/command
-
-if ENSC_HAVE_C99_COMPILER
-check_PROGRAMS += lib_internal/testsuite/filecfg-ml \
- lib_internal/testsuite/copy \
- lib_internal/testsuite/sigbus
-TESTS += lib_internal/testsuite/filecfg-ml \
- lib_internal/testsuite/copy-check \
- lib_internal/testsuite/sigbus
-endif
-
-EXTRA_DIST += lib_internal/testsuite/copy-check
-
-TESTS_ENVIRONMENT += libinternaltestsuitedir=$(top_builddir)/lib_internal/testsuite
-
-
-lib_internal_testsuite_command_SOURCES = lib_internal/testsuite/command.c
-lib_internal_testsuite_command_LDADD = $(LIBINTERNAL_GLIBC) \
- $(LIBENSCVECTOR_GLIBC)
-
-lib_internal_testsuite_filecfg_ml_SOURCES = lib_internal/testsuite/filecfg-ml.c
-lib_internal_testsuite_filecfg_ml_LDADD = $(LIBINTERNAL_GLIBC)
-
-lib_internal_testsuite_copy_SOURCES = lib_internal/testsuite/copy.c
-lib_internal_testsuite_copy_LDADD = $(LIBINTERNAL_GLIBC)
-
-lib_internal_testsuite_sigbus_SOURCES = lib_internal/testsuite/sigbus.c
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 <lib_internal/util.h>
-#include <lib_internal/command.h>
-
-int wrapper_exit_code = 255;
-
-int
-main(int argc, char *argv[])
-{
- struct Command cmd;
- ssize_t i;
-
- if (argc<3) {
- WRITE_MSG(2, "Not enough parameters\n");
- return EXIT_FAILURE;
- }
-
- Command_init(&cmd);
- for (i=2; i<argc; ++i)
- Command_appendParameter(&cmd, argv[i]);
-
- if (Command_exec(&cmd, argv[1][0]!=0)) {
- Command_wait(&cmd, true);
- }
-
- Command_free(&cmd);
-}
+++ /dev/null
-#! /bin/bash
-## $Id$
-
-# Copyright (C) 2005 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.
-
-set -e
-
-dir=$(mktemp -d ${TMP:-/var/tmp}/copy-check.XXXXXX)
-trap "rm -rf $dir" EXIT
-
-COPY=${libinternaltestsuitedir:-$(dirname "$0")}/copy
-
-test -x "$COPY"
-
-function execWrap()
-{
- nr=$1
- msg=$2
- shift 2
-
- "$@" || {
- rc=$?
- echo $"Test $nr '$msg' failed with code $rc"
- return $rc
- }
-
- return 0
-}
-
-function doit()
-{
- execWrap "$nr" "copying" $COPY $dir/$nr-in $dir/$nr-out
- execWrap "$nr" "comparing" cmp $dir/$nr-in $dir/$nr-out
-}
-
-## Usage: execCheck <nr> [<dd-args>*]
-function execCheck()
-{
- local nr=$1
- shift
-
- dd if=/dev/urandom of=$dir/$nr-in "$@" &>/dev/null
-
- doit $nr
-}
-
-LANG=C
-
-### Check 1: small file copy
-execCheck 01 bs=10 count=1
-
-### Check 2: PAGESIZEd file copy
-execCheck 02 bs=4096 count=1
-
-### Check 3: PAGESIZE+1 file copy
-execCheck 03 bs=4097 count=1
-
-### Check 3a: really large file copy
-test x"$ensc_use_expensive_tests" != xyes ||
- execCheck 03a bs=$[ 64 * 1024*1024 + 23 ] count=1
-
-### Check 4: small sparse file copy
-execCheck 04 bs=10 count=1 seek=1
-
-### Check 5: large sparse file copy
-execCheck 05 bs=4097 count=1 seek=1
-
-### Check 6: large sparse file copy
-execCheck 06 bs=4098 count=1 seek=1
-
-### Check 7: large sparse file copy
-execCheck 07 bs=4099 count=1 seek=1
-
-### Check 8: large sparse file copy
-execCheck 08 bs=4100 count=1 seek=1
-
-### Check 8a: really large sparse file copy
-test x"$ensc_use_expensive_tests" != xyes ||
- execCheck 08a bs=$[ 64 * 1024*1024 + 23 ] count=1 seek=1
-
-### Check 9: huge sparse file copy
-test x"$ensc_use_expensive_tests" != xyes ||
- execCheck 09 bs=1024 count=1 seek=$[ 1024*1024 * 5 ]
-
-test x"$ensc_test_debug" != xyes || {
- ls -l $dir/*
- du $dir/*
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "lib_internal/unify.h"
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-int wrapper_exit_code = 1;
-
-int main(int argc, char *argv[])
-{
- struct stat st;
-
- if (argc<2) return EXIT_FAILURE;
- if (lstat(argv[1],&st)==-1) return EXIT_FAILURE;
-
- unlink(argv[2]);
- return Unify_copy(argv[1], &st, argv[2]) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 <lib_internal/filecfg.h>
-
-#include <string.h>
-#include <ctype.h>
-
-char const data[] = "\
-line 1\n\
-#line 2\n\
-\n\
-line 4\n\
- \n\
-line 6\n\
- \tline 7\n\
-line 8\t \n\
-";
-
-static bool
-test(void *x_p, char const *str, size_t len)
-{
- size_t *x = x_p;
-
- if (strncmp(str, "line ", 5)!=0) abort();
- if (!isdigit(str[len-1])) abort();
- ++*x;
- return true;
-}
-
-int main()
-{
- size_t l = 1;
- FileCfg_iterateOverMultiLine(data, test, &l);
- if (l!=6) abort();
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 <stdbool.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_SOCKET 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 1;
-
-#define TEST_BLOCKSIZE 0x10000
-static bool is_gremlin = false;
-static int sync_p[2];
-
-static void
-testit()
-{
- if (!is_gremlin) return;
-
- char c;
-
- Esend(sync_p[1], ".", 1, 0);
- Erecv(sync_p[1], &c, 1, 0);
-}
-
-#define TESTSUITE_COPY_CODE testit()
-
-#include "../unify.h"
-#include "../unify-copy.c"
-#include "../unify-settime.c"
-
-static bool
-checkTrunc(char const *src,
- char const *dst,
- struct stat const *st,
- size_t pos)
-{
- pid_t pid = Efork();
-
- if (pid==0) {
- char c;
-
- Erecv(sync_p[0], &c, 1, 0);
- Etruncate(src, pos);
- Esend(sync_p[0], &c, 1, 0);
- exit(0);
- }
-
- unlink(dst);
- return !copyReg(src, st, dst);
-}
-
-int main()
-{
- char f_name0[] = "/tmp/sigbus.XXXXXX";
- char f_name1[] = "/tmp/sigbus.XXXXXX";
- int fd_src = mkstemp(f_name0);
- int fd_dst = mkstemp(f_name1);
- char buf[TEST_BLOCKSIZE] = { [0] = '\0' };
- struct stat st;
- bool res;
-
- fd_src =
-
- write(fd_src, buf, sizeof(buf));
- close(fd_src);
- close(fd_dst);
-
- unlink(f_name1);
- stat(f_name0, &st);
- if (!copyReg(f_name0, &st, f_name1))
- return EXIT_FAILURE;
-
-
- is_gremlin = true;
-
- Esocketpair(AF_LOCAL, SOCK_STREAM, 0, sync_p);
- signal(SIGCHLD, SIG_IGN);
-
- res = (checkTrunc(f_name0, f_name1, &st, TEST_BLOCKSIZE/2) &&
- checkTrunc(f_name0, f_name1, &st, 0x2345));
-
- unlink(f_name0);
- unlink(f_name1);
- return res ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "unify.h"
-#include "util.h"
-
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-
-#define ENSC_WRAPPERS_IO 1
-#include <wrappers.h>
-
-#define MMAP_BLOCKSIZE (16 * 1024*1024)
-
-#ifndef TESTSUITE_COPY_CODE
-# define TESTSUITE_COPY_CODE do { } while (false)
-#endif
-
-static inline bool
-verifySource(int fd, struct stat const *exp_stat)
-{
- struct stat st;
-
- return (fstat(fd, &st)!=-1 &&
- st.st_dev==exp_stat->st_dev &&
- st.st_ino==exp_stat->st_ino);
-}
-
-static inline bool
-copyLnk(char const *src, char const *dst)
-{
- ssize_t len = 1024;
- for (;;) {
- char buf[len];
- ssize_t l;
- l = readlink(src, buf, len-1);
- if (l==-1) return false;
- if (l>=len-1) {
- len *= 2;
- continue;
- }
- buf[l] = '\0';
-
- return (symlink(buf, dst)!=-1);
- }
-}
-
-static sigjmp_buf bus_error_restore;
-static volatile sig_atomic_t bus_error;
-
-static void
-handlerSIGBUS(int UNUSED num)
-{
- bus_error = 1;
- siglongjmp(bus_error_restore, 1);
-}
-
-static void
-copyMem(void *dst_v, void const *src_v, size_t len_v)
-{
-#if 1
- int *dst = dst_v;
- int const *src = src_v;
- size_t len = len_v / sizeof(int);
- size_t rest = len_v - sizeof(int)*len;
- size_t i=0;
-
- for (; i<len; ++i) {
- if (*src != 0) *dst = *src;
- ++dst;
- ++src;
- }
-
- char *dst_c = (void *)(dst);
- char const *src_c = (void const *)(src);
-
- for (i=0; i<rest; ++i) {
- if (*src_c != 0) *dst_c = *src_c;
- ++dst_c;
- ++src_c;
- }
-#else
- memcpy(dst_v, src_v, len_v);
-#endif
-}
-
-static UNUSED bool
-copyMMap(int in_fd, int out_fd)
-{
- off_t in_len = lseek(in_fd, 0, SEEK_END);
- void const * volatile in_buf = 0;
- void * volatile out_buf = 0;
-
- loff_t volatile buf_size = 0;
- bool volatile res = false;
-
- if (in_len==-1) return false;
- if (in_len>0 &&
- (lseek(out_fd, in_len-1, SEEK_SET)==-1 ||
- write(out_fd, "\0", 1)!=1)) // create sparse file
- return false;
-
- bus_error = 0;
- if (sigsetjmp(bus_error_restore, 1)==0) {
- off_t offset = 0;
-
- while (offset < in_len) {
- buf_size = in_len - offset;
- if (buf_size > MMAP_BLOCKSIZE) buf_size = MMAP_BLOCKSIZE;
-
- if ((in_buf = mmap(0, buf_size, PROT_READ, MAP_SHARED, in_fd, offset))==0 ||
- (out_buf = mmap(0, buf_size, PROT_WRITE, MAP_SHARED, out_fd, offset))==0) {
- perror("mmap()");
- goto out;
- }
-
- offset += buf_size;
- madvise(const_cast(void *)(in_buf), buf_size, MADV_SEQUENTIAL);
- madvise(out_buf, buf_size, MADV_SEQUENTIAL);
-
- TESTSUITE_COPY_CODE;
- copyMem(out_buf, in_buf, buf_size);
-
- munmap(const_cast(void *)(in_buf), buf_size); in_buf = 0;
- munmap(out_buf, buf_size); out_buf = 0;
- }
-
- res = true;
- }
-
- out:
- if (in_buf !=0) munmap(const_cast(void *)(in_buf), buf_size);
- if (out_buf!=0) munmap(out_buf, buf_size);
-
- return res;
-}
-
-static inline bool
-copyReg(char const *src, struct stat const *src_stat,
- char const *dst)
-{
- int in_fd = open(src, O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_LARGEFILE);
- int out_fd = in_fd==-1 ? -1 : open(dst, O_RDWR|O_CREAT|O_EXCL, 0200);
- bool res = false;
-
- if (in_fd==-1 || out_fd==-1 ||
- !verifySource(in_fd, src_stat)) goto err;
-
-#if 0
- for (;;) {
- char buf[2048];
- ssize_t l = read(in_fd, buf, sizeof buf);
- if (l==-1) goto err;
- if (l==0) break;
- if (!WwriteAll(out_fd, buf, l, 0)) goto err;
- }
-
- res = true;
-#else
- void (*old_handler)(int) = signal(SIGBUS, handlerSIGBUS);
-
- res = copyMMap(in_fd, out_fd);
-
- signal(SIGBUS, old_handler);
-#endif
-
- err:
- if (out_fd!=-1 && close(out_fd)==-1) res=false;
- if (in_fd!=-1 && close(in_fd)==-1) res=false;
- return res;
-}
-
-static inline bool
-copyNode(char const UNUSED *src, struct stat const *src_stat,
- char const *dst)
-{
- return mknod(dst, src_stat->st_mode & (S_IFMT|S_IWUSR),
- src_stat->st_rdev)!=-1;
-}
-
-static inline bool
-copyDir(char const UNUSED *src, struct stat const UNUSED *src_stat,
- char const *dst)
-{
- return mkdir(dst, 0700)!=-1;
-}
-
-static inline bool
-setModes(char const *path, struct stat const *st)
-{
- return (lchown(path, st->st_uid, st->st_gid)!=-1 &&
- (S_ISLNK(st->st_mode) || chmod(path, st->st_mode)!=-1));
-}
-
-
-bool
-Unify_copy(char const *src, struct stat const *src_stat,
- char const *dst)
-{
- // skip sockets
- // TODO: message
- if (S_ISSOCK(src_stat->st_mode))
- return true;
-
- return
- (((S_ISLNK (src_stat->st_mode) && copyLnk (src, dst)) ||
- (S_ISREG (src_stat->st_mode) && copyReg (src, src_stat, dst)) ||
- (S_ISDIR (src_stat->st_mode) && copyDir (src, src_stat, dst)) ||
- ((S_ISBLK (src_stat->st_mode) ||
- S_ISCHR (src_stat->st_mode) ||
- S_ISFIFO(src_stat->st_mode)) && copyNode(src, src_stat, dst))
- ) &&
- setModes(dst, src_stat) &&
- Unify_setTime(dst, src_stat));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "unify.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <utime.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#define ENSC_WRAPPERS_IO 1
-#include <wrappers.h>
-
-bool
-Unify_deUnify(char const *dst)
-{
- size_t l = strlen(dst);
- char tmpfile[l + sizeof(";XXXXXX")];
- int fd_src, fd_tmp;
- struct stat st;
- struct utimbuf utm;
-
- fd_src = open(dst, O_RDONLY);
- if (fd_src==-1) {
- perror("open()");
- return false;
- }
-
- if (fstat(fd_src, &st)==-1) {
- perror("fstat()");
- close(fd_src);
- return false;
- }
-
- memcpy(tmpfile, dst, l);
- memcpy(tmpfile+l, ";XXXXXX", 8);
- fd_tmp = mkstemp(tmpfile);
-
- if (fd_tmp==-1) {
- perror("mkstemp()");
- tmpfile[0] = '\0';
- goto err;
- }
-
- if (fchown(fd_tmp, st.st_uid, st.st_gid)==-1 ||
- fchmod(fd_tmp, st.st_mode)==-1) {
- perror("fchown()/fchmod()");
- goto err;
- }
-
- // todo: acl?
-
- for (;;) {
- char buf[0x4000];
- ssize_t len = read(fd_src, buf, sizeof buf);
- if (len==-1) {
- perror("read()");
- goto err;
- }
- if (len==0) break;
-
- if (!WwriteAll(fd_tmp, buf, len, 0)) goto err;
- }
-
- if (close(fd_src)==-1) {
- perror("close()");
- goto err;
- }
- if (close(fd_tmp)==-1) {
- perror("close()");
- goto err;
- }
-
- utm.actime = st.st_atime;
- utm.modtime = st.st_mtime;
-
- // ALERT: race !!!
- if (utime(tmpfile, &utm)==-1) {
- perror("utime()");
- goto err1;
- }
-
- if (unlink(dst)==-1) {
- perror("unlink()");
- goto err1;
- }
-
- // ALERT: race !!!
- if (rename(tmpfile, dst)==-1) {
- perror("FATAL error in rename()");
- _exit(1);
- }
-
- return true;
-
- err:
- close(fd_src);
- close(fd_tmp);
- err1:
- if (tmpfile[0]) unlink(tmpfile);
-
- return false;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "unify.h"
-#include "vserver.h"
-
-
-UnifyStatus
-Unify_isIUnlinkable(char const *filename)
-{
- uint_least32_t const V = VC_IATTR_IUNLINK|VC_IATTR_IMMUTABLE;
-
- uint_least32_t flags;
- uint_least32_t mask = V;
-
- if (vc_get_iattr(filename, 0, &flags, &mask)==-1 || (mask & V) != V)
- return unifyUNSUPPORTED;
-
- return (flags & V)==V ? unifyBUSY : unifyUINLINKABLE;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "unify.h"
-#include <utime.h>
-#include <sys/stat.h>
-
-bool
-Unify_setTime(char const *dst, struct stat const *st)
-{
- struct utimbuf utm;
-
- // skip symlinks
- if (S_ISLNK(st->st_mode)) return true;
-
- utm.actime = st->st_atime;
- utm.modtime = st->st_mtime;
- return utime(dst, &utm)!=-1;
-}
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "unify.h"
-#include "vserver.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <signal.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-bool
-Unify_unify(char const *src, struct stat const UNUSED *src_stat,
- char const *dst, bool ignore_zero)
-{
- size_t l = strlen(dst);
- char tmpfile[l + sizeof(";XXXXXX")];
- int fd;
- bool res = false;
- struct stat st;
- bool lstat_succeeded;
- sigset_t mask_new, mask_old;
- int old_errno;
-
- // at first, set the ILI flags on 'src'
- if (vc_set_iattr(src,
- 0,
- VC_IATTR_IUNLINK|VC_IATTR_IMMUTABLE,
- VC_IATTR_IUNLINK|VC_IATTR_IMMUTABLE)==-1) {
- perror("vc_set_iattr()");
- return false;
- }
-
- lstat_succeeded = lstat(dst, &st)==0;
-
- sigfillset(&mask_new);
- if (sigprocmask(SIG_SETMASK, &mask_new, &mask_old)==-1) {
- perror("sigprocmask()");
- return false;
- }
-
-
- // check if 'dst' already exists
- // when ignore_zero is true, do not make backups of empty destinations
- if (lstat_succeeded && (st.st_size>0 || !ignore_zero)) {
- // now, create a temporary filename
- memcpy(tmpfile, dst, l);
- memcpy(tmpfile+l, ";XXXXXX", 8);
- fd = mkstemp(tmpfile);
- close(fd);
-
- if (fd==-1) {
- perror("mkstemp()");
- tmpfile[0] = '\0';
- goto err;
- }
-
- // and rename the old file to this name
-
- // NOTE: this rename() is race-free; when an attacker makes 'tmpfile' a
- // directory, the operation would fail; when making it a symlink to a file
- // or directory, the symlink but not the file/directory would be overridden
- if (rename(dst, tmpfile)==-1) {
- perror("rename()");
- goto err;
- }
- }
- else {
- if (lstat_succeeded) unlink(dst);
- tmpfile[0] = '\0';
- }
-
- // now, link the src-file to dst
- if (link(src, dst)==-1) {
- perror("link()");
-
- unlink(dst);
- if (tmpfile[0]!='\0' &&
- rename(tmpfile, dst)==-1) {
- perror("FATAL error in rename()");
- _exit(1);
- }
- goto err;
- }
-
- res = true;
-
- err:
- old_errno = errno;
-
- if (tmpfile[0]!='\0')
- unlink(tmpfile);
-
- if (sigprocmask(SIG_SETMASK, &mask_old, 0)==-1)
- perror("sigprocmask()");
-
- errno = old_errno;
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_UNIFY_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_UNIFY_H
-
-#include <sys/stat.h>
-#include <stdbool.h>
-
-bool
-Unify_unify(char const *src, struct stat const *src_stat,
- char const *dst, bool ignore_zero) NONNULL((1,2,3));
-
-bool
-Unify_copy(char const *src, struct stat const *src_stat,
- char const *dst) NONNULL((1,2,3));
-
-bool
-Unify_deUnify(char const *dst) NONNULL((1));
-
-bool
-Unify_setTime(char const *dst, struct stat const *stat) NONNULL((1,2));
-
-
-typedef enum { unifyUNSUPPORTED, unifyUINLINKABLE, unifyBUSY } UnifyStatus;
-
-UnifyStatus
-Unify_isIUnlinkable(char const *filename) NONNULL((1));
-
-#define Unify_isUnified(LHS, RHS) \
- ((bool)((LHS)->st_dev ==(RHS)->st_dev && \
- (LHS)->st_ino ==(RHS)->st_ino))
-
-#define Unify_isUnifyable(LHS, RHS) \
- ((bool)((LHS)->st_dev ==(RHS)->st_dev && \
- (LHS)->st_ino !=(RHS)->st_ino && \
- (LHS)->st_mode ==(RHS)->st_mode && \
- (LHS)->st_uid ==(RHS)->st_uid && \
- (LHS)->st_gid ==(RHS)->st_gid && \
- (LHS)->st_size ==(RHS)->st_size && \
- (LHS)->st_mtime==(RHS)->st_mtime))
-
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_UNIFY_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-
-size_t
-canonifyVserverName(char *name)
-{
- char *in = name;
- char *out = name;
-
- while (*in) {
- if ((*in>='a' && *in<='z') ||
- (*in>='A' && *in<='Z') ||
- (*in>='0' && *in<='9'))
- *out++ = *in;
- ++in;
- }
- *out = '\0';
- return out-name;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_UTILVSERVER_LIB_INTERNAL_UTIL_CAST_H
-#define H_UTILVSERVER_LIB_INTERNAL_UTIL_CAST_H
-
-#ifndef __cplusplus
-# define cAsT_(X) (X))
-# define reinterpret_cast(X) ((X) cAsT_
-# define static_cast(X) ((X) cAsT_
-# define const_cast(X) ((X) cAsT_
-#else /* __cplusplus */
-# define reinterpret_cast(X) reinterpret_cast<X>
-# define static_cast(X) static_cast<X>
-# define const_cast(X) const_cast<X>
-#endif
-
-#endif // H_UTILVSERVER_LIB_INTERNAL_UTIL_CAST_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_UTILVSERVER_LIB_INTERNAL_UTIL_COMMONSTRINGS_H
-#define H_UTILVSERVER_LIB_INTERNAL_UTIL_COMMONSTRINGS_H
-
-#ifndef PACKAGE_BUGREPORT
-# define PACKAGE_BUGREPORT "???"
-#endif
-
-#ifndef VERSION_COPYRIGHT_DISCLAIMER
-# define VERSION_COPYRIGHT_DISCLAIMER \
- "This program is free software; you may redistribute it under the terms of\n" \
- "the GNU General Public License. This program has absolutely no warranty.\n"
-#endif
-
-#endif // H_UTILVSERVER_LIB_INTERNAL_UTIL_COMMONSTRINGS_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_UTIL_DEBUG_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_UTIL_DEBUG_H
-
-#ifdef ENSC_ENABLE_DPRINTF
-# include <stdio.h>
-# define DPRINTF(FMT,...) printf(FMT, __VA_ARGS__)
-#else
-# define DPRINTF(FMT,...) do {} while(0)
-#endif
-
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_UTIL_DEBUG_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_UTILVSERVER_LIB_INTERNAL_UTIL_DECLARECMD_H
-#define H_UTILVSERVER_LIB_INTERNAL_UTIL_DECLARECMD_H
-
-#define VSERVER_DECLARE_CMD(CMD) \
- char buf[strlen(CMD)+1]; \
- memcpy(buf, (CMD), strlen(CMD)+1); \
- CMD = basename(buf);
-
-#endif // H_UTILVSERVER_LIB_INTERNAL_UTIL_DECLARECMD_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_UTILVSERVER_LIB_INTERNAL_UTIL_DIMOF_H
-#define H_UTILVSERVER_LIB_INTERNAL_UTIL_DIMOF_H
-
-#define DIM_OF(X) (sizeof(X)/sizeof((X)[0]))
-
-#endif // H_UTILVSERVER_LIB_INTERNAL_UTIL_DIMOF_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_UTIL_DOTFILE_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_UTIL_DOTFILE_H
-
-#include <stdbool.h>
-
-static inline UNUSED ALWAYSINLINE bool
-isDotfile(char const *d)
-{
- return d[0]=='.' && (d[1]=='\0' || (d[1]=='.' && d[2]=='\0'));
-}
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_UTIL_DOTFILE_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-#include <lib/internal.h>
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/resource.h>
-#include <stdio.h>
-
-void
-exitLikeProcess(int pid, char const *cmd, int ret)
-{
- int status;
-
- if (wait4(pid, &status, 0,0)==-1) {
-
- perror("wait()");
- exit(ret);
- }
-
- if (WIFEXITED(status))
- exit(WEXITSTATUS(status));
-
- if (WIFSIGNALED(status)) {
- struct rlimit lim = { 0,0 };
-
- if (cmd) {
- char buf[sizeof(int)*3 + 2];
- size_t l = utilvserver_fmt_uint(buf, pid);
-
- WRITE_MSG(2, "command '");
- WRITE_STR(2, cmd);
- WRITE_MSG(2, "' (pid ");
- Vwrite (2, buf, l);
- WRITE_MSG(2, ") exited with signal ");
- l = utilvserver_fmt_uint(buf, WTERMSIG(status));
- Vwrite (2, buf, l);
- WRITE_MSG(2, "; following it...\n");
- }
-
- // prevent coredumps which might override the real ones
- setrlimit(RLIMIT_CORE, &lim);
-
- kill(getpid(), WTERMSIG(status));
- exit(1);
- }
- else {
- char buf[sizeof(int)*3 + 2];
- size_t l = utilvserver_fmt_uint(buf, WTERMSIG(status));
-
- WRITE_MSG(2, "Unexpected status ");
- Vwrite (2, buf, l);
- WRITE_MSG(2, " from '");
- if (cmd) {
- WRITE_STR(2, cmd);
- WRITE_MSG(2, " (pid ");
- }
- l = utilvserver_fmt_uint(buf, pid);
- Vwrite (2, buf, l);
- if (cmd) WRITE_MSG(2, ")\n");
- else WRITE_MSG(2, "\n");
-
- exit(ret);
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_UTILVSERVER_LIB_INTERNAL_UTIL_EXITLIKEPROCESS_H
-#define H_UTILVSERVER_LIB_INTERNAL_UTIL_EXITLIKEPROCESS_H
-
-#include <sys/types.h>
-void exitLikeProcess(pid_t pid, char const /*@null@*/ *cmd, int ret) NORETURN;
-
-#endif // H_UTILVSERVER_LIB_INTERNAL_UTIL_EXITLIKEPROCESS_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_UTIL_IO_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_UTIL_IO_H
-
-#include <unistd.h>
-#include <string.h>
-
-inline static void UNUSED
-Vwrite(int fd, char const *buf, size_t len)
-{
- if (write(fd,buf,len)==-1) { /**/ }
-}
-
-inline static void UNUSED
-writeStr(int fd, char const *cmd)
-{
- Vwrite(fd, cmd, strlen(cmd));
-}
-
-#define WRITE_MSG(FD,X) Vwrite(FD,X,sizeof(X)-1)
-#define WRITE_STR(FD,X) writeStr(FD,X)
-
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_UTIL_IO_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util-lockfile.h"
-#include "errinfo.h"
-
-#include <signal.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <errno.h>
-
-static volatile sig_atomic_t alarm_flag = 0;
-
-static void
-alarmFunc(int UNUSED sig)
-{
- alarm_flag = 1;
- signal(SIGALRM, alarmFunc);
-}
-
-bool
-lockfile(int *fd, char const *filename, int op, long timeout,
- struct ErrorInformation *err)
-{
- char const *errstr = 0;
- void (*old_sighandler)(int) = 0;
-
- errstr = "open()";
- *fd = open(filename, O_CREAT|O_RDONLY|O_NOFOLLOW|O_NONBLOCK, 0644);
- if (*fd==-1) goto err;
-
- if (timeout!=-1) {
- errstr = "siginterrupt()";
- if (siginterrupt(SIGALRM, 1)==-1) goto err;
-
- errstr = "signal()";
- old_sighandler = signal(SIGALRM, alarmFunc);
- if (old_sighandler==SIG_ERR) goto err;
-
- alarm(timeout);
- }
-
- errstr = "flock()";
- while (flock(*fd, op)==-1) {
- if ((errno!=EINTR && errno!=EINTR) || alarm_flag) goto err;
- }
-
- if (timeout!=-1 && old_sighandler!=0)
- signal(SIGALRM, old_sighandler);
-
- errstr = "fcntl()";
- if (fcntl(*fd, F_SETFD, FD_CLOEXEC)==-1) goto err;
-
- return true;
-
- err:
- if (err) {
- err->pos = errstr;
- err->id = errno;
- }
- if (timeout!=-1 && old_sighandler!=0)
- signal(SIGALRM, old_sighandler);
- if (*fd!=-1) close(*fd);
- return false;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_UTIL_LOCKFILE_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_UTIL_LOCKFILE_H
-
-#include <stdbool.h>
-
-struct ErrorInformation;
-
-bool lockfile(int *fd, char const *filename, int op,
- long timeout,
- struct ErrorInformation *err);
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_UTIL_LOCKFILE_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_UTIL_MEM_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_UTIL_MEM_H
-
-#include <string.h>
-#include <stdlib.h>
-
-inline static void *
-Xmemcpy(void * restrict dst, void const * restrict src, size_t len)
-{
- return (char *)(memcpy(dst, src, len))+len;
-}
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_UTIL_MEM_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_UTIL_PERROR_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_UTIL_PERROR_H
-
-#define PERROR_U(MSG, ARG0) do { \
- size_t pu_l1 = strlen(MSG); \
- size_t pu_l2 = strlen(ARG0); \
- char pu_buf[pu_l1 + pu_l2 + sizeof("()")]; \
- memcpy(pu_buf, MSG, pu_l1); \
- pu_buf[pu_l1] = '('; \
- memcpy(pu_buf+1+pu_l1, ARG0, pu_l2); \
- pu_buf[pu_l1+1+pu_l2] = ')'; \
- pu_buf[pu_l1+2+pu_l2] = '\0'; \
- perror(pu_buf); \
- } while (0)
-
-#define PERROR_Q(MSG, ARG0) do { \
- size_t pq_l = strlen(ARG0); \
- char pq_buf[pq_l + 3]; \
- pq_buf[0] = '"'; \
- memcpy(pq_buf+1, ARG0, pq_l); \
- pq_buf[pq_l+1] = '"'; \
- pq_buf[pq_l+2] = '\0'; \
- PERROR_U(MSG, pq_buf); \
- } while (0)
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_UTIL_PERROR_H
+++ /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 <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-
-int
-safeChdir(char const *path, struct stat const *exp_stat)
-{
- if (strchr(path, '/')!=0) {
- errno = EINVAL;
- return -1;
- }
-
- {
- struct stat now_stat;
- if (chdir(path)==-1 ||
- stat(".", &now_stat)==-1) return -1;
- if (exp_stat->st_dev != now_stat.st_dev ||
- exp_stat->st_ino != now_stat.st_ino) {
- // TODO: warning/logging
- errno = EINVAL;
- return -1;
- }
- }
-
- return 0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_UTIL_SAFECHDIR_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_UTIL_SAFECHDIR_H
-
-struct stat;
-int safeChdir(char const *, struct stat const *exp_stat) NONNULL((1,2));
-
-#define EsafeChdir(PATH,EXP_STAT) \
- FatalErrnoError(safeChdir(PATH,EXP_STAT)==-1, "safeChdir()")
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_UTIL_SAFECHDIR_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_LIB_INTERNAL_UTIL_UNIXSOCK_H
-#define H_UTIL_VSERVER_LIB_INTERNAL_UTIL_UNIXSOCK_H
-
-#define ENSC_INIT_UNIX_SOCK(ADDR, FILENAME) \
- (ADDR).sun_family = AF_UNIX; \
- strncpy((ADDR).sun_path, FILENAME, sizeof((ADDR).sun_path)); \
- (ADDR).sun_path[sizeof((ADDR).sun_path)-1] = '\0';
-
-#endif // H_UTIL_VSERVER_LIB_INTERNAL_UTIL_UNIXSOCK_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_UTILVSERVER_LIB_INTERNAL_UTIL_H
-#define H_UTILVSERVER_LIB_INTERNAL_UTIL_H
-
-#include "util-cast.h"
-#include "util-commonstrings.h"
-#include "util-debug.h"
-#include "util-declarecmd.h"
-#include "util-dimof.h"
-#include "util-dotfile.h"
-#include "util-exitlikeprocess.h"
-#include "util-io.h"
-#include "util-lockfile.h"
-#include "util-mem.h"
-#include "util-perror.h"
-#include "util-safechdir.h"
-#include "util-unixsock.h"
-
-bool switchToWatchXid(char const **);
-size_t canonifyVserverName(char *);
-
-#endif // H_UTILVSERVER_LIB_INTERNAL_UTIL_H
+++ /dev/null
-## $Id$ ---*- makefile -*---
-
-## Copyright (C) 2002 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.
-##
-
-ChangeLog.sed:
- test "$(srcdir)" != "."
-
-if HAVE_CVS2CL
-ChangeLog: Makefile
- if test "$(srcdir)" = "." -a -d CVS; then \
- $(CVS2CL) $(CVS2CL_ALLFLAGS) -f $@; \
- fi
-else
-if HAVE_RCS2LOG
-ChangeLog: ChangeLog.sed Makefile
- if test "$(srcdir)" = "." -a -d CVS; then \
- $(RCS2LOG) -l 0 -c /dev/stdout | sed -f $< >$@; \
- fi
-endif
-endif
-
-.PHONY: ChangeLog
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-AC_DEFUN([__ENSC_CHECK_WARNFLAGS],
-[
- warn_flags="-Werror -W"
- AC_MSG_CHECKING([whether the $1-compiler accepts ${warn_flags}])
- AC_LANG_PUSH($1)
- __ensc_check_warnflags_old_CFLAGS="${$3}"
- $3="$warn_flags"
- AC_TRY_COMPILE([inline static void f(){}],
- [],
- [ensc_sys_compilerwarnflags_$2=${warn_flags}],
- [ensc_sys_compilerwarnflags_$2=])
- AC_LANG_POP($1)
- $3="$__ensc_check_warnflags_old_CFLAGS"
-
- if test x"${ensc_sys_compilerwarnflags_$2}" = x; then
- AC_MSG_RESULT([no])
- else
- AC_MSG_RESULT([yes])
- fi
-])
-
-AC_DEFUN([__ENSC_CHECK_WARNFLAGS_C],
-[
- __ENSC_CHECK_WARNFLAGS(C, C, CFLAGS)
-])
-
-AC_DEFUN([__ENSC_CHECK_WARNFLAGS_CXX],
-[
- __ENSC_CHECK_WARNFLAGS(C++, CXX, CXXFLAGS)
-])
-
-
-# --------------------------------------------------------------------------
-# Check whether the C++ compiler accepts a certain flag
-# If it does it adds the flag to CXXFLAGS
-# If it does not then it returns an error to lf_ok
-# Usage:
-# ENSC_CHECK_CXX_FLAG(-flag1 -flag2 -flag3 ...)
-# -------------------------------------------------------------------------
-
-AC_DEFUN([ENSC_CHECK_CXX_FLAG],
-[
- AC_REQUIRE([__ENSC_CHECK_WARNFLAGS_CXX])
-
- echo 'void f(){}' > conftest.cc
- for i in $1
- do
- AC_MSG_CHECKING([whether $CXX accepts $i])
- if test -z "`${CXX} ${ensc_sys_compilerwarnflags_CXX} $i -c conftest.cc 2>&1`"
- then
- CXXFLAGS="${CXXFLAGS} $i"
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
- done
- rm -f conftest.cc conftest.o
-])
-
-# --------------------------------------------------------------------------
-# Check whether the C compiler accepts a certain flag
-# If it does it adds the flag to CFLAGS
-# If it does not then it returns an error to lf_ok
-# Usage:
-# ENSC_CHECK_CC_FLAG(-flag1 -flag2 -flag3 ...)
-# -------------------------------------------------------------------------
-
-AC_DEFUN([ENSC_CHECK_CC_FLAG],
-[
- AC_REQUIRE([__ENSC_CHECK_WARNFLAGS_C])
-
-echo 'void f(){}' > conftest.c
- for i in $1
- do
- AC_MSG_CHECKING([whether $CC accepts $i])
- if test -z "`${CC} ${ensc_sys_compilerwarnflags_C} $i -c conftest.c 2>&1`"
- then
- CFLAGS="${CFLAGS} $i"
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
- done
- rm -f conftest.c conftest.o
-])
-
-AC_DEFUN([ENSC_CHECK_DEFAULT_FLAG],
-[
- if test x"${ensc_sys_default_flag}" = x; then
- ENSC_CHECK_CC_FLAG([-fmessage-length=0])
- ENSC_CHECK_CXX_FLAG([-fmessage-length=0])
-
- ensc_sys_default_flag=set
- fi
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-dnl Usage: ENSC_CHANGELOG(<CVS_TAG>)
-
-AC_DEFUN([ENSC_CHANGELOG],
-[
- if test x"$1" != x; then
- AC_SUBST(CVS2CL_TAG, ['-F $1'])
- fi
-
- AC_CHECK_PROGS(CVS2CL, [cvs2cl])
- AM_CONDITIONAL(HAVE_CVS2CL, [test x"$CVS2CL" != x])
-
- AC_CHECK_PROGS(RCS2LOG, [rcs2log])
- AM_CONDITIONAL(HAVE_RCS2LOG, [test x"$RCS2LOG" != x])
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-AC_DEFUN([ENSC_CXXCOMPILER],
-[
- AC_REQUIRE([AC_PROG_CXX])
-
- AC_CACHE_CHECK([whether $CXX is a C++ compiler], [ensc_cv_cxx_cxxcompiler],
- [
- AC_LANG_PUSH(C++)
- AC_COMPILE_IFELSE([
- #include <ostream>
- ],
- [ensc_cv_cxx_cxxcompiler=yes],
- [ensc_cv_cxx_cxxcompiler=no])
- AC_LANG_POP(C++)
- ])
-
- AM_CONDITIONAL(ENSC_HAVE_CXX_COMPILER,
- [test x"$ensc_cv_cxx_cxxcompiler" = xyes])
-
- if test x"$ensc_cv_cxx_cxxcompiler" = xno; then
- AC_MSG_WARN([*** some programs will not be built because a C++ compiler is lacking])
- fi
-])
-
-AC_DEFUN([ENSC_C99COMPILER],
-[
- AC_REQUIRE([AC_PROG_CC])
-
- AC_CACHE_CHECK([whether $CC is a C99 compiler], [ensc_cv_c99_c99compiler],
- [
- AC_LANG_PUSH(C)
- AC_COMPILE_IFELSE([
-int main(int argc, char *argv[]) {
- struct { int x; } a = { .x = argc };
- if (0) return 0;
- int b;
-}
- ],
- [ensc_cv_c99_c99compiler=yes],
- [ensc_cv_c99_c99compiler=no])
- AC_LANG_POP(C)
- ])
-
- AM_CONDITIONAL(ENSC_HAVE_C99_COMPILER,
- [test x"$ensc_cv_c99_c99compiler" = xyes])
-
- if test x"$ensc_cv_c99_c99compiler" = xno; then
- AC_MSG_WARN([*** some programs will not be built because a C99 compiler is lacking])
- fi
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-AC_DEFUN([_ENSC_DIETLIBC_C99],
-[
- AH_TEMPLATE([ENSC_DIETLIBC_C99], [Define to 1 if dietlibc supports C99])
-
- AC_CACHE_CHECK([whether dietlibc supports C99], [ensc_cv_c_dietlibc_c99],
- [
- _ensc_dietlibc_c99_old_CFLAGS=$CFLAGS
- _ensc_dietlibc_c99_old_CC=$CC
-
- CFLAGS="-std=c99"
- CC="${DIET:-diet} $CC"
-
- AC_LANG_PUSH(C)
- AC_COMPILE_IFELSE([/* */],[
- AC_COMPILE_IFELSE([
- #include <stdint.h>
- #include <sys/cdefs.h>
- #if defined(inline)
- # error 'inline' badly defined
- #endif
- volatile uint64_t a;
- ],
- [ensc_cv_c_dietlibc_c99=yes],
- [ensc_cv_c_dietlibc_c99=no])],
- [ensc_cv_c_dietlibc_c99='skipped (compiler does not support C99)'])
- AC_LANG_POP
-
- CC=$_ensc_dietlibc_c99_old_CC
- CFLAGS=$_ensc_dietlibc_c99_old_CFLAGS
- ])
-
- if test x"$ensc_cv_c_dietlibc_c99" = xyes; then
- AC_DEFINE(ENSC_DIETLIBC_C99,1)
- fi
-])
-
-dnl Usage: ENSC_ENABLE_DIETLIBC(<conditional>[,<min-version>])
-dnl <conditional> ... automake-conditional which will be set when
-dnl dietlibc shall be enabled
-dnl provides:
-dnl * $ENSC_VERSION_DIETLIBC_NUM and
-dnl * $ENSC_VERSION_DIETLIBC
-
-AC_DEFUN([ENSC_ENABLE_DIETLIBC],
-[
- AC_MSG_CHECKING([whether to enable dietlibc])
- AC_ARG_ENABLE([dietlibc],
- [AC_HELP_STRING([--disable-dietlibc],
- [do not use dietlibc (default: use dietlibc)])],
- [case "$enableval" in
- yes) use_dietlibc=forced;;
- no) use_dietlibc=forced_no;;
- *) AC_MSG_ERROR(['$enableval' is not a valid value for --enable-dietlibc]);;
- esac],
- [: ${DIET:=diet}
- which "$DIET" >/dev/null 2>/dev/null && use_dietlibc=detected || use_dietlibc=detected_no])
-
- if test "$use_dietlibc" = detected -a '$2'; then
- _dietlibc_ver=$(${DIET:-diet} -v 2>&1 | sed '1p;d')
- _dietlibc_ver=${_dietlibc_ver##*diet version }
- _dietlibc_ver=${_dietlibc_ver##*dietlibc-}
- _dietlibc_ver_maj=${_dietlibc_ver%%.*}
- _dietlibc_ver_min=${_dietlibc_ver##*.}
- _dietlibc_ver_min=${_dietlibc_ver_min%%[[!0-9]]*}
- _dietlibc_cmp=$2
- _dietlibc_cmp_maj=${_dietlibc_cmp%%.*}
- _dietlibc_cmp_min=${_dietlibc_cmp##*.}
-
- ENSC_VERSION_DIETLIBC=$_dietlibc_ver_maj.$_dietlibc_ver_min
-
- let _dietlibc_ver=_dietlibc_ver_maj*1000+_dietlibc_ver_min 2>/dev/null || _dietlibc_ver=0
- let _dietlibc_cmp=_dietlibc_cmp_maj*1000+_dietlibc_cmp_min
-
- test $_dietlibc_ver -ge $_dietlibc_cmp || use_dietlibc=detected_old
- else
- ENSC_VERSION_DIETLIBC=
- _dietlibc_ver=-1
- fi
-
- ENSC_VERSION_DIETLIBC_NUM=$_dietlibc_ver
- ensc_have_dietlibc=no
-
- case x"$use_dietlibc" in
- xdetected)
- AM_CONDITIONAL($1, true)
- AC_MSG_RESULT([yes (autodetected, $ENSC_VERSION_DIETLIBC)])
- ensc_have_dietlibc=yes
- ;;
- xforced)
- AM_CONDITIONAL($1, true)
- AC_MSG_RESULT([yes (forced)])
- ensc_have_dietlibc=yes
- ;;
- xdetected_no)
- AM_CONDITIONAL($1, false)
- AC_MSG_RESULT([no (detected)])
- ;;
- xdetected_old)
- AM_CONDITIONAL($1, false)
- AC_MSG_RESULT([no (too old; $2+ required, $ENSC_VERSION_DIETLIBC found)])
- ;;
- xforced_no)
- AM_CONDITIONAL($1, false)
- AC_MSG_RESULT([no (forced)])
- ;;
- *)
- AC_MSG_ERROR([internal error, use_dietlibc was "$use_dietlibc"])
- ;;
- esac
-
- if test x"$ensc_have_dietlibc" != xno; then
- _ENSC_DIETLIBC_C99
- fi
-])
-
-
-dnl Usage: ENSC_DIETLIBC_SANITYCHECK
-AC_DEFUN([ENSC_DIETLIBC_SANITYCHECK],
-[
- AC_REQUIRE([AC_CANONICAL_HOST])
- AC_REQUIRE([ENSC_ENABLE_DIETLIBC])
-
- if test "$host_cpu" = x86_64 -a $ENSC_VERSION_DIETLIBC_NUM -le 0027; then
- AC_MSG_WARN([*** ***])
- AC_MSG_WARN([*** dietlibc<=0.27 is known to be broken for x86_64 systems ***])
- AC_MSG_WARN([*** please make sure that at least the environ.S fix is applied ***])
- AC_MSG_WARN([*** and lib/__nice.c added ***])
- AC_MSG_WARN([*** ***])
- fi
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-AC_DEFUN([ENSC_DIETLIBC_NEED_COMPAT],
-[
- AC_REQUIRE([ENSC_ENABLE_DIETLIBC])
- AC_CACHE_CHECK([whether dietlibc needs '-lcompat'], [ensc_cv_c_dietlibc_compat],
- [
- AC_LANG_PUSH(C)
- ensc_dietlibc_need_compat_old_CC=$CC
- CC="${DIET:-diet} $CC"
- AC_LINK_IFELSE([
- AC_LANG_PROGRAM([
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <errno.h>
-
-#define __NR_foo0 42
-#define __NR_foo1 42
-#define __NR_foo2 42
-#define __NR_foo3 42
-#define __NR_foo4 42
-#define __NR_foo5 42
-inline static _syscall0(int, foo0)
-inline static _syscall1(int, foo1, int, a)
-inline static _syscall2(int, foo2, int, a, int, b)
-inline static _syscall3(int, foo3, int, a, int, b, int, c)
-inline static _syscall4(int, foo4, int, a, int, b, int, c, int, d)
-inline static _syscall5(int, foo5, int, a, int, b, int, c, int, d, int, e)
-],
- [foo0(); foo1(0); foo2(0,0); foo3(0,0,0); foo4(0,0,0,0); foo5(0,0,0,0,0);])],
- [ensc_cv_c_dietlibc_compat=no],
- [ensc_cv_c_dietlibc_compat=yes])
- CC=$ensc_dietlibc_need_compat_old_CC
- AC_LANG_POP
- ])
-
- if test x"$1" != x; then
- AM_CONDITIONAL($1, test x"$ensc_cv_c_dietlibc_compat" = xyes)
- fi
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-AC_DEFUN([ENSC_CHECK_EXT2FS_HEADER],
-[
- AC_LANG_PUSH(C++)
- AC_CACHE_CHECK([for ext2fs-headers], [ensc_cv_test_ext2fs_header],[
- AC_COMPILE_IFELSE(AC_LANG_SOURCE([#include <ext2fs/ext2_fs.h>
- int main() { return 0; }]),
- [ensc_cv_test_ext2fs_header=e2fsprogs],[
- AC_COMPILE_IFELSE(AC_LANG_SOURCE([#include <linux/ext2_fs.h>
- int main() { return 0; }]),
- [ensc_cv_test_ext2fs_header=kernel],[
- ensc_cv_test_ext2fs_header=none])])])
-
- case x"$ensc_cv_test_ext2fs_header" in
- (xe2fsprogs)
- AC_CHECK_HEADER([ext2fs/ext2_fs.h],
- [AC_DEFINE(ENSC_HAVE_EXT2FS_EXT2_FS_H, 1, [define when <ext2fs/ext2_fs.h> is usable])],
- [AC_MSG_FAILURE([unexpected error while checkin for <ext2fs/ext2_fs.h>])])
- ;;
- (xkernel)
- AC_CHECK_HEADER([linux/ext2_fs.h],
- [AC_DEFINE(ENSC_HAVE_LINUX_EXT2_FS_H, 1, [define when <linux/ext2_fs.h> is usable])],
- [AC_MSG_FAILURE([unexpected error while checkin for <linux/ext2_fs.h>])])
- ;;
- (*)
- AC_MSG_FAILURE([
-ext2fs headers were not found, or they are not usable. This can have
-the following reasons:
-
-* you have neither the e2fsprogs nor the kernel headers installed
-
-* kernel headers are broken (e.g. these of linux 2.6 are known to be)
- and you do not have e2fsprogs headers installed; please try to install
- - e2fsprogs-devel (for Red Hat), or
- - libext2fs2-devel (for Mandrake), or
- - e2fslibs-dev (for Debian)
- in this case.
-
-* kernel headers are broken and your e2fsprogs headers are too old;
- until version 1.27 (inclusive), they are using reserved C++ keywords
-
-* kernel headers are broken and your e2fsprogs headers are too new;
- recent (January 2004) BK snapshots of e2fsprogs are unusable for
- C++, for details and a solution see
- https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=112448
-
-
-In the latter two cases you have the following options:
-* fix the headers manually, or
-* install a stable version of e2fsprogs (e.g. 1.34), or
-* use good kernel headers (from linux 2.4.x)
-])
- ;;
- esac
- AC_LANG_POP
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-AC_DEFUN([ENSC_FPIC_SYSCALL],
-[
- AC_CACHE_CHECK([whether syscall() allows -fpic], [ensc_cv_c_fpic_syscall],
- [
- ensc_fpic_syscall_old_CFLAGS=$CFLAGS
- CFLAGS="-fPIC -DPIC"
-
- AC_LANG_PUSH(C)
- AC_COMPILE_IFELSE([
- #include <sys/syscall.h>
- #include <unistd.h>
- #include <asm/unistd.h>
- #include <errno.h>
-
- #define __NR_dummy 42
- _syscall3(int, dummy, int, a, int, b, int, c)],
- [ensc_cv_c_fpic_syscall=yes], [ensc_cv_c_fpic_syscall=no])
- AC_LANG_POP
-
- CFLAGS=$ensc_fpic_syscall_old_CFLAGS
- ])
-
- AM_CONDITIONAL(ENSC_ALLOW_FPIC_WITH_SYSCALL, [test x"$ensc_cv_c_fpic_syscall" = xyes])
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-dnl Usage: ENSC_INITRDDIR(<variable>)
-
-AC_DEFUN([ENSC_INITRDDIR],
-[
- AC_MSG_CHECKING([for initrddir])
- AC_ARG_WITH([initrddir],
- [AC_HELP_STRING([--with-initrddir <DIR>],
- [use <DIR> as directory for SysV init-files (default: $sysconfdir/init.d)])],
- [case "$withval" in
- yes|no) AC_MSG_ERROR(['$withval' is not a valid value for '--with-initrddir']);;
- *) ensc_initrddir=$withval;;
- esac],
- [ensc_initrddir='$(sysconfdir)/init.d'])
-
- if test "$1"; then
- $1=$ensc_initrddir
- AC_SUBST($1)
- fi
-
- AC_MSG_RESULT($ensc_initrddir)
-])
-
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-dnl Usage: ENSC_KERNEL_HEADERS(<var>)
-dnl <var> ... basedir of kernel-headers (without the '/linux');
-dnl this value will be AC_SUBST'ed
-
-AC_DEFUN([_ENSC_KERNEL_DIR],
-[
- AC_CACHE_CHECK([for linux kernel dir], [ensc_cv_path_kerneldir],
- [
-AC_ARG_WITH([kerneldir],
- [AC_HELP_STRING([--with-kerneldir=DIR],
- [assume kernelsources in DIR (default: /lib/modules/<current>/build)])],
- [case "$withval" in
- yes|no) AC_MSG_ERROR(['$withval' is not a valid value for kerneldir]);;
- *) ensc_cv_path_kerneldir=$withval;;
- esac],
- [ensc_cv_path_kerneldir=
- for i in /lib/modules/$(uname -r)/build /usr/src/linux /usr; do
- test -e $i/include/linux/version.h && { ensc_cv_path_kerneldir=$i; break; }
- done])
- ])
-
- test "$ensc_cv_path_kerneldir" -a -e "$ensc_cv_path_kerneldir"/include/linux/version.h || {
- AC_MSG_ERROR([Can not find kernelsources])
- }
-])
-
-AC_DEFUN([ENSC_KERNEL_HEADERS],
-[
- AC_REQUIRE([_ENSC_KERNEL_DIR])
-
- AC_CACHE_CHECK([for linux kernel headers], [ensc_cv_path_kernelheaders],
- [
- ensc_cv_path_kernelheaders=$ensc_cv_path_kerneldir/include
- ])
-
- if test x"$1" != x; then
- $1=$ensc_cv_path_kernelheaders
- AC_SUBST($1)
- fi
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-dnl Usage: ENSC_SET_SEARCHPATH(<PATH>)
-AC_DEFUN([ENSC_SET_SEARCHPATH],
-[
- ensc_searchpath="$1"
-])
-
-dnl Usage: ENSC_PATHPROG_INIT
-AC_DEFUN([ENSC_PATHPROG_INIT],
-[
- ENSC_PATHPROG_SED=
- AC_SUBST([ENSC_PATHPROG_SED])
-])
-
-
-dnl Usage: ENSC_PATHPROG(<VAR>, <PROG>[, <DFLT>, <DESCR>])
-AC_DEFUN([ENSC_PATHPROG],
-[
- AC_REQUIRE([ENSC_SET_SEARCHPATH])
- AC_REQUIRE([ENSC_PATHPROG_INIT])
-
- if test -z "$3"; then
- rq=true
- else
- rq=false
- fi
-
- if $rq; then
- ensc_dflt=
- else
- ensc_dflt="$3"
- fi
-
- AC_PATH_PROGS($1, [$2], [$ensc_dflt], [$ensc_searchpath])
-
- if test -z "${$1}" && $rq; then
- if test -z "$4"; then
- AC_MSG_ERROR([Can not find the '$2' tool within '${ensc_searchpath:-$PATH}'.])
- else
- AC_MSG_ERROR([
-Can not find the '$2' tool within '${ensc_searchpath:-$PATH}'.
-$4])
- fi
- fi
-
- test "${$1}" && ENSC_PATHPROG_SED="${ENSC_PATHPROG_SED}s!@'$1'@!${$1}!g;"
-
- test "${$1}"])
-
-
-
-dnl Usage: ENSC_PATHPROG_STANDARD_TOOLS)
-AC_DEFUN([ENSC_PATHPROG_STANDARD_TOOLS],
-[
- ENSC_PATHPROG(AWK, awk)
- ENSC_PATHPROG(CAT, cat)
- ENSC_PATHPROG(CHOWN, chown)
- ENSC_PATHPROG(CMP, cmp)
- ENSC_PATHPROG(CP, cp)
- ENSC_PATHPROG(DIRNAME, dirname)
- ENSC_PATHPROG(EGREP, egrep)
- ENSC_PATHPROG(ENV, env)
- ENSC_PATHPROG(GREP, grep)
- ENSC_PATHPROG(LN, ln)
- ENSC_PATHPROG(MKDIR, mkdir)
- ENSC_PATHPROG(MKFIFO, mkfifo)
- ENSC_PATHPROG(MKTEMP, mktemp)
- ENSC_PATHPROG(MOUNT, mount)
- ENSC_PATHPROG(MV, mv)
- ENSC_PATHPROG(NICE, nice)
- ENSC_PATHPROG(PS, ps)
- ENSC_PATHPROG(RM, rm)
- ENSC_PATHPROG(RMDIR, rmdir)
- ENSC_PATHPROG(SED, sed)
- ENSC_PATHPROG(SH, sh)
- ENSC_PATHPROG(TAC, tac)
- ENSC_PATHPROG(TAR, tar)
- ENSC_PATHPROG(TOUCH, touch)
- ENSC_PATHPROG(TTY, tty)
- ENSC_PATHPROG(UMOUNT, umount)
- ENSC_PATHPROG(WC, wc)
-])
-
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-dnl Usage: ENSC_RELEASE(<cppflag-variable>)
-dnl <cppflag-variable> ... name of variable which will get the preprocessor
-dnl flags and which will be AC_SUBST'ed
-
-AC_DEFUN([ENSC_RELEASE],
-[
- AC_MSG_CHECKING([whether to enable release-mode])
- AC_ARG_ENABLE([release],
- [AC_HELP_STRING([--enable-release],
- [enable release mode (default: no)])],
- [case "$enableval" in
- yes) ensc_release_mode=yes;;
- no) ensc_release_mode=no;;
- *) AC_MSG_ERROR(['$enableval' is not a valid value for '--enable-release']);;
- esac],
- [ ensc_release_mode=no ])
-
- if test x"$ensc_release_mode" = xno; then
- $1=
- else
- $1='-DNDEBUG'
- fi
-
- AC_SUBST($1)
- AC_MSG_RESULT($ensc_release_mode)
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-dnl Usage: ENSC_SYSCALL
-
-AC_DEFUN([ENSC_SYSCALL],
-[
- AC_REQUIRE([ENSC_KERNEL_HEADERS])
- AC_MSG_CHECKING([for syscall(2) invocation method])
- AC_ARG_WITH([syscall],
- [AC_HELP_STRING([--with-syscall=METHOD],
- [call syscall(2) with the specified METHOD; valid values are 'fast', 'traditional' and 'auto' (default: auto)])],
- [],
- [with_syscall=auto])
- AC_MSG_RESULT([$with_syscall])
-
- case x"$with_syscall" in
- xauto)
- AC_CACHE_CHECK([which syscall(2) invocation works], [ensc_cv_test_syscall],
- [
- AC_LANG_PUSH(C)
- AC_COMPILE_IFELSE([
-#include <asm/unistd.h>
-#include <syscall.h>
-#include <errno.h>
-#define __NR_foo0 300
-#define __NR_foo1 301
-#define __NR_foo2 302
-#define __NR_foo3 303
-#define __NR_foo4 304
-#define __NR_foo5 305
-inline static _syscall0(int, foo0)
-inline static _syscall1(int, foo1, int, a)
-inline static _syscall2(int, foo2, int, a, int, b)
-inline static _syscall3(int, foo3, int, a, int, b, int, c)
-inline static _syscall4(int, foo4, int, a, int, b, int, c, int, d)
-inline static _syscall5(int, foo5, int, a, int, b, int, c, int, d, int, e)
-
-int main() {
- return foo0() || \
- foo1(1) || \
- foo2(1,2) || \
- foo3(1,2,3) || \
- foo4(1,2,3,4) || \
- foo5(1,2,3,4,5);
-}
- ],
- [ensc_cv_test_syscall=fast],
- [ensc_cv_test_syscall=traditional])
-
- AC_LANG_POP
- ])
- with_syscall=$ensc_cv_test_syscall
- ;;
- xfast|xtraditional)
- ;;
- *)
- AC_MSG_ERROR(['$with_syscall' is not a valid value for '--with-syscall'])
- ;;
- esac
-
- if test x"$with_syscall" = xtraditional; then
- AC_DEFINE(ENSC_SYSCALL_TRADITIONAL, 1, [Define to 1 when the fast syscall(2) invocation does not work])
- fi
-
- AH_BOTTOM([
-#if defined(__pic__) && defined(__i386) && !defined(ENSC_SYSCALL_TRADITIONAL)
-# define ENSC_SYSCALL_TRADITIONAL 1
-#endif])
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-dnl Usage: ENSC_SYSCALLNR(<syscall>,<default>)
-
-AC_DEFUN([ENSC_SYSCALLNR],
-[
- AC_REQUIRE([AC_PROG_CPP])
- AC_REQUIRE([AC_PROG_EGREP])
- AC_REQUIRE([ENSC_KERNEL_HEADERS])
-
- AC_CACHE_CHECK([for number of syscall '$1'], [ensc_cv_value_syscall_$1],
- [
- AC_LANG_PUSH(C)
- AC_LANG_CONFTEST([
-#include <asm/unistd.h>
-#ifdef __NR_$1
-ensc_syscall_tmp_nr=__NR_$1;
-ensc_syscall_tmp_src=ENSC_MARK
-#endif
-])
- ensc_syscall_tmp_nr=
- ensc_syscall_tmp_src=
- test "$ensc_syscall_tmp_nr" || \
- eval $($CPP $CPPFLAGS -D ENSC_MARK='glibc' conftest.c | $EGREP '^ensc_syscall_tmp_(nr=[[1-9]][[0-9]]*;|src=.*)$')
- test "$ensc_syscall_tmp_nr" || \
- eval $($CPP $CPPFLAGS -D ENSC_MARK='kernel' -I $ensc_cv_path_kernelheaders conftest.c | $EGREP '^ensc_syscall_tmp_(nr=[[1-9]][[0-9]]*;|src=.*)$')
- test "$ensc_syscall_tmp_nr" || {
- ensc_syscall_tmp_nr=$2
- ensc_syscall_tmp_src=default
- }
-
- if test x"$ensc_syscall_tmp_nr" = x; then
- AC_MSG_ERROR(
-[Can not determine value of __NR_$1; please verify your glibc/kernelheaders, and/or set CPPFLAGS='-D__NR_$1=<value>' environment when calling configure.])
- fi
- AC_LANG_POP
-
- ensc_cv_value_syscall_$1="$ensc_syscall_tmp_nr/$ensc_syscall_tmp_src"
- ])
-
- ensc_syscall_tmp_nr=${ensc_cv_value_syscall_$1%/*}
- ensc_syscall_tmp_src=${ensc_cv_value_syscall_$1#*/}
-
- if test x"$ensc_syscall_tmp_src" != x'glibc'; then
- AC_DEFINE_UNQUOTED(ENSC_SYSCALL__NR_$1, $ensc_syscall_tmp_nr, [The number of the $1 syscall])
- fi
-])
+++ /dev/null
-dnl $Id$
-
-dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; version 2 of the License.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-dnl Usage: ENSC_UV_VROOTDIR[(<vserverdir-variable>)]
-dnl <vserverdir-variable> ... name of variable which will get assigned
-dnl the dirname of the vserver-topdir
-
-AC_DEFUN([ENSC_UV_VROOTDIR],
-[
- AC_MSG_CHECKING([which vserver-rootdir is to use])
- AC_ARG_WITH([vrootdir],
- [AC_HELP_STRING([--with-vrootdir=DIR],
- [place vservers under DIR (default: /vservers)])],
- [case "$withval" in
- yes|no) AC_MSG_ERROR(['$withval' is not a valid value for vrootdir]);;
- *) ensc_uv_path_vrootdir=$withval;;
- esac],
- [ensc_uv_path_vrootdir=/vservers])
- AC_MSG_RESULT([$ensc_uv_path_vrootdir])
-
- if test x"$1" != x; then
- $1=$ensc_uv_path_vrootdir
- AC_SUBST($1)
- fi
-])
+++ /dev/null
-## $Id$
-
-## Copyright (C) 2002 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.
-
-gpgsig:
- gpgkey=$(GPG_KEY); \
- gpg $${gpgkey:+--default-key "$$gpgkey"} --armor --detach-sign $(distdir).tar.bz2
+++ /dev/null
-## $Id$ ---*- makefile -*---
-
-## Copyright (C) 2002 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.
-##
-
-BAD_INC_PATHS = /usr/include|/usr/local/include
-BAD_LIB_PATHS = /usr/lib
-
-pkgconfdir = $(libdir)/pkgconfig
-pkgconf_DATA = $(addsuffix .pc, $(PKGCONFIG_FILES))
-
-CLEANFILES += $(addsuffix .pc, $(PKGCONFIG_FILES))
-EXTRA_DIST += $(addsuffix .pc.subst, $(PKGCONFIG_FILES))
-
-
-%.pc: %.pc.subst Makefile
- rm -f $@
- @case '$(libdir)' in \
- $(BAD_LIB_PATHS)) libflags=;; \
- *) libflags='-L$${libdir} ';; \
- esac; \
- case '$(pkgincludedir)' in \
- $(BAD_INC_PATHS)) pkgincflags=;; \
- *) pkgincflags='-I$${pkgincludedir} ';; \
- esac; \
- case '$(includedir)' in \
- $(BAD_INC_PATHS)) incflags=;; \
- *) incflags='-I$${includedir} ';; \
- esac; \
- sed -e 's!@'PACKAGE'@!$(PACKAGE)!g; \
- s!@'VERSION'@!$(VERSION)!g; \
- s!@'prefix'@!$(prefix)!g; \
- s!@'exec_prefix'@!$(exec_prefix)!g; \
- s!@'libdir'@!$(libdir)!g; \
- s!@'includedir'@!$(includedir)!g; \
- s!@'libflags"@!$${libflags}$(pkgconf_LIBFLAGS)!g;"' \
- s!@'incflags"@!$${incflags}$(pkgconf_INCFLAGS)!g;"' \
- s!@'pkgincflags"@!$${pkgincflags}$(pkgconf_PKGINCFLAGS)!g;"' \
- s!@'pkgincludedir'@!$(pkgincludedir)!g' \
- $< >$@
- test -z "$(CHMOD_REFERENCE)" || $(CHMOD_REFERENCE) '$<' '$@'
- chmod a-w $@
+++ /dev/null
-## $Id$ ---*- makefile -*---
-
-## Copyright (C) 2002 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.
-##
-
-$(BUILT_SOURCES) config.h: .X$(subst /,_,$(sysconfdir))-up-to-date
-
-distclean-local: distclean-uptodate
-
-distclean-uptodate:
- @rm -f .*-up-to-date
-
-.%-up-to-date:
- @rm -f .*-up-to-date
- @$(MAKE) -s clean
- @touch -t 197001020000 '$@'
- @$(MAKE) -s $(BUILT_SOURCES)
+++ /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; either version 2, or (at your option)
-## any later version.
-##
-## 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.
-##
-
-man_pages = man/chbind.8 \
- man/chcontext.8 \
- man/distrib-info.8 \
- man/rebootmgr.8 \
- man/reducecap.8 \
- man/vps.8 \
- man/vpstree.8 \
- man/vserver-copy.8 \
- man/vserver-stat.8 \
- man/vserver.8 \
- man/vtop.8
-
-man_MANS += $(man_pages)
-EXTRA_DIST += $(man_pages)
+++ /dev/null
-.TH "chbind" "8" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-chbind \- The chbind utility is used to lock a process and its children into using a specific IP number/Interface.
-.SH "SYNTAX"
-.LP
-chbind [\fI\-\-silent\fP] [\fI\-\-ip ip_number/interface\fP] <\fIcommand arguments\fP>
-.SH "DESCRIPTION"
-.LP
-The chbind utility executes a command, and locks the resulting process and its children into using a specific IP number/Interface, no matter what it is told in it's configuration. This applies to services and client connection as well.
-.SH "OPTIONS"
-.LP
-.TP
-\fB\-\-ip\fR ip_number/interface
-Binds the process to the given IP number or Interface. If an interface
-is supplied (for example eth0), both the IP number and broadcast address
-are extracted.
-.TP
-\fB\-\-bcast\fR broadcast address
-Binds the process to the given broadcast IP number.
-.TP
-\fB\-\-silent\fR
-Do not complain.
-
-.SH "FILES"
-.LP
-\fI/usr/sbin/chbind\fP
-
-
-.SH "EXAMPLES"
-.LP
-If I wanted to ensure my httpd listened only on my eth0 interface, I could do:
-chbind \-\-ip eth0 /etc/rc.d/init.d/httpd start
-.LP
-Please contribute some, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chcontext(8) rebootmgr(8) reducecap(8)
-vps(8) vpstree(8) vrpm(8) vserver(8)
-vserver\-stat(8) vtop(8)
+++ /dev/null
-.TH "chcontext" "1" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-chcontext \- chcontext allocates a new security context and executes a command in that context.
-.SH "SYNTAX"
-.LP
-chcontext [\fIoptions\fP] <\fIcommand arguments\fP>
-.SH "DESCRIPTION"
-.LP
-chcontext allocates a new security context and executes a command in that context.
-By default, a new/unused context is allocated
-.SH "OPTIONS"
-.LP
-.TP
-\fB\-\-cap\fR CAP_NAME
-Add a capability from the command. This option may be repeated several time. See /usr/include/linux/capability.h In general, this option is used with the \-\-secure option. \-\-secure removes most critical capabilities and \-\-cap adds specific ones.
-.TP
-\fB\-\-cap\fR !CAP_NAME
-Remove a capability from the command. This option may be repeated several time. See /usr/include/linux/capability.h
-.TP
-\fB\-\-ctx\fR num
-Select the context. Only root in context 0 is allowed to select a specific context.
-Context number 1 is special. It can see all processes in any contexts, but can't kill them though.
-.TP
-\fB\-\-disconnect\fR
-Start the command in background and make the process a child of process 1.
-.TP
-\fB\-\-domainname\fR new_domainname
-Set the domainname (NIS) in the new security context.
-Use "none" to unset the domainname.
-.TP
-\fB\-\-flag\fR
-Set one flag in the new or current security context. The following flags are supported. The option may be used several time.
- lock: The new process is trapped and can't use
- chcontext anymore.
- sched: The new process and its children will
- share a common execution priority.
- nproc: Limit the number of process in the
- vserver according to ulimit setting.
- Normally, ulimit is a per user thing.
- With this flag, it becomes a per vserver
- thing.
- private: No one can join this security context
- once created.
-.TP
-\fB\-\-hostname\fR new_hostname
-Set the hostname in the new security context.
-This is needed because if you create a less privileged security context, it may be unable to change its hostname.
-.TP
-\fB\-\-secure\fR
-Remove all the capabilities to make a virtual server trustable.
-.TP
-\fB\-\-silent\fR
-Do not print the allocated context number.
-.LP
-Information about context is found in /proc/self/status
-.SH "FILES"
-.LP
-\fI/usr/sbin/chcontext\fP
-
-
-.SH "EXAMPLES"
-.LP
-# You must be root, running X.
-# We start an xterm in another security context
-/usr/sbin/chcontext xterm &
-
-# We check, there is no xterm running, yet we can
-# see it.
-ps ax | grep xterm
-
-# Are we running in security context 0
-# We check the s_context line in /proc/self/status
-cat /proc/self/status
-
-# Ok we in security context 0
-# Try the security context 1
-/usr/sbin/chcontext \-\-ctx 1 ps ax | grep xterm
-
-# Ok, we see the xterm, we try to kill it
-/usr/sbin/chcontext \-\-ctx 1 killall xterm
-
-# No, security context 1 can see, but can't kill
-# let's find out in which security context this
-# xterm is running
-/usr/sbin/chcontext \-\-ctx 1 ps ax | grep xterm
-
-# Ok, this is PID XX. We need the security context
-/usr/sbin/chcontext \-\-ctx 1 cat /proc/XX/status
-
-# We see the s_context, this is SS.
-# We want to kill this process
-/usr/sbin/chcontext \-\-ctx SS killall xterm
-.LP
-Please contribute some, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chbind(8) rebootmgr(8) reducecap(8)
-vps(8) vpstree(8) vrpm(8) vserver(8)
-vserver\-stat(8) vtop(8)
+++ /dev/null
-.TH "distrib-info" "8" "0.1.0" "Jacques Gelinas <jack@solucorp.qc.ca>" "System Administration"
-.SH "NAME"
-.LP
-distrib-info \- A distribution independant utility to retrieve package information.
-.SH "SYNTAX"
-.LP
-distrib-info vserver-name command [options]
-
-.SH "DESCRIPTION"
-.LP
-distrib-info \- This utility provides a solution to hide some differences
-between Linux distributions. The various utilities (vunify, vbuild, ...)
-need package information to perform their task. They call distrib-info
-to retrieve this information. distrib-info is the only one understanding
-the various distribution out there.
-.TP
-This utility is only used as a back-end for other utilities such as
-vunify and vbuild.
-.SH "OPTIONS"
-.LP
-.TP
-\fBdumpfiles\fR reports all files owned by a package.
-.TP
-\fBpkgversion\fR reports all packages and version.
-.TP
-\fBunifiles\fR reports the files of a package which may be shared by
-several virtual servers. Generally, this excludes all configuration files.
-
-.SH "EXAMPLES"
-.LP
-The following command will report all packages in the vserver ref80.
-The package will be presented with the version/release.
-
- distrib-info ref80 pkgversion
-
-To get the list of unify-able (sharable) file in package sendmail
-of the vserver ref80, we do
-
- distrib-info ref80 unifiles sendmail
-.SH "FILES"
-.LP
- /usr/lib/vservers/distrib-info
-.SH "AUTHORS"
-.LP
-This Man page was written by Jacques Gelinas <jack@solucorp.qc.ca>.
-.SH "SEE ALSO"
-.LP
-vbuild(8) vfiles(8) vunify(8)
-newvserver(8)
-
+++ /dev/null
-.TH "rebootmgr" "8" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-rebootmgr \- rebootmgr stops and starts one or more vservers at your command.
-.SH "SYNTAX"
-.LP
-rebootmgr \fIvserver\-name\fP [\fIvserver\-name\fP ...] \fICommand\fP
-.SH "DESCRIPTION"
-.LP
-The chbind utility executes a command, and locks the resulting process and its children into using a specific IP number/Interface, no matter what it is told in it's configuration. This applies to services and client connection as well.
-.SH "OPTIONS"
-.LP
-.TP
-\fB\-\-ip\fR ip_number/interface
-Binds the process to the given IP number or Interface.
-.TP
-\fB\-\-silent\fR
-Do not complain.
-
-.SH "FILES"
-.LP
-\fI/usr/sbin/rebootmgr\fP
-
-
-.SH "EXAMPLES"
-.LP
-If I wanted to ensure my httpd listened only on my eth0 interface, I could do:
-chbind \-\-ip eth0 /etc/rc.d/init.d/httpd start
-.LP
-Please contribute some, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chcontext(8) chbind(8) reducecap(8)
-vps(8) vpstree(8) vrpm(8) vserver(8)
-vserver\-stat(8) vtop(8)
+++ /dev/null
-.TH "reducecap" "8" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-reducecap \- The reducecap utility is used to lower the capability ceiling of a process and child process.
-.SH "SYNTAX"
-.LP
-reducecap [\fIoptions\fP] <\fIcommand arguments\fP>
-.SH "DESCRIPTION"
-.LP
-The reducecap utility is used to lower the capability ceiling of a process and child process. Even setuid program won't be able to grab more capabilities.
-.SH "OPTIONS"
-.LP
-.TP
-\fB\-\-secure\fR Removes all dangerous capabilities from the process executed.Specificly it removes:
-CAP_LINUX_IMMUTABLE CAP_NET_BROADCAST CAP_NET_ADMIN, CAP_NET_RAW CAP_IPC_LOCK CAP_IPC_OWNER CAP_SYS_MODULE CAP_SYS_RAWIO CAP_SYS_PACCT CAP_SYS_ADMIN CAP_SYS_BOOT CAP_SYS_NICE CAP_SYS_RESOURCE CAP_SYS_TIME CAP_MKNOD.
-
-Leaving the following capabilities:
-CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_FSETID CAP_KILL CAP_SETGID CAP_SETUID CAP_NET_BIND_SERVICE CAP_SYS_CHROOT CAP_SYS_PTRACE CAP_SYS_TTY_CONFIG CAP_LEASE CAP_QUOTACTL
-.TP
-\fB\-\-show\fR Shows the current process capabilities.
-.TP
-\fB\-\-flag\fR
-sets the security context flags. The option may be repeated
-several times. Here are the values:
-
-lock: The security context can't be changed. The process is trapped
- in this context. This is generally used for vservers because yoy
- do not want them to hide in new security context.
-
-sched: Each process in a security context contribute (lower) to the general
- priority of every processes in the context. Mostly, all processes
- in a security context take as much CPU together as one process
- not bound to this flag. Said again differently, a vserver having
- 100 active processes won't get more CPU than another vserver
- with a single active process.
-
-
-nproc: The "ulimit -u N" setting becomes global to the security context. It means
- the security context is not allowed to have more than N processes.
-
-private: No other processes, even root in security context 0, is allowed to
- enter this security context. Once a security context is setup
- with this flag, it is on its own. This also means that root
- in security context 0 won't be able to kill or interact with those
- processes.
-
-hideinfo: Hides various information in /proc.
-
-.TP
-\fB--LINUX_IMMUTABLE\fR
-.TP
-\fB--NET_BIND_SERVICE\fR
-.TP
-\fB--NET_BROADCAST\fR
-.TP
-\fB--NET_ADMIN\fR
-.TP
-\fB--NET_RAW\fR
-.TP
-\fB--IPC_LOCK\fR
-.TP
-\fB--IPC_OWNER\fR
-.TP
-\fB--SYS_MODULE\fR
-.TP
-\fB--SYS_RAWIO\fR
-.TP
-\fB--SYS_PACCT\fR
-.TP
-\fB--SYS_ADMIN\fR
-.TP
-\fB--SYS_BOOT\fR
-.TP
-\fB--SYS_NICE\fR
-.TP
-\fB--SYS_RESOURCE\fR
-.TP
-\fB--SYS_TIME\fR
-.TP
-\fB--MKNOD\fR
-
-All these options remove one capability. These options may be used
-after the
-\fB--secure\fR
-option to remove more capabilities.
-
-
-.SH "FILES"
-.LP
-\fI/usr/sbin/reducecap\fP
-
-
-.SH "EXAMPLES"
-.LP
-# You are not root now
-# What is the current capability ceiling
-cat /proc/self/status
-# The capBset line presents mostly 1s.
-/usr/sbin/reducecap \-\-secure /bin/sh
-cat /proc/self/status
-# The capBset now shows many more 0s.
-# The capEff shows all 0s, you have no privilege now
-# We su to root
-su
-cat /proc/self/status
-# capEff is much better now, but there are still many 0s
-# Now we try to see if we are really root
-tail /var/log/messages
-# So far so good, we see the content
-/sbin/ifconfig eth0
-/sbin/ifconfig eth0 down
-# No way, we can't configure the interface. In fact
-# we have lost most privilege normally assigned to root
-exit
-.LP
-Please contribute some more, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chcontext(8) rebootmgr(8) chbind(8)
-vps(8) vpstree(8) vrpm(8) vserver(8)
-vserver\-stat(8) vtop(8)
+++ /dev/null
-.TH "vps" "8" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-vps \- The vps utility is simply a wrapper for the ps program.
-.SH "SYNTAX"
-.LP
-vps [\fIoptions\fP]
-
-.SH "DESCRIPTION"
-.LP
-vps \- The vps utility is simply a wrapper for the ps program, that enables ps to show you the all the processes on the system, instead of only the ones in the current s_context (see cat /proc/self/status).
-.SH "OPTIONS"
-.LP
-.TP
-See man ps.
-.SH "FILES"
-.LP
-\fI/usr/sbin/vps\fP
-
-
-.SH "EXAMPLES"
-.LP
-Please contribute some, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chcontext(8) rebootmgr(8) reducecap(8)
-chbind(8) vpstree(8) vrpm(8) vserver(8)
-vserver\-stat(8) vtop(8)
+++ /dev/null
-.TH "vpstree" "8" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-vpstree \- The vpstree utility is simply a wrapper for the pstree program.
-.SH "SYNTAX"
-.LP
-vpstree [\fIoptions\fP]
-
-.SH "DESCRIPTION"
-.LP
-vpstree \- The vpstree utility is simply a wrapper for the pstree program, that enables pstree to show you the all the processes on the system, instead of only the ones in the current s_context (see cat /proc/self/status).
-.SH "OPTIONS"
-.LP
-.TP
-See man pstree.
-.SH "FILES"
-.LP
-\fI/usr/sbin/vpstree\fP
-
-
-.SH "EXAMPLES"
-.LP
-Please contribute some, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chcontext(8) rebootmgr(8) reducecap(8)
-chbind(8) vps(8) vrpm(8) vserver(8)
-vserver\-stat(8) vtop(8)
+++ /dev/null
-.TH "vrpm" "8" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-vrpm \- is simply a wrapper for the rpm utility.
-.SH "SYNTAX"
-.LP
-vrpm [--unify] [ALL | vserver1 vserver2 ...] \-\- [rpm options]
-
-.SH "DESCRIPTION"
-.LP
-vrpm \- is simply a wrapper for the rpm utility. It enables rpm to manage a specific, several or all virtual server(s) with one command.
-vrpm is executed in the root server.
-.SH "OPTIONS"
-.LP
-.TP
-\fB\-\-\fR All commands after this, is given to the rpm utility (see man rpm).
-.TP
-The
-\fB--unify\fR option triggers the vunify utility on the vservers and the
-supplied packages.
-.SH "FILES"
-.LP
-\fI/usr/sbin/vrpm\fP
-
-
-.SH "EXAMPLES"
-.TP
-verifies the gcc package on all vservers.
-.LP
-vrpm ALL \-\- \-\-verify gcc
-.TP
-Updates package.rpm on vserver1 and vserver2 if
-the package exists in a earlier version
-(the F flag for rpm).
-.LP
-vrpm vserver1 vserver2 \-\- \-Fvh package.rpm
-.TP
-vrpm is executed in the root server
-.LP
-Please contribute some more, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chcontext(8) rebootmgr(8) reducecap(8)
-chbind(8) vps(8) vtop(8) vserver(8)
-vserver\-stat(8) vpstree(8)
+++ /dev/null
-.TH "vserver-copy" "8" "0.3" "Mark Lawrence <nomad@null.net>" "System Administration"
-.SH "NAME"
-.LP
-vserver-copy \- copy/move a virtual server.
-.SH "SYNTAX"
-.LP
-vserver-copy [\fIoptions\fP] \fIvserver\fP \fInewname\fP
-.LP
-vserver-copy [\fIoptions\fP] \fIvserver\fP \fIhost\fP:[\fInewname\fP]
-.SH "DESCRIPTION"
-.LP
-vserver-copy makes a copy of a virtual server using rsync. It will
-rewrite the vserver.conf configuration file with the new hostname and
-IP information when given. If the destination name contains a host
-specification then ssh/rsh will be used for the data transfer.
-
-vserver-copy can used on a running vserver, although naturally the
-consistency of open database files and the like cannot be guaranteed.
-A running vserver can however be safely moved from one root host to another
-using the \-s flag.
-
-If downtime is an issue when moving a virtual server across hosts you
-should first run vserver without the \-s flag. This will pre\-populate the
-destination filesystem requiring only updates to be made on the next
-invocation.
-.SH "OPTIONS"
-.LP
-.TP
-\fB\-h\fR,\fB-\-help\fR
-output usage information and exit
-.TP
-\fB\-V\fR,\fB-\-version\fR
-output version information and exit
-.TP
-\fB\-v\fR,\fB-\-verbose\fR
-show all output (normally only informational messages and warnings)
-.TP
-\fB\-q\fR,\fB-\-quiet\fR
-suppress all output
-.TP
-\fB\-d\fR,\fB-\-domain\fR domain
-the new DNS domain when changing name. Overwrites /etc/hosts. Must be
-used with \-i
-.TP
-\fB\-i\fR,\fB-\-ip\fR address
-the new IP address when changing name. Overwrites /etc/hosts. Must be
-used with \-d
-.TP
-\fB\-r\fR,\fB-\-vsroot\fR
-directory containing virtual servers. Defaults to "/vserver"
-.TP
-\fB\-R\fR,\fB-\-rsh\fR
-use rsh instead of the default ssh for network transfer
-.TP
-\fB\-s\fR,\fB-\-stopstart\fR
-stop the virtual server before copying and start the new vserver afterwards.
-This really only makes sense if you are copying across root hosts and not
-changing names or IP addresses.
-.SH "FILES"
-.LP
-\fI/etc/vservers/vserver.conf\fP
-.SH "EXAMPLES"
-.LP
-# Copy a template vserver (same IP addresses etc)
-
-/usr/sbin/vserver-copy template web01
-
-# Copy webserver with change in configuration
-
-/usr/sbin/vserver-copy -i 192.168.5.62 -d example.com template web62
-
-# Move a running vserver to another roothost
-
-/usr/sbin/vserver-copy -s web62 roothost02:
-
-.SH "BUGS"
-.LP
-If a virtual server is moved from one root host to another a gratuitious
-ping should be sent to inform other devices on the local area network
-of the change in MAC address.
-
-Without this ping the devices will continue to attempt to reach the old
-MAC address for the length of their arp-cache timeout (10 minute default
-on Suns!).
-
-This functionality should probably be implmemented during the
-"vserver <name> start" process.
-.SH "AUTHOR"
-.LP
-Mark Lawrence <nomad@null.net>
-.SH "SEE ALSO"
-.LP
-vserver(8)
+++ /dev/null
-.TH "vserver-stat" "8" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-vserver\-stat
-.SH "SYNTAX"
-.LP
-vserver\-stat
-
-.SH "DESCRIPTION"
-.LP
-vserver\-stat \- The vserver\-stat utility shows informations about all the active contexts.
-
- CTX# Context number
- #0 = root context
- #1 = monitoring context
- PROC QTY Quantity of processes in each
- context
- VSZ Number of pages of virtual
- memory
- RSS Resident set size
- utime User\-mode CPU time
- accumulated
- ctime Kernel\-mode CPU time
- accumulated
-.SH "FILES"
-.LP
-\fI/usr/sbin/vserver\-stat\fP
-
-
-.SH "EXAMPLES"
-.LP
-Please contribute some, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chcontext(8) rebootmgr(8) reducecap(8)
-chbind(8) vps(8) vrpm(8) vserver(8)
-vtop(8) vpstree(8)
+++ /dev/null
-.TH "vserver" "8" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-vserver \- The vserver utility enables you to control different aspects of your vservers.
-.SH "SYNTAX"
-.LP
-vserver [ options ] [vserver name] [options]
-
-.SH "DESCRIPTION"
-.LP
-vserver \- The vserver utility enables you to control different aspects of your vservers, such as stopping and starting them, and services within them.
-.SH "OPTIONS"
-.LP
-.TP
-\fBbuild\fR Create a virtual server by copying the packages of the root server
-.TP
-\fBenter\fR Enter in the virtual server context and starts a shell. Same as "vserver name exec /bin/sh\".
-.TP
-\fBexec\fR Exec a command in the virtual server context as root.
-syntax: vserver name exec command ...
-.TP
-\fBsuexec\fR Exec a command in the virtual server context under some user id.
-syntax: vserver name suexec userid command ...
-.TP
-\fBservice\fR Control a service inside a vserver.
-syntax: vserver name service service\-name (start/stop/restart etc.)
-.TP
-\fBstart\fR Starts the various services in the vserver.
-It uses the default runlevel found in the
-.B /etc/inittab
-file of the vserver.
-.TP
-\fBstop\fR Ends all services and kills the remaining processes.
-.TP
-\fBrunning\fR Tells if a virtual server is running. It returns proper exit code, so you can use it as a test.
-.TP
-\fBstatus\fR Tells various information about the state of a virtual server:
-running status, number of running processes and uptime.
-.TP
-.I --nodev
-do not configure the IP devices associated with the vserver. This
-is useful to execute some commands on the vserver (or enter it)
-without making it active on the network. Especially useful if you
-have an active copy of the vserver moved to another server on the
-network.
-.TP
-.I --silent
-cuts most informative messages.
-
-.SH "FILES"
-.LP
-\fI/usr/sbin/vserver\fP
-.P
-\fI/etc/vservers/*.conf\fP
-.P
-\fI/etc/vservers/*.sh\fP
-.P
-\fI/vservers/*\fP
-
-.SH "EXAMPLES"
-.LP
-Please contribute some, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chbind(8) chcontext(8)
-newvserver(8)
-rebootmgr(8) reducecap(8)
-vps(8) vpstree(8)
-vrpm(8)
-vserver\-stat(8)
-vtop(8)
+++ /dev/null
-.TH "vtop" "8" "0.1.0" "Klavs Klavsen <kl@vsen.dk>" "System Administration"
-.SH "NAME"
-.LP
-vtop \- The vtop utility is simply a wrapper for the top program.
-.SH "SYNTAX"
-.LP
-vtop [\fIoptions\fP]
-
-.SH "DESCRIPTION"
-.LP
-vtop \- The vtop utility is simply a wrapper for the top program, that enables top to show you the all the processes on the system, instead of only the ones in the current s_context (see cat /proc/self/status).
-.SH "OPTIONS"
-.LP
-.TP
-See man top.
-.SH "FILES"
-.LP
-\fI/usr/sbin/vtop\fP
-
-
-.SH "EXAMPLES"
-.LP
-Please contribute some, if you feel it's important.
-.SH "AUTHORS"
-.LP
-This Man page was written by Klavs Klavsen <kl@vsen.dk> and based upon the helpful output from the program itself and the documentation on the Virtual Server site <http://www.solucorp.qc.ca/miscprj/s_context.hc?prjstate=1&nodoc=0>
-.SH "SEE ALSO"
-.LP
-chcontext(8) rebootmgr(8) reducecap(8)
-chbind(8) vps(8) vrpm(8) vserver(8)
-vserver\-stat(8) vpstree(8)
+++ /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_PATHCONFIG_H
-#define H_UTIL_VSERVER_PATHCONFIG_H
-
-#define PKGLIBDIR "@PKGLIBDIR@"
-#define SBINDIR "@SBINDIR@"
-#define CONFDIR "@CONFDIR@"
-#define SYSCONFDIR "@SYSCONFDIR@"
-#define LOCKDIR "/var/lock"
-#define PKGLIBDEFAULTDIR PKGLIBDIR "/defaults"
-
-#define DEFAULT_VSERVERDIR "@VSERVERDIR@"
-#define DEFAULT_VSERVERPKGDIR "@VSERVERPKGDIR@"
-#define DEFAULT_PKGSTATEDIR "@PKGSTATEDIR@"
-#define DEFAULT_PKGSTATEREVDIR "@PKGSTATEREVDIR@"
-
-#define MOUNT_PROG "@MOUNT@"
-#define UMOUNT_PROG "@UMOUNT@"
-#define PS_PROG "@PS@"
-
-#define VPKG_PROG PKGLIBDIR "/vpkg"
-#define RESOLVER_PROG PKGLIBDIR "/rpm-fake-resolver"
-
-#define PROG_IP "@IP@"
-#define PROG_MODPROBE "@MODPROBE@"
-#define PROG_NAMEIF "@NAMEIF@"
-#define PROG_VCONFIG "@VCONFIG@"
-
-#define PROG_SECURE_MOUNT PKGLIBDIR "/secure-mount"
-
-#define PATH_VSERVER_START PKGLIBDIR "/vserver.start"
-#define PATH_FUNCTIONS PKGLIBDIR "/functions"
-#define PATH_UTILVSERVER_VARS PKGLIBDIR "/util-vserver-vars"
-
-#endif // H_UTIL_VSERVER_PATHCONFIG_H
+++ /dev/null
-.gdb_history
-.*.stamp
-util-vserver-vars
-vps
+++ /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; either version 2, or (at your option)
-## any later version.
-##
-## 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.
-##
-
-AM_INSTALLCHECK_STD_OPTIONS_EXEMPT += \
- scripts/vapt-get-worker \
- scripts/vrpm-worker \
- scripts/vyum-worker \
- scripts/vrpm-preload \
- scripts/save_s_context \
- scripts/vservers.grabinfo.sh \
- scripts/vpstree \
- scripts/vserver-copy \
- scripts/vserver-wrapper \
- scripts/vsysvwrapper \
- scripts/vtop \
- scripts/legacy/distrib-info \
- scripts/legacy/vps \
- scripts/legacy/save_s_context \
- scripts/legacy/vserver \
- scripts/legacy/rootshell \
- scripts/legacy/vserverkillall
-
-
-scripts_pkglib_src_DTA = scripts/functions \
- scripts/vserver-build.apt-rpm \
- scripts/vserver-build.skeleton \
- scripts/vserver-build.debootstrap \
- scripts/vserver-build.rpm \
- scripts/vserver-build.yum \
- scripts/vserver-build.functions \
- scripts/vserver-build.functions.apt \
- scripts/vserver-build.functions.rpm \
- scripts/vserver-build.functions.pkgmgmt \
- scripts/vserver-build.functions.yum \
- scripts/vserver-setup.functions \
- scripts/vserver.functions \
- scripts/vserver.start \
- scripts/vserver.stop \
- scripts/vserver.suexec
-
-scripts_pkglib_gen_DTA = scripts/util-vserver-vars
-
-scripts_pkglib_src_SCRPTS = scripts/pkgmgmt \
- scripts/vapt-get-worker \
- scripts/vpkg \
- scripts/vrpm-worker \
- scripts/vrpm-preload \
- scripts/start-vservers \
- scripts/vprocunhide \
- scripts/vserver-build \
- scripts/vserver-wrapper \
- scripts/vservers.grabinfo.sh \
- scripts/vshelper \
- scripts/vsysvwrapper \
- scripts/vyum-worker
-
-scripts_legacy_src_SCRPTS = scripts/legacy/save_s_context \
- scripts/legacy/vserver \
- scripts/legacy/rootshell \
- scripts/legacy/distrib-info \
- scripts/legacy/vserverkillall
-scripts_legacy_gen_SCRPTS = scripts/legacy/vps
-
-scripts_sbin_src_PRGS = scripts/chcontext \
- scripts/vapt-get \
- scripts/vpstree \
- scripts/vrpm \
- scripts/vserver \
- scripts/vserver-copy \
- scripts/vsomething \
- scripts/vtop \
- scripts/vyum
-
-scripts_sbin_gen_PRGS =
-scripts_sbincfg_gen_DTA =
-
-scripts_subst_SRCS = scripts/util-vserver-vars.pathsubst \
- scripts/legacy/vps.pathsubst
-
-
-
-sbin_SCRIPTS += $(scripts_sbin_src_PRGS) $(scripts_sbin_gen_PRGS)
-scripts_sbincfg_DTA = $(scripts_sbincfg_gen_DTA)
-pkglib_SCRIPTS += $(scripts_pkglib_src_SCRPTS)
-legacy_SCRIPTS += $(scripts_legacy_src_SCRPTS) $(scripts_legacy_gen_SCRPTS)
-pkglib_DATA += $(scripts_pkglib_src_DTA) $(scripts_pkglib_gen_DTA)
-
-CLEANFILES += $(scripts_pkglib_gen_DTA) \
- $(scripts_sbin_gen_PRGS) \
- $(scripts_sbincfg_gen_DTA) \
- $(scripts_legacy_gen_SCRPTS)
-
-EXTRA_DIST += $(scripts_pkglib_src_DTA) \
- $(scripts_pkglib_src_SCRPTS) \
- $(scripts_legacy_src_SCRPTS) \
- $(scripts_sbin_src_PRGS) \
- $(scripts_subst_SRCS)
-
-scripts/util-vserver-vars: scripts/.util-vserver-vars.pathsubst.stamp
-scripts/legacy/vps: scripts/legacy/.vps.pathsubst.stamp
+++ /dev/null
-## $Id$ --*- sh -*--
-
-case "$(hostname -s)" in
- ensc-pc) BASE=/mnt/nfs/src/util-vserver.devel;;
- delenn) BASE=/mnt/home/ensc/src/util-vserver.devel;;
- *) BASE=/home/ensc/src/util-vserver.devel;;
-esac
-
-PACKAGE='util-vserver'
-PACKAGE_BUGREPORT='enrico.scholz@informatik.tu-chemnitz.de'
-PACKAGE_NAME='util-vserver'
-PACKAGE_STRING='util-vserver 0.23.89.1'
-PACKAGE_TARNAME='util-vserver'
-PACKAGE_VERSION='0.23.89.1'
-
-__CONFDIR='/etc/vservers'
-__INCLUDEDIR='/usr/include'
-__INITRDDIR='/etc/init.d'
-__LEGACYDIR=$BASE/scripts/legacy
-__LIBDIR=/usr/lib
-__LOCKDIR=/var/lock
-__PKGLIBDEFAULTDIR=$BASE/distrib/misc
-__PKGSTATEDIR='/var/run/vservers'
-__PKGSTATEREVDIR='/var/run/vservers.rev'
-__SBINDIR=$BASE/src
-__SYSCONFDIR='/usr/local/etc'
-__VSHELPERSTATEDIR='/var/run/vshelper'
-
-__DISTRIBDIR=$BASE/distrib
-__PKGLIBDIR=$BASE/scripts
-__RUNDIR=$__PKGSTATEDIR
-
-__DEFAULT_VSERVERDIR='/vservers'
-__DEFAULT_VSERVERPKGDIR='/vservers/.pkg'
-
-_CAPCHROOT="$BASE/src/capchroot"
-_CHAINECHO="$BASE/src/chain-echo"
-_CHBIND="$BASE/src/chbind"
-_CHCONTEXT="$BASE/scripts/chcontext"
-_CHCONTEXT_COMPAT="$BASE/src/chcontext-compat"
-_CHROOT_CAT="$BASE/src/chroot-cat"
-_CHROOT_RM="$BASE/src/chroot-rm"
-_EXEC_CD="$BASE/src/exec-cd"
-_EXEC_ULIMIT="$BASE/src/exec-ulimit"
-_FAKE_RUNLEVEL="$BASE/src/fakerunlevel"
-_FILETIME="$BASE/src/filetime"
-_INITSYNC_MINIT_START=:
-_LIB_FUNCTIONS="$BASE/scripts/functions"
-_LIB_VSERVER_SETUP_FUNCTIONS="$BASE/scripts/vserver-setup.functions"
-_LIB_VSERVER_BUILD_FUNCTIONS="$BASE/scripts/vserver-build.functions"
-_LIB_VSERVER_BUILD_FUNCTIONS_APT="$BASE/scripts/vserver-build.functions.apt"
-_LIB_VSERVER_BUILD_FUNCTIONS_RPM="$BASE/scripts/vserver-build.functions.rpm"
-_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT="$BASE/scripts/vserver-build.functions.pkgmgmt"
-_LOCKFILE="$BASE/src/lockfile"
-_MASK2PREFIX="$BASE/src/mask2prefix"
-_PKGMGMT="$BASE/scripts/pkgmgmt"
-_READLINK="$BASE/src/readlink"
-_REBOOTMGR="$BASE/src/rebootmgr"
-_RPM_FAKE_SO="$BASE/src/.libs/rpm-fake.so"
-_SAVE_CTXINFO="$BASE/src/save_ctxinfo"
-_SAVE_S_CONTEXT="$BASE/scripts/legacy/save_s_context"
-_SECURE_MOUNT="$BASE/src/secure-mount"
-_SETATTR="$BASE/src/setattr"
-_VAPT_GET="$BASE/scripts/vapt-get"
-_VAPT_GET_WORKER="$BASE/scripts/vapt-get-worker"
-_VATTRIBUTE="$BASE/src/vattribute"
-_VCONTEXT="$BASE/src/vcontext"
-_VKILL="$BASE/src/vkill"
-_VLIMIT="$BASE/src/vlimit"
-_VNAMESPACE="$BASE/src/vnamespace"
-_VPKG="$BASE/scripts/vpkg"
-_VPROCUNHIDE="$BASE/scripts/vprocunhide"
-_VPS="$BASE/src/vps"
-_VRPM="$BASE/scripts/vrpm"
-_VRPM_PRELOAD="$BASE/scripts/vrpm-preload"
-_VRPM_WORKER="$BASE/scripts/vrpm-worker"
-_VSCHED="$BASE/src/vsched"
-_VSERVER="$BASE/scripts/vserver"
-_VSERVER_LEGACY="$BASE/scripts/legacy/vserver"
-_VSERVER_BUILD="$BASE/scripts/vserver-build"
-_VSERVER_INFO="$BASE/src/vserver-info"
-_VSHELPER="$BASE/scripts/vshelper"
-_VSHELPER_SYNC="$BASE/src/vshelper-sync"
-_VSOMETHING="$BASE/scripts/vsomething"
-_VUNAME="$BASE/src/vuname"
-_VUNIFY="$BASE/src/vunify"
-_VYUM="$BASE/scripts/vyum"
-_VYUM_WORKER="$BASE/scripts/vyum-worker"
-
-_AWK="/bin/awk"
-_CAT="/bin/cat"
-_CHOWN="/bin/chown"
-_CMP="/usr/bin/cmp"
-_CP="/bin/cp"
-_DIRNAME="/usr/bin/dirname"
-_EGREP="/bin/egrep"
-_ENV="/bin/env"
-_GREP="/bin/grep"
-_IP="/sbin/ip"
-_IPTABLES="/sbin/iptables"
-_LN="/bin/ln"
-_LN_S="$_LN -s"
-_MKDIR="/bin/mkdir"
-_MKFIFO="/usr/bin/mkfifo"
-_MKTEMP="/bin/mktemp"
-_MKTEMPDIR="$_MKTEMP -d"
-_MODPROBE="/sbin/modprobe"
-_MOUNT="/bin/mount"
-_MV="/bin/mv"
-_NAMEIF="/sbin/nameif"
-_NICE="/bin/nice"
-_RM="/bin/rm"
-_RMDIR="/bin/rmdir"
-_RMMOD="/sbin/rmmod"
-_SED="/bin/sed"
-_SH="/bin/sh"
-_TAC="/usr/bin/tac"
-_TAR="/bin/tar"
-_TOUCH="/bin/touch"
-_TTY="/usr/bin/tty"
-_UMOUNT="/bin/umount"
-_VCONFIG="/sbin/vconfig"
-_WC="/usr/bin/wc"
-_WGET="/usr/bin/wget"
-
-# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=106057
-WORKAROUND_106057=1
-# /var/lib/rpm is hardcoded into apt-get which does not honor the
-# %_dbpath variable therefore
-# http://distro2.conectiva.com.br/pipermail/apt-rpm/2003-October/001985.html
-WORKAROUND_APT_DBPATH=1
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# Copyright (C) 2004 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-function showHelp()
-{
- echo \
-$"Usage: /usr/sbin/chcontext [--cap [!]<cap_name>] [--secure] [--xid <num>] [--disconnect]
- [--domainname <name>] [--hostname <name>] [--flag <flags>+]
- [--silent] [--] command arguments ...
-
-chcontext allocate a new security context and executes
-a command in that context.
-By default, a new/unused context is allocated
-
---cap CAP_NAME
- Add a capability from the command. This option may be
- repeated several time.
- See /usr/include/linux/capability.h
- In general, this option is used with the --secure option
- --secure removes most critical capabilities and --cap
- adds specific ones.
-
---cap !CAP_NAME
- Remove a capability from the command. This option may be
- repeated several time.
- See /usr/include/linux/capability.h
-
---xid num
- Select the context. On root in context 0 is allowed to
- select a specific context.
- Context number 1 is special. It can see all processes
- in any contexts, but can't kill them though.
- Option --xid may be repeated several times to specify up to 16 contexts.
---disconnect
- Start the command in background and make the process
- a child of process 1.
---domainname new_domainname
- Set the domainname (NIS) in the new security context.
- Use "none" to unset the domain name.
---flag
- Set one flag in the new or current security context. The following
- flags are supported. The option may be used several time.
-
- fakeinit: The new process will believe it is process number 1.
- Useful to run a real /sbin/init in a vserver.
- lock: The new process is trapped and can't use chcontext anymore.
- sched: The new process and its children will share a common
- execution priority.
- nproc: Limit the number of process in the vserver according to
- ulimit setting. Normally, ulimit is a per user thing.
- With this flag, it becomes a per vserver thing.
- private: No one can join this security context once created.
- ulimit: Apply the current ulimit to the whole context
---hostname new_hostname
- Set the hostname in the new security context
- This is need because if you create a less privileged
- security context, it may be unable to change its hostname
---secure
- Remove all the capabilities to make a virtual server trustable
---silent
- Do not print the allocated context number.
-
-Report bugs to <$PACKAGE_BUGREPORT>."
- exit $1
-}
-
-function showVersion()
-{
- echo \
-$"chcontext $PACKAGE_VERSION -- allocates/enters a security context
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2004 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit $1
-}
-
-$_VSERVER_INFO - FEATURE migrate || exec $_CHCONTEXT_COMPAT "$@"
-
-tmp=$(getopt -o + --long cap:,ctx:,xid:,disconnect,domainname:,flag:,hostname:,secure,silent,help,version -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-OPT_CAPS=()
-OPT_CTX=
-OPT_DISCONNECT=
-OPT_FLAGS=()
-OPT_SECURE=
-OPT_SILENT=
-OPT_INITPID=
-
-while true; do
- case "$1" in
- --help) showHelp $0 ;;
- --version) showVersion ;;
- --cap) OPT_CAPS=( "${OPT_CAPS[@]}" "$2" ); shift;;
- --ctx|--xid) OPT_CTX=$2; shift;;
- --disconnect) OPT_DISCONNECT=1;;
- --domainname) OPT_DOMAINNAME=$2; shift;;
- --hostname) OPT_HOSTNAME=$2; shift;;
- --flag)
- test "$2" != "fakeinit" || OPT_INITPID=--initpid
- OPT_FLAGS=( "${OPT_FLAGS[@]}" "$2" )
- shift
- ;;
- --secure) OPT_SECURE=1;;
- --silent) OPT_SILENT=1;;
- --) shift; break;;
- *) echo $"chcontext: internal error; arg=='$1'" >&2; exit 1;;
- esac
- shift
-done
-
-create_cmd=( $_VCONTEXT --create --silentexist
- ${OPT_SILENT:+--silent}
- ${OPT_CTX:+--xid "$OPT_CTX"} )
-
-chain_cmd=()
-
-old_IFS=$IFS
-IFS=,$IFS
-
-test -z "$OPT_DOMAINNAME$OPT_HOSTNAME" || \
- chain_cmd=( "${chain_cmd[@]}"
- --
- $_VUNAME --set --xid self
- ${OPT_DOMAINNAME:+-t domainname="$OPT_DOMAINNAME"}
- ${OPT_HOSTNAME:+ -t nodename="$OPT_HOSTNAME"} )
-
-chain_cmd=( "${chain_cmd[@]}"
- --
- $_VATTRIBUTE --set
- ${OPT_CAPS:+--bcap "${OPT_CAPS[*]}"}
- ${OPT_FLAGS:+--flag "${OPT_FLAGS[*]}"}
- ${OPT_SECURE:+--secure} )
-
-migrate_cmd=( $_VCONTEXT
- ${OPT_SILENT:+--silent}
- ${OPT_DISCONNECT:+--disconnect}
- $OPT_INITPID )
-
-IFS=$old_IFS
-
-if $_VSERVER_INFO -q "$OPT_CTX" XIDTYPE static; then
- "${create_cmd[@]}" "${chain_cmd[@]}" -- \
- "${migrate_cmd[@]}" --endsetup --migrate-self -- "$@"
- rc=$?
-else
- rc=254
-fi
-
-test "$rc" -ne 254 || exec "${migrate_cmd[@]}" --xid "$OPT_CTX" --migrate -- "$@"
-exit $rc
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-_VS_LOGFILE=
-_VS_ERRFILE=
-
-_VS_NEWLINE='
-'
-declare -r _VS_NEWLINE=${_VS_NEWLINE:0-1}
-
-function findObject
-{
- local _fo_mod=$1
- local _fo_var=$2
- local _fo_file=
- local _fo_i=X
- shift 2
-
- for _fo_i; do
- test -n "$_fo_i" || continue
- test ! $_fo_mod "$_fo_i" || { _fo_file=$_fo_i; break; }
- done
-
- test -z "$_fo_i" -o -n "$_fo_file" || {
- echo "Can not find file for '$_fo_var'; aborting"
- exit 1
- } >&2
-
- eval "$_fo_var=\"$_fo_file\""
-}
-
-function findFile
-{
- findObject -f "$@"
-}
-
-function findDir
-{
- findObject -d "$@"
-}
-
-function findAndCopy
-{
- local dst=$1
- test ! -s "$dst" || return 0
-
- local tmp
- shift
- findFile tmp "$@"
-
- test -n "$tmp" -a -s "$tmp" || return 0
- $_CP -af "$tmp" "$dst"
-}
-
-function getPhysicalDir
-{
- ( set -P && cd "$1" && pwd )
-}
-
-## Usage: logging <message>
-function logging
-{
- if test -n "$_VS_LOGFILE"; then
- echo "$@" >>"$_VS_LOGFILE"
- else
- echo "$@"
- fi
-}
-
-## Usage: warning <message>
-function warning
-{
- if test -n "$_VS_ERRFILE"; then
- echo "$@" >>"$_VS_ERRFILE"
- else
- echo "$@" >&2
- fi
-}
-
-## Usage: panic <message>
-function panic
-{
- if test -n "$_VS_ERRFILE"; then
- echo "$@" >>"$_VS_ERRFILE"
- else
- echo "$@" >&2
- fi
-
- exit 1
-}
-
-## Usage: execute <message>
-function execute
-{
- test -z "${DEBUG_EXEC:-}" || echo "$@"
- test "${DEBUG_EXEC:-}" = noexec || exec "$@"
- exit 0
-}
-
-## Usage: isNumber <arg>
-function isNumber
-{
- local tmp
- let tmp=$1+0 2>/dev/null || test -z "${1//0/}" -a -n "$1" || return 1
- return 0
-}
-
-## Usage: colorize <style> <command>
-function colorize
-{
- local style=$1
- shift
-
- if ! $_TTY -s; then
- "$@"
- else
- local cfile
- findFile cfile "$__CONFDIR"/.defaults/styles/"$style" ''
- if test -n "$cfile"; then
- $_CAT "$cfile"
- else
- case "$style" in
- (bold) echo -ne "\e[1m";;
- (emph) echo -ne "\e[34m";;
- (info) echo -ne "\e[0;34m";;
- (warn*) echo -ne "\e[1;31m";;
- (error) echo -ne "\e[1;33;41m";;
- (*) ;;
- esac
- fi
-
- "$@"
- echo -ne "\e[m"
- fi
-}
-
-## Usage: xtermTitle <title>
-function xtermTitle
-{
- $_TTY -s || return 0
- echo -ne "\e]0;$@\007"
-}
-
-_VS_LOCKS=''
-## Usage: lock <lockfile> [<timeout>]
-function lock
-{
- local tmp=$($_MKTEMP /tmp/vserver-lock.XXXXXX)
- $_RM -f $tmp
- $_MKFIFO -m600 $tmp
-
- $_LOCKFILE "$1" $tmp $2 &
- $_GREP -q true $tmp 2>/dev/null || return 1
-
- _VS_LOCKS="$! $_VS_LOCKS"
-}
-
-## Usage: unlock [<num>]
-function unlock
-{
- local num=$1
- local i
-
- set -- $_VS_LOCKS
- while test "$#" -gt 0; do
- kill -HUP "$1" >/dev/null || :
- shift
- test "$num" != 1 || break
- test -z "$num" || let --num
- done
- _VS_LOCKS="$@"
-}
-
-function _pkgMountBindDir()
-{
- test "$1" != "$2" || return 0
-
- $_MOUNT -n --bind "$1" "$2"
-}
-
-function _pkgSetVarsBase
-{
- case "$vserver" in
- ./*|/*)
- if test -d "$vserver/vdir"; then
- BASEDIR=$vserver
- VDIR=$(getPhysicalDir "$vserver/vdir")
-
- PKGDIR=$BASEDIR/apps/pkgmgmt
- test -d "$PKGDIR" || {
- echo "Can not find configuration-directory for package-managment tools"
- exit 1
- } >&2
- findDir EXECDIR $PKGDIR/execdir /
- else
- VDIR=$(getPhysicalDir "$vserver")
- PKGDIR=
- fi
- ;;
- *)
- BASEDIR=$__CONFDIR/$vserver
- test -d "$BASEDIR" || {
- echo "Can not find configuration-directory"
- exit 1
- } >&2
-
- VDIR=$BASEDIR/vdir
- test -d "$VDIR" || VDIR=$__DEFAULT_VSERVERDIR/$vserver
- VDIR=$(getPhysicalDir "$VDIR")
-
- PKGDIR=$BASEDIR/apps/pkgmgmt
- test -d "$PKGDIR" || {
- echo "Can not find configuration-directory for package-managment tools"
- exit 1
- } >&2
-
- findDir EXECDIR $PKGDIR/execdir /
-
- ;;
- esac
-
- if test -z "$WORKAROUND_106057"; then
- _rpmdb_mntpoint=/dev
- else
- _rpmdb_mntpoint=/.rpmdb
- fi
-}
-
-function _pkgSetVarsRPM
-{
- if test -n "$PKGDIR"; then
- findDir RPMETCDIR $PKGDIR/rpmetc $PKGDIR/base/rpm/etc /etc/rpm
- findDir RPMSTATEDIR $PKGDIR/rpmstate $PKGDIR/base/rpm/state
-
- findDir RPMLIBDIR $PKGDIR/rpmlib /
-
- else
- findDir RPMETCDIR "$VDIR"/etc/rpm /etc/rpm
- findDir RPMSTATEDIR "$VDIR"/var/lib/rpm
- RPMLIBDIR=/
- fi
-
- RPMSTATEDIR=$(getPhysicalDir "$RPMSTATEDIR")
- RPMETCDIR=$(getPhysicalDir "$RPMETCDIR")
-}
-
-function _pkgSetVarsApt
-{
- if test -n "$PKGDIR"; then
- findDir APTETCDIR $PKGDIR/aptetc $PKGDIR/base/apt/etc /etc/apt
- findDir APTSTATEDIR $PKGDIR/aptstate $PKGDIR/base/apt/state
- findDir APTCACHEDIR $PKGDIR/aptcache $PKGDIR/base/apt/cache
- findDir APTARCHIVDIR $PKGDIR/aptarchives $PKGDIR/base/apt/archives /var/cache/apt/archives
- else
- findDir APTETCDIR "$VDIR"/etc/apt /etc/apt
- findDir APTSTATEDIR "$VDIR"/var/state/apt
- findDir APTCACHEDIR "$VDIR"/var/cache/apt
- findDir APTARCHIVDIR "$VDIR"/var/cache/apt/archives /var/cache/apt/archives
- fi
-
- findFile APT_CONFIG "$APTETCDIR"/apt.conf ""
- test -z "$APT_CONFIG" || export APT_CONFIG
-}
-
-function _pkgSetVarsYum
-{
- if test -n "$PKGDIR"; then
- findDir YUMETCDIR $PKGDIR/yumetc $PKGDIR/base/yum/etc /etc
- findDir YUMCACHEDIR $PKGDIR/yumcache $PKGDIR/base/yum/cache
- else
- findDir YUMETCDIR "$VDIR"/etc /etc
- findDir YUMCACHEDIR "$VDIR"/var/cache/yum
- fi
-}
-
-
-function _pkgMountBase
-{
- :
-}
-
-function _pkgMountApt
-{
- :
-}
-
-function _pkgMountYum
-{
- :
-}
-
-function _pkgMountRPM
-{
- _pkgMountBindDir "$RPMETCDIR" /etc/rpm
- test "$RPMLIBDIR" = "/" || _pkgMountBindDir "$RPMLIBDIR" /usr/lib/rpm
-
- pushd "$VDIR" >/dev/null
-
- $_SECURE_MOUNT --chroot -n --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint"
- test -z "$WORKAROUND_106057" || mount -n --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint"
-
- test -e "$VDIR"/proc/self/status || \
- $_SECURE_MOUNT --chroot -n -t proc none /proc
-
- popd >/dev/null
-}
-
-function _pkgSetEnvBase
-{
- test "$EXECDIR" = "/" || {
- PATH=$EXECDIR:$PATH
- LD_LIBRARY_PATH=$EXECDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
- }
-
- export PATH LD_LIBRARY_PATH
-}
-
-function _pkgSetEnvApt
-{
- :
-}
-
-function _pkgSetEnvYum
-{
- :
-}
-
-function _pkgSetEnvRPM
-{
- CUR_VSERVER=$vserver
- RPM_FAKE_NAMESPACE_MOUNTS=$_rpmdb_mntpoint
- RPM_BINARY=$_VRPM_PRELOAD
-
- export CUR_VSERVER RPM_FAKE_NAMESPACE_MOUNTS RPM_BINARY
-}
-
-function pkgInit
-{
- local i
- local vserver=$1
- shift
-
- _pkgSetVarsBase
- for i; do
- case "$i" in
- rpm) _pkgSetVarsRPM;;
- apt) _pkgSetVarsApt;;
- yum) _pkgSetVarsYum;;
- *) echo "Unknown packaging flavor" >&2; exit 1;;
- esac
- done
-
- _pkgMountBase
- for i; do
- case "$i" in
- rpm) _pkgMountRPM;;
- apt) _pkgMountApt;;
- yum) _pkgMountYum;;
- esac
- done
-
- _pkgSetEnvBase
- for i; do
- case "$i" in
- rpm) _pkgSetEnvRPM;;
- apt) _pkgSetEnvApt;;
- yum) _pkgSetEnvYum;;
- esac
- done
-
- _PKG_FLAVORS="$@"
- _PKG_VSERVER=$vserver
-}
-
-function isAvoidNamespace
-{
- local cfgdir
-
- $_VSERVER_INFO - FEATURE namespace || return 0
- cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 0
- test ! -e "$cfgdir"/namespace || return 1
- test -e "$__CONFDIR"/.defaults/nonamespace -o \
- -e "$cfgdir"/nonamespace
-}
-
-function getAllVservers
-{
- local _ga_i
- declare -a _ga_tmp=()
-
- for _ga_i in $__CONFDIR/*; do
- test -d "$_ga_i" || continue
- test ! -e "$_ga_i"/disabled || continue
- test -d "$_ga_i"/vdir || continue
- case "$_ga_i" in
- *.~*~) continue;;
- esac
-
- _ga_tmp=( "${_ga_tmp[@]}" "${_ga_i##$__CONFDIR/}")
- done
-
- eval $1='( "${_ga_tmp[@]}" )'
-}
-
-## Usage: _getProcNumberCount <ctx> <var>
-function _getProcNumberCount
-{
- local _gp_var=$2
- local _gp_procnr_cnt=0
-
- # Use /proc/virtual from kernel 2.6 when possible
- if test -d "/proc/virtual"; then
- set -- $($_GREP '^PROC:' "/proc/virtual/$1/limit" 2>/dev/null)
- _gp_procnr_cnt=$2
- else
- _gp_procnr_cnt=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$1" | $_WC -l )
- fi
-
- let _gp_procnr_cnt=_gp_procnr_cnt+0
- eval $_gp_var=\$_gp_procnr_cnt
-}
-
-## Usage: getVserverCtx <vdir> <result-varname> [<procnumber-varname> [<do-cleanup>]]
-## Returns: 0 iff vserver is running
-function getVserverStatus
-{
- test -r "$1"/run || return 1
-
- local _gvs_ctx
- read _gvs_ctx <"$1"/run
- eval "$2"=\$_gvs_ctx
-
- test -n "$3" || return 0
- local _gvs_tmp
- _getProcNumberCount "$_gvs_ctx" _gvs_tmp
- eval "$3"=\$_gvs_tmp
-
- if test "$_gvs_tmp" = 0; then
- local runfile=$($_READLINK "$1/run")
- test -z "$4" || $_RM -f "$runfile"
- return 1
- fi
-
- return 0
-}
-
-## Usage: isCtxRunning <ctx>
-function isCtxRunning
-{
- local _tmp
- _getProcNumberCount "$1" _tmp
- test $_tmp -gt 0
-}
-
-## Usage: isVserverRunning <vdir> [<ctx-varname>]
-function isVserverRunning
-{
- local _ivr_ctx _ivr_procnum
-
- getVserverStatus "$1" _ivr_ctx _ivr_procnum 1 || return 1
- test "$_ivr_procnum" != 0 || return 1
- test -z "$2" || eval "$2"=\$_ivr_ctx
- return 0
-}
-
-## Called as 'getFileValue <varname> <filename>+'
-function getFileValue
-{
- local _gfv_var=$1
- local _gfv_file
- shift
-
- findFile _gfv_file "$@" ''
- test -n "$_gfv_file" -a -r "$_gfv_file" || return 0
- eval read "$_gfv_var" <"$_gfv_file"
-}
-
-## Called as 'getFileArray <varname> <filename>'
-function getFileArray
-{
- test -r "$2" || return 1
-
- local IFS=$_VS_NEWLINE
- eval "$1"='( $(< "$2") )'
-}
-
-function checkComponents
-{
- local i
- local msg=$1
- local x_failed=
-
- shift
-
- for i; do
- local failed=
- case "$i" in
- (core) test -x "$_CHBIND" || failed=1;;
- (build) test -x "$_VSERVER_BUILD" || failed=1;;
- (sysv) test -x "$__INITRDDIR/vserver" || failed=1;;
- (devel) test -d "$__INCLUDEDIR/vserver.h" || failed=1;;
- (*) echo "Unknown component '$i'" >&2
- return false
- ;;
- esac
-
- test -z "$failed" || {
- echo "$msg: $i"
- x_failed=1
- } >&2
- done
-
- test -z "$x_failed"
-}
-
-## Usage: isKernelAPI <ver> [<cmp-modifier>]
-function isKernelAPI
-{
- local api
- api=$($_VSERVER_INFO - APIVER) || api=0
- test $[ $api ] -${2:-ge} $[ $1 ]
-}
-
-## Usage: callInNamespace <vserver> <command> <args>*
-function callInNamespace
-{
- local ctx=
-
- isAvoidNamespace "$1" || \
- ctx=$( $_VSERVER_INFO "$1" CONTEXT f ) || ctx=
-
- shift
- if test -n "$ctx"; then
- $_VNAMESPACE --enter "$ctx" -- "$@"
- else
- "$@"
- fi
-}
-
-## Usage: setDefaultTTY <vdir> [<fallback-tty>]
-function setDefaultTTY
-{
- local cfgdir ttyname
-
- cfgdir=$($_VSERVER_INFO "$1" APPDIR init) || cfgdir=
- findObject -e ttyname \
- ${cfgdir:+"$cfgdir"/tty} \
- "$__CONFDIR/.defaults/apps/init/tty" \
- $2 /dev/null
-
- exec <$ttyname
- exec &>$ttyname
-}
-
-## Usage: pkgmgmt.guessStyle <vserver> <resultvar>
-function pkgmgmt.guessStyle()
-{
- local _pgs_vdir
- _pgs_vdir=$($_VSERVER_INFO "$1" VDIR) || {
- echo $"Can not determine vserver-root" >&2
- return 1
- }
- local _pgs_cfgdir=$($_VSERVER_INFO "$1" APPDIR pkgmgmt) || :
-
- if test -n "$_pgs_cfgdir" -a -e "$_pgs_cfgdir"/style; then
- read style <"$_pgs_cfgdir"/style
- elif test -e "$_pgs_vdir"/etc/redhat-release -o -e "$_pgs_vdir"/etc/fedora-release; then
- style=redhat
- elif test -e "$_pgs_vdir"/etc/mandrake-release; then
- style=mandrake
- elif test -e "$_pgs_vdir"/etc/debian_version; then
- style=debian
- elif test -e "$_pgs_vdir"/etc/SuSE-release; then
- style=suse
- else
- echo $"Can not determine packagemanagement style" >&2
- return 1
- fi
-
- eval $2=\$style
- return 0
-}
-
-## Usage: pkgmgmt.isInternal <vserver>
-## returns true iff <vserver> is configured for internal packagemanagement
-## A typical application is
-## | is_external=
-## | pkgmgmt.isInternal "$vserver" || is_external=1
-function pkgmgmt.isInternal
-{
- local cfgdir=$($_VSERVER_INFO "$1" APPDIR pkgmgmt) || :
-
- test -z "$cfgdir" -o ! -d "$cfgdir" -o -e "$cfgdir"/internal
-}
-
-## Usage: pkgmgmt.isAptAvailable <cfgdir> <vdir> [<is-internal>]
-function pkgmgmt.isAptAvailable
-{
- local cfgdir="$1"
- local vdir="$2"
- local is_internal="$3"
-
- local have_apt i
- if test -n "$is_internal"; then
- have_apt=1
- test -d "$cfgdir"/base/apt -o -d "$cfgdir"/aptetc || have_apt=
- else
- have_apt=
- for i in /bin /usr/bin /usr/local/bin; do
- test ! -x "$vdir$i"/apt-get || { have_apt=1; break; }
- done
- fi
-
- test -n "$have_apt" && return 0 || return 1
-}
-
-## Usage: pkgmgmt.isYumAvailable <cfgdir> <vdir> [<is-internal>]
-function pkgmgmt.isYumAvailable
-{
- local cfgdir="$1"
- local vdir="$2"
- local is_internal="$3"
-
- local have_yum i
- if test -n "$is_internal"; then
- have_yum=1
- test -d "$cfgdir"/base/yum -o -d "$cfgdir"/yumetc || have_yum=
- else
- have_yum=
- for i in /bin /usr/bin /usr/local/bin; do
- test ! -x "$vdir$i"/yum || { have_yum=1; break; }
- done
- fi
-
- test -n "$have_yum" && return 0 || return 1
-}
-
-
-function vshelper.doSanityCheck
-{
- local vshelper this_xid i
- declare -a warnings=()
- local solution_disable=
- local solution_sysctl=
-
- vshelper.isEnabled && vshelper.isEnabled warning || return 0
-
- this_xid=$($_VSERVER_INFO - XID) ||
- panic $"Failed to determine current context; aborting..."
-
- ## Do nothing in other xid's; the helper will be executed in xid 0 only
- test "$this_xid" = 0 || return 0
-
- local proc_file=/proc/sys/kernel/vshelper
-
- if ! test -r "$proc_file"; then
- vshelper=
- warnings=( "${warnings[@]}"
- $"File '$proc_file' does not exist but is required for vshelper setup" )
- solution_disable=1
- else
- vshelper=$(cat "$proc_file")
-
- $_CMP -s "$vshelper" "$_VSHELPER" || {
- warnings=( "${warnings[@]}"
- $"The configured vshelper '$vshelper' does not match the 'vshelper'
- script of the util-vserver package"
- )
- solution_disable=1
- solution_sysctl=1
- }
- fi
-
- test -d "$__VSHELPERSTATEDIR" || {
- warnings=( "${warnings[@]}"
- $"\
-The vshelper state-directory '$__VSHELPERSTATEDIR' does not exist; since
-it is created by 'make install', this indicates a serious problem with
-your util-vserver installation" )
- solution_disable=1
- }
-
- test "${#warnings[@]}" -eq 0 || {
- warning $"\
-The following problem(s) were encountered while verifying vshelper
-functionality:"
-
- for i in "${warnings[@]}"; do
- warning "* $i"
- done
-
- warning $"\
-
-To fix this, you can:"
-
- test -z "$solution_disable" || warning $"\
-* disable vshelper entirely by executing
- | touch \"$__CONFDIR/.defaults/apps/vshelper/disabled\"
-* disable only this message by executing
- | touch \"$__CONFDIR/.defaults/apps/vshelper/warning-disabled\""
-
- test -x "$solution_sysctl" || warning $"\
-* configure the util-vserver vshelper script, e.g. by adding
- | kernel.vshelper = \"$_VSHELPER\"
- to /etc/sysctl.conf and rebooting the machine, or by executing
- | echo \"$_VSHELPER\" >$proc_file"
-
- warning ""
-
- return 1
- }
-
- return 0
-}
-
-## Usage: vshelper.isEnabled [<style>] [<vserver>]
-function vshelper.isEnabled
-{
- local f=${1:+$1-}disabled
- test ! -e "$__CONFDIR"/.defaults/apps/vshelper/"$f" || return 1
- $_VSERVER_INFO - FEATURE vshelper || return 1
- if test -n "$2"; then
- local appdir
- appdir=$($_VSERVER_INFO "$2" APPDIR vshelper) || return 0
- test -z "$2" -o ! -e "$appdir/$f" || return 1
- fi
-
- return 0
-}
-
-## Usage: vshelper.isDebug [<vserver>]
-function vshelper.isDebug
-{
- test ! -e "$__CONFDIR"/.defaults/apps/vshelper/debug || return 1
- $_VSERVER_INFO - FEATURE vshelper || return 1
- if test -n "$1"; then
- local appdir
- appdir=$($_VSERVER_INFO "$1" APPDIR vshelper) || return 1
- test -z "$1" -o ! -e "$appdir/debug" || return 1
- fi
-
- return 0
-}
-
-function vshelper._getHandlerInternal
-{
- local _vghi_var=$1
- local _vghi_tmp
- shift
- shift ## HACK: see below the note about the 'set -u' mode
-
- while test "$#" -ge 2; do
- local _vghi_mod=$1
- local _vghi_obj=$2
- shift 2
-
- test "$_vghi_mod" "$_vghi_obj" || continue
- case "$_vghi_mod" in
- (-x)
- eval $_vghi_var=\$_vghi_obj
- ;;
- (-e)
- read _vghi_tmp <"$_vghi_obj"
- eval $_vghi_var=:\$_vghi_tmp
- ;;
- (*) panic $"Internal error, unexpected modifier '$_vghi_mod'"
- esac
- return 0
- done
-
- return 1
-}
-
-## Usage: vshelper.getHandler <result-var> <vserver> <action>
-function vshelper.getHandler
-{
- local _vgh_appdir
- _vgh_appdir=$($_VSERVER_INFO "$2" APPDIR vshelper) || _vgh_appdir=
-
- declare -a _vgh_search_list=( X )
- ## HACK: when we are in 'set -u' mode, empty lists are causing errors
-
- test -z "$_vgh_appdir" || _vgh_search_list=( "${_vgh_search_list[@]}" -x "$_vgh_appdir/$3" )
- test -z "$_vgh_appdir" || _vgh_search_list=( "${_vgh_search_list[@]}" -e "$_vgh_appdir/action" )
- _vgh_search_list=( "${_vgh_search_list[@]}" -x "$__CONFDIR"/.defaults/apps/vshelper/"$3" )
- _vgh_search_list=( "${_vgh_search_list[@]}" -e "$__CONFDIR"/.defaults/apps/vshelper/action )
-
- ! vshelper._getHandlerInternal "$1" "${_vgh_search_list[@]}" || return 0
- eval $1=':restart'
-}
-
-## Usage: vshelper.init <vserver> [<method> <args>*]
-function vshelper.doInit
-{
- vshelper.isEnabled || return 0
-
- local xid
- xid=$($_VSERVER_INFO "$1" CONTEXT false) && test -n "$xid" || {
- warning $"vshelper.init: can not determine xid of vserver '$vserver'; returned value was '$xid'"
- return 1
- }
-
- local f="$__VSHELPERSTATEDIR/$xid"
-
- set -C
- $_RM -f "$f"
- echo "$1" >"$f"
- set +C
-
- if test -n "$2"; then
- shift 1
- local i
- for i; do
- echo "$i"
- done
- else
- echo "default"
- fi >>"$f"
-
- return 0
-}
-
-## Usage: vshelper.doDestroy <vserver> <xid>
-function vshelper.doDestroy
-{
- vshelper.isEnabled || return 0
-
- $_RM -f "$__VSHELPERSTATEDIR/$2"
-}
-
-## Usage: vshelper.initSync <vserver> <pipe-varname>
-function vshelper.initSync
-{
- local _vis_tmpdir
- _vis_tmpdir=$($_MKTEMPDIR /tmp/vserver-stop.XXXXXX) || {
- warning $"Failed to generate temporary directory for vshelper sync"
- return 1
- }
-
- local _vis_fifo="$_vis_tmpdir"/pipe
- $_MKFIFO -m700 "$_vis_fifo"
- vshelper.doInit "$1" sync "$_vis_fifo"
- eval $2=\$_vis_fifo
-}
-
-## Usage: vshelper.getSyncTimeout <vserver> <varname>
-function vshelper.getSyncTimeout
-{
- local _vgst_appdir _vgst_file _vgst_tmp
- _vgst_appdir=$($_VSERVER_INFO "$1" APPDIR vshelper) || _vgst_appdir=
-
- findFile _vgst_file ${_vgst_appdir:+"$_vgst_appdir"/sync-timeout} "$__CONFDIR"/.defaults/apps/vshelper/sync-timeout ''
- test -n "$_vgst_file" || return 1
- read _vgst_tmp <"$_vgst_file"
- eval $2=\$_vgst_tmp
-}
-
-
-function _rpmFake.getCapFlags
-{
- local ctx=$1
-
- if test -n "$ctx" && ! $_VSERVER_INFO - FEATURE migrate; then
- set -- $($_CHCONTEXT_COMPAT --xid 1 \
- $_SH -c "$_CAT /proc/[0-9]*/status | $_EGREP '^(CapBset|s_context|ctxflags)'" | \
- $_GREP -B 1 -A 1 "^s_context: $ctx " | \
- $_SED -e '1,3p;d' | $_AWK '{ print $2 }')
- else
- set --
- fi
-
- if test -n "$3"; then
- RPM_FAKE_CAP=$[ ~0x$1 ]
- RPM_FAKE_FLAGS=$3
- else
- RPM_FAKE_CAP=$[ ~0xd40c04ff ]
- RPM_FAKE_FLAGS=4
- fi
-}
-
-function rpmFake.init
-{
- local vdir ctx
-
- vdir=$($_VSERVER_INFO "$1" VDIR) || vdir="$1"
- ctx=$($_VSERVER_INFO "$1" CONTEXT) || ctx=
-
- test -d "$vdir" ||
- panic $"Can not find chroot environment at '$vdir' for '$1'"
-
- _rpmFake.getCapFlags "$ctx"
-
- RPM_FAKE_CHROOT=$vdir
- RPM_FAKE_CTX=$ctx
-}
-
-function rpmFake.exec
-{
- export RPM_FAKE_CHROOT RPM_FAKE_CTX RPM_FAKE_CAP RPM_FAKE_FLAGS
-
- LD_PRELOAD=$_RPM_FAKE_SO${LD_PRELOAD:+:$LD_PRELOAD} \
- exec "$@"
-}
+++ /dev/null
-.vps.pathsubst.stamp
-vps
+++ /dev/null
-#!/bin/bash
-
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on distrib-info by Jacques Gelinas
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-
-# This scripts knows about every possible distribution (well, it should)
-# It is passed a vserver name and a key (a command). The key represent a task.
-# It executes the command and output on stdout.
-# For example
-# distrib-info vserver1 pkgversion
-# If vserver1 is a redhat system, it executes
-# rpm -qa --queryformat "%{name}=%{version}-%{release}
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-if [ "$1" = "" ] ; then
- echo distrib-info vserver-name command [ args ... ] >&2
- echo Commands are: >&2
- echo dumpfiles: Shows all files owned by a package >&2
- echo pkgversion: reports all packages and their version/release >&2
- echo unifiles: reports all unify-able file of a package >&2
- exit 1
-fi
-if [ "$1" = "/" ] ; then
- DISTDIR=/
- CHROOTCMD=
-elif [ -d "$1" ] ; then
- DISTDIR=$1
- CHROOTCMD="$__SBINDIR/chroot $DISTDIR"
-else
- DISTDIR=$__DEFAULT_VSERVERDIR/$1
- CHROOTCMD="$__SBINDIR/chroot $DISTDIR"
-fi
-KEY=$2
-shift
-shift
-if [ -f $DIRDIR/etc/redhat-release -o -f $DISTDIR/etc/mandrake-release ] ; then
- case $KEY in
- pkgversion)
- $CHROOTCMD /bin/rpm -qa --queryformat "%{name}=%{version}-%{release}\n"
- ;;
- unifiles)
- # We remove /etc and /var/log to make sure no special file
- # there will be unified
- $CHROOTCMD /bin/rpm -ql --dump $* \
- | $_PARSERPMDUMP /etc/
- ;;
- dumpfiles)
- $CHROOTCMD /bin/rpm -ql $*
- ;;
- *)
- echo unknown request $KEY >&2
- ;;
- esac
-else
- echo Distribution not supported yet >&2
-fi
+++ /dev/null
-#!/bin/sh
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on rootshell by Jacques Gelinas
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-test "$*" || set -- --login
-exec $CHBIND --silent --ip 0.0.0.0 /bin/bash "$@"
-
+++ /dev/null
-#!/bin/sh
-
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on save_s_context by Jacques Gelinas
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-if [ $# -lt 1 ] ;then
- echo save_s_context file command
- echo Save the security context in file and execute a command
-else
- CTX=`grep ^s_context: /proc/self/status | sed s/s_context:// | (read a b; echo $a)`
- CTX=`eval expr $CTX + 0`
- echo S_CONTEXT=$CTX >$1
- echo S_PROFILE=$PROFILE >>$1
- shift
- exec "$@"
-fi
-
-
+++ /dev/null
-#!/usr/bin/perl
-
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on vps by Krischan Jodies
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-# Wrapper for ps. Adds security context number and name
-# to the PID column.
-#
-# (c) 2002 krischan.jodies@sernet.de
-# version 1.0
-
-# 1.1 Added error messages
-
-if ($ARGV[0] eq "--help") {
- exec("ps @ARGV");
- exit;
-}
-
-
-$lockdir = "/var/run/vservers";
-
-$pid_length = 5;
-get_server_names();
-$context=get_context("self");
-
-if ($context == -1) {
- print "Can not find my security context. Is this a ctx kernel?\n";
- exit;
-}
-if ($context != 1) {
- exec("@PKGLIBDIR@/chcontext-compat --silent --ctx 1 $0 @ARGV");
- print "Can not execute chcontext\n";
- exit; # not reached
-}
-
-
-if (! open PS, "ps @ARGV|") {
- print "Can not execute ps\n";
- exit;
-}
-while (<PS>) {
- chomp;
- push @ps,$_;
-}
-
-$header = shift @ps;
-$header =~ /(.*) PID(.+)/;
-$left = $1;
-$right = $2;
-$left_length = length($left);
-print "${left} PID CONTEXT ${right}\n";
-foreach $line (@ps) {
- $pid = substr $line,$left_length,$pid_length;
- print substr $line,0,$left_length;
- print "$pid";
- $context = get_context($pid);
- $context_name = getcontextname($context);
- printf " %-3s %-10s",$context,$context_name;
- print substr $line,$left_length + $pid_length;
- print "\n";
-
-}
-
-exit;
-
-sub get_context
-{
- my $pid = $_[0];
- $pid =~ s/ //g;
- open STATUS, "/proc/$pid/status";
- while (<STATUS>)
- {
- chomp;
- if (/s_context: (\d+)/) {
- close STATUS;
- return $1;
- }
- }
- close STATUS;
- return -1;
-}
-
-sub getcontextname {
- if (exists $name{$_[0]}) {
- return $name{$_[0]};
- }
- if ($_[0] == 1) {
- return "ALL_PROCS";
- }
- elsif ($_[0] == 0) {
- return "MAIN";
- }
- return "UNKNOWN";
-}
-
-
-sub get_server_names
-{
- opendir LOCKDIR, "$lockdir";
- while ($file=readdir(LOCKDIR)) {
- if (-f "$lockdir/$file") {
- open FILE, "$lockdir/$file";
- $file =~ s/(.+)\.ctx/$1/;
- while (<FILE>) {
- if (/S_CONTEXT=(\d+)/) {
- $name{$1} = $file;
- }
- }
- }
- }
-}
+++ /dev/null
-#!/bin/sh
-
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on vserver by Jacques Gelinas
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-# This is a script to control a virtual server
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-USR_SBIN=$__SBINDIR
-USR_LIB_VSERVER=$__PKGLIBDIR
-DEFAULTPATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
-
-vserver_mknod(){
- mknod $1 $2 $3 $4
- chmod $5 $1
-}
-
-mountproc()
-{
- mkdir -p $1/proc $1/dev/pts
- if [ ! -d $1/proc/1 ] ; then
- mount -t proc none $1/proc
- mount -t devpts -o gid=5,mode=0620 none $1/dev/pts
- fi
-}
-umountproc()
-{
- umount $1/proc 2>/dev/null
- umount $1/dev/pts 2>/dev/null
-}
-
-# Check that the vservers parent directory has permission 000
-# This is the key to avoid chroot escape
-testperm()
-{
- return
- PERM=`$_SHOWPERM $__DEFAULT_VSERVERDIR/$1/..`
- if [ "$PERM" != 000 ] ; then
- echo
- echo "**********************************************************"
- echo $__DEFAULT_VSERVERDIR/$1/.. has insecure permissions.
- echo A vserver administrator may be able to visit the root server.
- echo To fix this, do
- echo " " chmod 000 $__DEFAULT_VSERVERDIR/$1/..
- echo do it anytime you want, even if vservers are running.
- echo "**********************************************************"
- echo
- fi
-}
-# Set the IP alias needed by a vserver
-ifconfig_iproot()
-{
- if [ "$NODEV" = "" -a "$IPROOT" != "" -a "$IPROOT" != "0.0.0.0" -a "$IPROOT" != "ALL" ] ;then
- # A vserver may have more than one IP
- # The first alias is dev:vserver
- # and the other are dev:vserver1,2,3 and so on
- # An IP may hold the device. The following is valid
- # IPROOT="1.2.4.5 eth1:1.2.3.5"
- # IPROOTDEV=eth0
- # The first IP 1.2.3.4 will go on eth0 and the other on eth1
- # VLAN devices are also supported (eth0.231 for vlan 231)
- SUFFIX=
- for oneip in $IPROOT
- do
- IPDEV=$IPROOTDEV
- MASK=$IPROOTMASK
- BCAST=$IPROOTBCAST
- # Split the device and IP if available
- case $oneip in
- *:*)
- eval `echo $oneip | tr : ' ' | (read dev ip; echo oneip=$ip; echo IPDEV=$dev)`
- ;;
- esac
- # Split the IP and the netmask if available
- case $oneip in
- */*)
- eval `echo $oneip | tr / ' ' | (read ip msk; echo oneip=$ip; echo MASK=$msk)`
- eval `$_IFSPEC "" "$oneip" "$MASK" "$BCAST"`
- ;;
- esac
- if [ "$IPDEV" != "" ] ; then
- case $IPDEV in
- *.*)
- if [ ! -f /proc/net/vlan/$IPDEV ] ; then
- /sbin/vconfig add `echo $IPDEV | tr . ' '`
- # Put a dummy IP
- /sbin/ifconfig $IPDEV 127.0.0.1
- fi
- ;;
- esac
- # Compute the default netmask, if missing
- eval `$_IFSPEC $IPDEV "$oneip" "$MASK" "$BCAST"`
- IPROOTMASK=$NETMASK
- IPROOTBCAST=$BCAST
- #echo /sbin/ifconfig $IPDEV:$1$SUFFIX $oneip netmask $IPROOTMASK broadcast $IPROOTBCAST
- /sbin/ifconfig $IPDEV:$1$SUFFIX $oneip netmask $IPROOTMASK broadcast $IPROOTBCAST
- fi
- if [ "$SUFFIX" = "" ] ; then
- SUFFIX=1
- else
- SUFFIX=`expr $SUFFIX + 1`
- fi
- done
- fi
- if [ "$IPROOTBCAST" = "" ] ; then
- IPROOTBCAST=255.255.255.255
- fi
-}
-ifconfig_iproot_off()
-{
- if [ "$NODEV" = "" -a "$IPROOT" != "" -a "$IPROOT" != "0.0.0.0" -a "$IPROOT" != "ALL" -a "$IPROOTDEV" != "" ] ;then
- SUFFIX=
- for oneip in $IPROOT
- do
- IPDEV=$IPROOTDEV
- # Split the device and IP if available
- case $oneip in
- *:*)
- eval `echo $oneip | tr : ' ' | (read dev ip; echo IPDEV=$dev)`
- ;;
- esac
- /sbin/ifconfig $IPDEV:$1$SUFFIX down 2>/dev/null
- if [ "$SUFFIX" = "" ] ; then
- SUFFIX=1
- else
- SUFFIX=`expr $SUFFIX + 1`
- fi
- done
- fi
-}
-# Split an IPROOT definition, trash the devices and
-# compose a set of --ip option for chbind
-setipopt(){
- RET=
- IPS="$*"
- if [ "$IPS" = "" ] ; then
- IPS=0.0.0.0
- fi
- if [ "$1" = "ALL" ] ; then
- IPS=`$_LISTDEVIP`
- fi
- for oneip in $IPS
- do
- # Split the device and IP if available
- case $oneip in
- *:*)
- eval `echo $oneip | tr : ' ' | (read dev ip; echo oneip=$ip)`
- ;;
- esac
- #case $oneip in
- #*/*)
- # eval `echo $oneip | tr / ' ' | (read ip msk; echo oneip=$ip)`
- # ;;
- #esac
- echo --ip $oneip
- done
-}
-
-# Extract the initial runlevel from the vserver inittab
-get_initdefault()
-{
- INITDEFAULT=`grep :initdefault $__DEFAULT_VSERVERDIR/$1/etc/inittab | sed 's/:/ /g' | ( read a level b; echo $level)`
-}
-
-# Read the vserver configuration file, reusing the PROFILE value
-# found in /var/run/vservers
-readlastconf()
-{
- if [ -f $__PKGSTATEDIR/$1.ctx ] ; then
- . $__PKGSTATEDIR/$1.ctx
- if [ "$S_PROFILE" != "" ] ; then
- export PROFILE=$S_PROFILE
- fi
- fi
- export PROFILE
- . $__CONFDIR/$1.conf
-}
-usage()
-{
- echo vserver [ options ] server-name command ...
- echo
- echo server-name is a directory in $__DEFAULT_VSERVERDIR
- echo
- echo The commands are:
- echo " build : Create a virtual server by copying the packages"
- echo " of the root server"
- echo " enter : Enter in the virtual server context and starts a shell"
- echo " Same as \"vserver name exec /bin/sh\""
- echo " exec : Exec a command in the virtual server context"
- echo " suexec : Exec a command in the virtual server context uid"
- echo " service : Control a service inside a vserver"
- echo " vserver name service service-name start/stop/restart/status"
- echo " start : Starts the various services in the vserver, runlevel 3"
- echo " stop : Ends all services and kills the remaining processes"
- echo " running : Tells if a virtual server is running"
- echo " It returns proper exit code, so you can use it as a test"
- echo " status : Tells some information about a vserver"
- echo " chkconfig : It turns a server on or off in a vserver"
- echo
- echo "--nodev : Do not configure the IP aliases of the vserver"
- echo " Useful to enter a vserver without enabling its network"
- echo " and avoiding conflicts with another copy of this vserver"
- echo " running elsewhere"
- echo "--silent : No informative messages about vserver context and IP numbers"
- echo " Useful when you want to redirect the output"
-}
-
-calculateCaps()
-{
- local f
- for f in "$@"; do
- case $f in
- !CAP_SYS_CHROOT)
- CHROOTOPT=--nochroot
- ;;
- *)
- CAPS="$CAPS --cap $f"
- ;;
- esac
- done
-}
-
-SILENT=
-NODEV=
-while true
-do
- if [ "$1" = "--silent" ] ; then
- SILENT=--silent
- shift
- elif [ "$1" = "--nodev" ] ; then
- NODEV=--nodev
- shift
- else
- break
- fi
-done
-# Setup the default ulimit for a vserver
-setdefulimit(){
- # File handle are limited to half of the current system limit
- # Virtual memory is limited to the ram size
- NFILE=`cat /proc/sys/fs/file-max`
- NFILE=`expr $NFILE / 2`
- VMEM=`cat /proc/meminfo | grep MemTotal | (read a b c; echo $b)`
- # Disabled for now, we need a different to set the security
- # context limit than fiddling with ulimit
- #ulimit -H -n $NFILE -v $VMEM
-}
-if [ $# -lt 2 ] ; then
- usage
-elif [ "$2" = "build" ] ; then
- # Either the directory does not exist or is empty
- NBSUB=`ls $__DEFAULT_VSERVERDIR/$1 2>/dev/null | grep -v lost+found | wc -l`
- NBSUB=`expr $NBSUB`
- if [ "$NBSUB" != 0 ] ; then
- echo Virtual server $__DEFAULT_VSERVERDIR/$1 already exist
- else
- if [ ! -d $__DEFAULT_VSERVERDIR ] ; then
- mkdir $__DEFAULT_VSERVERDIR || exit 1
- chmod 000 $__DEFAULT_VSERVERDIR
- echo Directory $__DEFAULT_VSERVERDIR was created with permissions 000
- fi
- mkdir -p $__DEFAULT_VSERVERDIR/$1 || exit 1
- chmod 755 $__DEFAULT_VSERVERDIR/$1
- if test "$UTIL_VSERVER_AVOID_COPY"; then
- mkdir -p $__DEFAULT_VSERVERDIR/$1/{etc/rc.d/init.d,sbin,var/run,var/log}
- else
- cp -ax /sbin /bin /etc /usr /var /lib $__DEFAULT_VSERVERDIR/$1/. || exit 1
- fi
- cd $__DEFAULT_VSERVERDIR/$1 || exit 1
- rm -fr lib/modules/*
- rm -f var/spool/mail/*
- rm -f `find var/run -type f`
- rm -f `find var/log -type f`
- touch var/log/wtmp
- rm -f var/lock/subsys/*
- rm -f etc/cron.d/kmod
- mkdir proc tmp home root boot
- test -f /root/.bashrc && cp -a /root/.bashrc root/.
- test -f /root/.bash_profile && cp -a /root/.bash_profile root/.
- chmod 1777 tmp
- chmod 750 root
- # Create a minimal dev so the virtual server can't grab
- # more privileges
- mkdir dev dev/pts
- vserver_mknod dev/null c 1 3 666
- vserver_mknod dev/zero c 1 5 666
- vserver_mknod dev/full c 1 7 666
- vserver_mknod dev/random c 1 8 644
- vserver_mknod dev/urandom c 1 9 644
- vserver_mknod dev/tty c 5 0 666
- vserver_mknod dev/ptmx c 5 2 666
- touch dev/hdv1
- # Turn off some service useless on a vserver
- # vserver_turnoff apmd network autofs dhcpd gpm ipchains iptables \
- # irda isdn keytable kudzu linuxconf-setup netfs nfs nfslock \
- # pcmcia portmap pppoe random rawdevices rhnsd rstatd ruserd \
- # rwalld rwhod sendmail smb snmpd v_httpd h_xinetd v_sshd vservers \
- # xfs ypbind xinetd
- (
- cd etc/init.d 2>/dev/null || cd etc/rc.d/init.d
- for serv in *
- do
- case $serv in
- *.bak|*~|functions|killall|halt|single)
- ;;
- *)
- #$USR_LIB_VSERVER/capchroot $__DEFAULT_VSERVERDIR/$1 /sbin/chkconfig --level 2345 $serv off
- $0 --silent $1 chkconfig --level 2345 $serv off
- ;;
- esac
- done
- )
- rm -f etc/rc.d/rc6.d/S*reboot
- # Create a dummy /etc/fstab and /etc/mtab to please
- # df and linuxconf. We use hdv1, which does not exist
- # to remind the admin that it is not the real drive
- echo /dev/hdv1 / ext2 defaults 1 1 >etc/fstab
- echo /dev/hdv1 / ext2 rw 0 0 >etc/mtab
- # Install the vreboot utility
- cp -a "$_VREBOOT" sbin/.
- ln -sf vreboot sbin/vhalt
-
- echo Directory $__DEFAULT_VSERVERDIR/$1 has been populated
- if [ ! -d $__CONFDIR ] ; then
- mkdir $__CONFDIR
- chmod 600 $__CONFDIR
- echo Directory $__CONFDIR has been created
- fi
- if [ ! -f $__CONFDIR/$1.conf ] ; then
- CONF=$__CONFDIR/$1.conf
- cat >$CONF <<-EOF
-if [ "$PROFILE" = "" ] ; then
- PROFILE=prod
-fi
-# Select the IP number assigned to the virtual server
-# This IP must be one IP of the server, either an interface
-# or an IP alias
-# A vserver may have more than one IP. Separate them with spaces.
-# do not forget double quotes.
-# Some examples:
-# IPROOT="1.2.3.4 2.3.4.5"
-# IPROOT="eth0:1.2.3.4 eth1:2.3.4.5"
-# If the device is not specified, IPROOTDEV is used
-case \$PROFILE in
-prod)
- IPROOT=1.2.3.4
- # The netmask and broadcast are computed by default from IPROOTDEV
- #IPROOTMASK=
- #IPROOTBCAST=
- # You can define on which device the IP alias will be done
- # The IP alias will be set when the server is started and unset
- # when the server is stopped
- #IPROOTDEV=eth0
- # You can set a different host name for the vserver
- # If empty, the host name of the main server is used
- S_HOSTNAME=
- ;;
-backup)
- IPROOT=1.2.3.4
- #IPROOTMASK=
- #IPROOTBCAST=
- #IPROOTDEV=eth0
- S_HOSTNAME=
- ;;
-esac
-# Uncomment the onboot line if you want to enable this
-# virtual server at boot time
-#ONBOOT=yes
-# You can set a different NIS domain for the vserver
-# If empty, the current on is kept
-# Set it to "none" to have no NIS domain set
-S_DOMAINNAME=
-# You can set the priority level (nice) of all process in the vserver
-# Even root won't be able to raise it
-S_NICE=
-# You can set various flags for the new security context
-# lock: Prevent the vserver from setting new security context
-# sched: Merge scheduler priority of all processes in the vserver
-# so that it acts a like a single one.
-# nproc: Limit the number of processes in the vserver according to ulimit
-# (instead of a per user limit, this becomes a per vserver limit)
-# private: No other process can join this security context. Even root
-# Do not forget the quotes around the flags
-S_FLAGS="lock nproc"
-# You can set various ulimit flags and they will be inherited by the
-# vserver. You enter here various command line argument of ulimit
-# ULIMIT="-HS -u 200"
-# The example above, combined with the nproc S_FLAGS will limit the
-# vserver to a maximum of 200 processes
-ULIMIT="-HS -u 1000"
-# You can set various capabilities. By default, the vserver are run
-# with a limited set, so you can let root run in a vserver and not
-# worry about it. He can't take over the machine. In some cases
-# you can to give a little more capabilities (such as CAP_NET_RAW)
-# S_CAPS="CAP_NET_RAW"
-S_CAPS=""
-# Select an unused context (this is optional)
-# The default is to allocate a free context on the fly
-# In general you don't need to force a context
-#S_CONTEXT=
- EOF
- echo $CONF has been created. Look at it\!
- fi
- fi
-elif [ ! -f $__CONFDIR/$1.conf ] ; then
- echo No configuration for this vserver: $__CONFDIR/$1.conf
- exit 1
-elif [ ! -d $__DEFAULT_VSERVERDIR/$1/. ] ; then
- echo No directory for this vserver: $__DEFAULT_VSERVERDIR/$1
- exit 1
-elif [ "$2" = "start" ] ; then
- echo Starting the virtual server $1
- testperm $1
- if ! $0 $1 running
- then
- test -x $__CONFDIR/$1.sh && $__CONFDIR/$1.sh pre-start $1
- IPROOT=
- IPROOTMASK=
- IPROOTBCAST=
- IPROOTDEV=
- S_NICE=
- S_FLAGS=
- . $__CONFDIR/$1.conf
- export PROFILE
- ifconfig_iproot $1
- cd $__DEFAULT_VSERVERDIR/$1 || exit 1
-
- if [ "$PROFILE" != "" ] ; then
- echo export PROFILE=$PROFILE >etc/PROFILE
- fi
-
- rm -f `find var/run -type f`
- touch var/run/utmp
- chgrp ${UTMP_GROUP:-utmp} var/run/utmp
- chmod 0664 var/run/utmp
- rm -f var/lock/subsys/*
- mountproc $__DEFAULT_VSERVERDIR/$1
- CTXOPT=
- HOSTOPT=
- DOMAINOPT=
- NICECMD=
- FLAGS=
- CAPS=
- get_initdefault $1
- STARTCMD="/etc/rc.d/rc $INITDEFAULT"
- if [ -x $__DEFAULT_VSERVERDIR/$1/etc/init.d/rc ] ; then
- STARTCMD="/etc/init.d/rc $INITDEFAULT"
- elif [ -x $__DEFAULT_VSERVERDIR/$1/usr/bin/emerge ] ; then
- STARTCMD="/sbin/rc default"
- elif [ -x $__DEFAULT_VSERVERDIR/$1/etc/rc.d/rc.M ] ; then
- STARTCMD="/etc/rc.d/rc.M"
- fi
-
- DISCONNECT=
- FAKEINIT=
- for f in $S_FLAGS dummy
- do
- case $f in
- dummy)
- ;;
-
- minit)
- FAKEINIT=true
- FLAGS="$FLAGS --flag fakeinit"
- STARTCMD=/sbin/minit-start
- DISCONNECT=--disconnect
- ;;
-
- fakeinit)
- FAKEINIT=true
- FLAGS="$FLAGS --flag $f"
- STARTCMD=/sbin/init
- DISCONNECT=--disconnect
- ;;
- *)
- FLAGS="$FLAGS --flag $f"
- ;;
- esac
- done
- if [ "$FAKEINIT" = "" ] ; then
- $USR_LIB_VSERVER/fakerunlevel $INITDEFAULT var/run/utmp
- fi
-
- calculateCaps $S_CAPS
-
- if [ "$S_CONTEXT" != "" ] ; then
- CTXOPT="--ctx $S_CONTEXT"
- fi
- if [ "$S_HOSTNAME" != "" ] ; then
- HOSTOPT="--hostname $S_HOSTNAME"
- export HOSTNAME=$S_HOSTNAME
- fi
- if [ "$S_DOMAINNAME" != "" ] ; then
- DOMAINOPT="--domainname $S_DOMAINNAME"
- fi
- if [ "$S_NICE" != "" ] ; then
- NICECMD="nice -$S_NICE"
- fi
- mkdir -p $__PKGSTATEDIR
- chmod 700 $__PKGSTATEDIR
- setdefulimit
- if [ "$ULIMIT" != "" ] ; then
- ulimit $ULIMIT
- fi
- #echo FLAGS=$FLAGS
- #echo CAPS=$CAPS
- # We switch to /vservers/$1 now, because after the
- # security context switch /vservers directory becomes a dead zone.
- cd $__DEFAULT_VSERVERDIR/$1
- IPOPT=`setipopt $IPROOT`
- export PATH=$DEFAULTPATH
- $NICECMD $_CHBIND $SILENT $IPOPT --bcast $IPROOTBCAST \
- $_CHCONTEXT_COMPAT $SILENT $DISCONNECT $CAPS $FLAGS $CTXOPT $HOSTOPT $DOMAINOPT --secure \
- $_SAVE_S_CONTEXT $__PKGSTATEDIR/$1.ctx \
- $_CAPCHROOT $CHROOTOPT . $STARTCMD
- sleep 2
- test ! -x $__CONFDIR/$1.sh || $__CONFDIR/$1.sh post-start $1
- fi
-elif [ "$2" = "running" ] ; then
- if [ ! -f $__PKGSTATEDIR/$1.ctx ] ; then
- echo Server $1 is not running
- exit 1
- else
- . $__PKGSTATEDIR/$1.ctx
- NB=$($USR_SBIN/vps ax | awk '{print $2}' | grep \^$S_CONTEXT\$ | wc -l)
- #NB=`$_CHCONTEXT_COMPAT --silent --ctx $S_CONTEXT ps ax | wc -l`
- #NB=`eval expr $NB + 0`
- if [ "$NB" -gt 0 ] ; then
- echo Server $1 is running
- exit 0
- else
- echo Server $1 is not running
- exit 1
- fi
- fi
-elif [ "$2" = "status" ] ; then
- if $0 $1 running
- then
- . $__PKGSTATEDIR/$1.ctx
- NB=$($USR_SBIN/vps ax | awk '{print $2}' | grep \^$S_CONTEXT\$ | wc -l)
- echo $NB processes running
- echo Vserver uptime: `$USR_LIB_VSERVER/filetime $__PKGSTATEDIR/$1.ctx`
- fi
-elif [ "$2" = "stop" ] ; then
- echo Stopping the virtual server $1
- IPROOT=
- IPROOTMASK=
- IPROOTBCAST=
- IPROOTDEV=
- CAPS=
- IS_MINIT=
- readlastconf $1
- if $0 $1 running
- then
- test -x $__CONFDIR/$1.sh && $__CONFDIR/$1.sh pre-stop $1
- ifconfig_iproot $1
- cd $__DEFAULT_VSERVERDIR/$1
- mountproc $__DEFAULT_VSERVERDIR/$1
- # The fakeinit flag tell us how to turn off the server
- get_initdefault $1
- export PREVLEVEL=$INITDEFAULT
- STOPCMD="/etc/rc.d/rc 6"
- if [ -x $__DEFAULT_VSERVERDIR/$1/etc/init.d/rc ] ; then
- STOPCMD="/etc/init.d/rc 6"
- elif [ -x $__DEFAULT_VSERVERDIR/$1/usr/bin/emerge ] ; then
- STOPCMD="/sbin/rc shutdown"
- elif [ -x $__DEFAULT_VSERVERDIR/$1/etc/rc.d/rc.6 ] ; then
- STOPCMD="/etc/rc.d/rc.6"
- fi
-
- for f in $S_FLAGS dummy
- do
- case $f in
- minit)
- IS_MINIT=1
- FLAGS="$FLAGS --flag fakeinit"
- STOPCMD="/sbin/minit-stop"
- ;;
-
- fakeinit)
- FLAGS="$FLAGS --flag $f"
- STOPCMD="/sbin/init 6"
- ;;
- *)
- ;;
- esac
- done
-
- calculateCaps $S_CAPS
-
- cd $__DEFAULT_VSERVERDIR/$1
- IPOPT=`setipopt $IPROOT`
- export PATH=$DEFAULTPATH
- $_CHBIND $SILENT $IPOPT --bcast $IPROOTBCAST \
- $_CHCONTEXT_COMPAT $SILENT $CAPS --secure --ctx $S_CONTEXT \
- $_CAPCHROOT . $STOPCMD
-
- if test "$IS_MINIT"; then
- echo "Waiting for minit finish-signal"
- dd if=var/run/minit-stop of=/dev/zero bs=1 count=1 &>/dev/null
- sleep 1
- else
- echo sleeping 5 seconds
- sleep 5
- fi
-
- echo Killing all processes
- $_CHBIND --silent $IPOPT --bcast $IPROOTBCAST \
- $_CHCONTEXT_COMPAT $CAPS --secure --silent --ctx $S_CONTEXT \
- $_VSERVERKILLALL
- fi
- # We umount anyway, because "enter" establish the mount
- # but when you exit, the server is considered not running
- umountproc $__DEFAULT_VSERVERDIR/$1
- cd /
- test -x $__CONFDIR/$1.sh && $__CONFDIR/$1.sh post-stop $1
- ifconfig_iproot_off $1
-elif [ "$2" = "restart" ] ; then
- if $0 $1 running
- then
- $0 $1 stop
- $0 $1 start
- fi
-elif [ "$2" = "suexec" ] ; then
- if [ -z "$3" ] ; then
- echo "Missing user!" >&2
- echo "vserver vserver-name suexec user command [ args ... ]" >&2
- exit 1
- elif [ -z "$4" ] ; then
- echo "Missing command and arguments!" >&2
- echo "vserver vserver-name suexec user command [ args ... ]" >&2
- exit 1
- else
- IPROOT=
- IPROOTMASK=
- IPROOTBCAST=
- IPROOTDEV=
- readlastconf $1
- . $__CONFDIR/$1.conf
- cd $__DEFAULT_VSERVERDIR/$1
- ifconfig_iproot $1
- mountproc $__DEFAULT_VSERVERDIR/$1
- PS1="[\u@vserver:$1 \W]"
- export PS1
- VSERVER=$1
- USERID=$3
- shift; shift; shift
- CAPS=
- for f in $S_CAPS dummy
- do
- case $f in
- dummy)
- ;;
- !CAP_SYS_CHROOT)
- CHROOTOPT=--nochroot
- ;;
- *)
- CAPS="$CAPS --cap $f"
- ;;
- esac
- done
- FLAGS=
- for f in $S_FLAGS dummy
- do
- case $f in
- minit)
- FLAGS="$FLAGS --flag fakeinit"
- ;;
-
- dummy)
- ;;
- *)
- FLAGS="$FLAGS --flag $f"
- ;;
- esac
- done
- setdefulimit
- if [ "$ULIMIT" != "" ] ; then
- ulimit $ULIMIT
- fi
- if $0 $VSERVER running >/dev/null
- then
- . $__PKGSTATEDIR/$VSERVER.ctx
- cd $__DEFAULT_VSERVERDIR/$VSERVER
- IPOPT=`setipopt $IPROOT`
- export PATH=$DEFAULTPATH
- exec $_CHBIND $SILENT $IPOPT --bcast $IPROOTBCAST \
- $_CHCONTEXT_COMPAT $SILENT $FLAGS $CAPS --secure --ctx $S_CONTEXT \
- $_CAPCHROOT --suid $USERID . "$@"
- else
- test -x $__CONFDIR/$1.sh && $__CONFDIR/$1.sh pre-start $1
- CTXOPT=
- HOSTOPT=
- DOMAINOPT=
- if [ "$S_CONTEXT" != "" ] ; then
- CTXOPT="--ctx $S_CONTEXT"
- fi
- if [ "$S_HOSTNAME" != "" ] ; then
- HOSTOPT="--hostname $S_HOSTNAME"
- export HOSTNAME=$S_HOSTNAME
- fi
- if [ "$S_DOMAINNAME" != "" ] ; then
- DOMAINOPT="--domainname $S_DOMAINNAME"
- fi
- mkdir -p $__PKGSTATEDIR
- cd $__DEFAULT_VSERVERDIR/$VSERVER
- IPOPT=`setipopt $IPROOT`
- export PATH=$DEFAULTPATH
- exec $_CHBIND $SILENT $IPOPT --bcast $IPROOTBCAST \
- $_CHCONTEXT_COMPAT $SILENT $FLAGS $CAPS --secure $CTXOPT $HOSTOPT $DOMAINOPT \
- $_SAVE_S_CONTEXT $__PKGSTATEDIR/$VSERVER.ctx \
- $_CAPCHROOT --suid $USERID $CHROOTOPT . "$@"
- fi
- fi
-elif [ "$2" = "exec" ] ; then
- VSERV=$1
- shift; shift
- exec $0 $NODEV $SILENT $VSERV suexec root "$@"
-elif [ "$2" = "enter" ] ; then
- testperm $1
- exec $0 $NODEV $SILENT $1 exec /bin/bash -login
-elif [ "$2" = "service" ] ; then
- VSERVER=$1
- shift
- shift
- exec $0 $NODEV $SILENT $VSERVER exec /sbin/service "$@"
-elif [ "$2" = "chkconfig" ] ; then
- VSERVER=$1
- shift
- shift
- if [ "$1" = "--level" ] ; then
- shift
- LEVELS=$1
- shift
- fi
- if [ $# != 2 -a ! -x $__DEFAULT_VSERVERDIR/$VSERVER/sbin/chkconfig ] ; then
- echo Invalid argument, expected vserver name chkconfig [ --level nnn ] service on\|off
- elif [ -x $__DEFAULT_VSERVERDIR/$VSERVER/sbin/chkconfig ] ; then
- exec $0 --silent $VSERVER exec /sbin/chkconfig "$@"
- elif [ -x $__DEFAULT_VSERVERDIR/$VSERVER/usr/sbin/update-rc.d ] ; then
- if [ "$2" = "on" -o "$2" = "start" ] ; then
- $0 --silent $VSERVER exec /usr/sbin/update-rc.d -f $1 remove >/dev/null
- exec $0 --silent $VSERVER exec /usr/sbin/update-rc.d $1 start 80 2 3 4 5 . stop 20 0 1 6 . >/dev/null
- elif [ "$2" = "off" -o "$2" = "stop" ] ; then
- $0 --silent $VSERVER exec /usr/sbin/update-rc.d -f $1 remove >/dev/null
- exec $0 --silent $VSERVER exec /usr/sbin/update-rc.d $1 stop 20 0 1 2 3 4 5 6 . >/dev/null
- else
- echo vserver chkconfig: Expecting on or off
- fi
- else
- echo chkconfig functionality is not available on this
- echo vserver distribution.
- echo Looked for /sbin/chkconfig and /usr/sbin/update-rc.d
- fi
-else
- echo Command unknown $2
- echo
- usage
-fi
-
+++ /dev/null
-#!/bin/sh
-
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on vserverkillall by Jacques Gelinas
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-# This script kills all process it can finds
-# Only useful if you are using a security context.
-# It does nothing in context 0
-USR_LIB_VSERVER=/usr/lib/util-vserver
-CTX=`grep ^s_context /proc/self/status | sed s/s_context:// | (read a b; echo $a)`
-CTX=`eval expr $CTX + 0`
-if [ "$CTX" = 0 ] ; then
- echo Running in security context 0, do nothing
-else
- cd /proc
- for SIG in -TERM -TERM -TERM -9
- do
- ONE=0
- for dir in *
- do
- case $dir in
- 1)
- ;;
- $$)
- ;;
- [1-9]*)
- ONE=1
- echo kill $SIG "`$USR_LIB_VSERVER/readlink /proc/$dir/exe`"[$dir]
- kill $SIG $dir
- ;;
- *)
- ;;
- esac
- done
- if [ "$ONE" = 0 ] ; then
- break
- fi
- sleep 1
- done
- # Kill the fakeinit process. It is shown as process one, but can't
- # be killed this way
- INITPID=`cat /proc/self/status | grep initpid: | (read a b; expr $b)`
- if [ "$INITPID" != "0" ] ; then
- echo kill init, pid $INITPID
- kill -9 $INITPID
- fi
-fi
-
-
+++ /dev/null
-#!/bin/bash
-# $Id$
-
-# Copyright (C) 2004 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
-. "$__PKGLIBDIR/vserver.functions"
-
-function showHelp()
-{
- echo \
-$"Usage: $0 --externalize|--internalize [-y] [--] <vserver-name>
-
-Report bugs to <$PACKAGE_BUGREPORT>."
- exit 0
-}
-
-function showVersion()
-{
- echo $"\
-vpkg $PACKAGE_VERSION -- shows information about packages in vservers
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2004 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit 0
-}
-
-function init()
-{
- if test -z "$WORKAROUND_106057"; then
- rpmdb_mntpoint=/dev
- else
- rpmdb_mntpoint=/.rpmdb
- fi
- pkgmgmt.initVariables
-}
-
-function _createDirs()
-{
- for i; do
- test -n "$i" || continue
- mkdir -p -m755 "$i"
- done
-}
-
-function _copySecure()
-{
- local chroot=$1
- local srcdir=$2
- local dstdir=$3
-
-
- ( cd "$srcdir" && tar chf - '.' ) | \
- ( cd "$chroot" && $_EXEC_CD "$dstdir" $_TAR xf - )
-}
-
-function _copySecureRev()
-{
- local chroot=$1
- local srcdir=$2
- local dstdir=$3
-
- ( cd "$chroot" && $_EXEC_CD "$srcdir" $_TAR cf - '.' ) | \
- ( cd "$dstdir" && tar xf - )
-}
-
-function _hashAuto()
-{
- local hash=$2
- local dir=$(dirname "$1")
- local file=$(basename "$1")
-
- $_EXEC_CD "$dir" "$(which test)" "$file" || return 0
-
- local tmp=$($_MKTEMP /tmp/apt.conf.XXXXXX)
- trap "$_RM -f $tmp" EXIT
-
- $_EXEC_CD "$dir" $_CAT "$file" | \
- $_SED -e "s|^\([^$hash].*@autogenerated@\)|$hash$hash\1|" >$tmp
-
- $_CAT $tmp | $_EXEC_CD "$dir" "$(which cmp)" -s - "$file" || \
- $_CHROOT_CAT "$1" <$tmp
-
- $_RM -f $tmp
-}
-
-function _unhashAuto()
-{
- test -e "$1" || return 0
-
- local hash=$2
- local tmp=$($_MKTEMP /tmp/apt.conf.XXXXXX)
- trap "$_RM -f $tmp" EXIT
-
- $_SED -e "s|^$hash$hash\(.*@autogenerated@\)|\1|" "$1" >$tmp
- $_CMP -s "$tmp" "$1" || \
- $_CAT "$tmp" >"$1"
-
- $_RM -f $tmp
-}
-
-function _mountFilesystemsInternal()
-{
- local fstab="$1"
- test -e "$fstab" || return 0
- shift
-
- pushd "$vdir" >/dev/null
- "$@" $_SECURE_MOUNT -n -a --chroot --fstab "$fstab"
- popd >/dev/null
-}
-
-function _mountFilesystems()
-{
- local cfgdir
- cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || {
- echo "Can not determine configuration directory for '$1'; ..." >&2
- return 1
- }
- test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
-
- _mountFilesystemsInternal "$cfgdir"/fstab $_CHBIND "${CHBIND_OPTS[@]}" || return 1
- _mountFilesystemsInternal "$cfgdir"/fstab.local $_CHBIND "${CHBIND_OPTS[@]}" || return 1
-}
-
-function _umountFilesystems()
-{
- local cfgdir
- cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || {
- echo "Can not determine configuration directory for '$1'; ..." >&2
- return 1
- }
- local vdir=$cfgdir/vdir
- local is_ok=1
- test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
-
- pushd "$vdir/" >/dev/null || return 1
- _umountVserverInternal "$cfgdir"/fstab.local || is_ok=
- _umountVserverInternal "$cfgdir"/fstab $_CHBIND "${CHBIND_OPTS[@]}" || is_ok=
- popd >/dev/null || return 1
-
- test -n "$is_ok"
-}
-
-function processVserver_RH()
-{
- local vserver=$1
- local is_internalize=$2
- local have_apt
- local cfgdir
- local i
-
- cfgdir=$($_VSERVER_INFO "$vserver" APPDIR pkgmgmt) || \
- cfgdir=$($_VSERVER_INFO "$vserver" APPDIR)/pkgmgmt
-
- ## Figure out the environment....
- have_apt=1
- pkgmgmt.isAptAvailable "$cfgdir" "$vdir" "$is_internalize" || have_apt=
-
- local APTETCDIR=
- local APTSTATEDIR=
- local APTCACHEDIR=
- local APTARCHIVDIR=
- local RPMETCDIR=
- local RPMSTATEDIR=
-
- ## Create directories and assign variables where configuration
- ## can/will be found on the host
- if test -n "$is_internalize"; then
- pushd "$vdir" >/dev/null
-
- test ! -L var/lib/rpm || {
- $_EXEC_CD /var/lib $_RM rpm &&
- $_EXEC_CD /var/lib $_MKDIR -m755 rpm &&
- $_EXEC_CD /var/lib $_CHOWN rpm:rpm rpm ||
- :
- } </dev/null 2>/dev/null
-
- for i in var/cache/apt/{,archives/{,partial},genpkglist,gensrclist} \
- var/state/{,apt/{,lists/{,partial}}} \
- etc/apt etc/rpm; do
- test -d "$i" ||
- $_EXEC_CD /$(dirname "$i") $_MKDIR -m755 $(basename "$i") || :
- done #2>/dev/null
-
- popd >/dev/null
-
- if test -n "$have_apt"; then
- findDir APTETCDIR "$cfgdir"/aptetc "$cfgdir"/base/apt/etc /etc/apt /
- fi
-
- findDir RPMETCDIR "$cfgdir"/rpmetc "$cfgdir"/base/rpm/etc /etc/rpm /
- findDir RPMSTATEDIR "$cfgdir"/rpmstate "$cfgdir"/base/rpm/state
- else
- mkdir -m755 -p "$cfgdir"
- local need_base=
-
- if test -n "$have_apt"; then
- findDir APTETCDIR "$cfgdir"/aptetc "$cfgdir"/base/apt/etc /
- findDir APTSTATEDIR "$cfgdir"/aptstate "$cfgdir"/base/apt/state /
- findDir APTCACHEDIR "$cfgdir"/aptcache "$cfgdir"/base/apt/cache /
- findDir APTARCHIVDIR "$cfgdir"/aptarchives "$cfgdir"/base/apt/archives /
-
- test "$APTETCDIR" != / || APTETCDIR=$cfgdir/base/apt/etc
- test "$APTSTATEDIR" != / || APTSTATEDIR=$cfgdir/base/apt/state
- test "$APTCACHEDIR" != / || APTCACHEDIR=$cfgdir/base/apt/cache
- test "$APTARCHIVDIR" != / || APTARCHIVDIR=$cfgdir/base/apt/archive
-
- test -d "$cfgdir"/aptetc -a -d "$cfgdir"/aptstate -a \
- -d "$cfgdir"/aptcache -a -d "$cfgdir"/aptarchives || need_base=1
- fi
-
- findDir RPMETCDIR "$cfgdir"/rpmetc "$cfgdir"/base/rpm/etc /
- findDir RPMSTATEDIR "$cfgdir"/rpmstate "$cfgdir"/base/rpm/state /
-
- test "$RPMETCDIR" != / || RPMETCDIR=$cfgdir/base/rpm/etc
- test "$RPMSTATEDIR" != / || RPMSTATEDIR=$cfgdir/base/rpm/state
-
- test -d "$cfgdir"/rpmetc -a -d "$cfgdir"/rpmstate || need_base=1
- test ! -e "$cfgdir"/base || need_base=
-
- test -z "$need_base" || ln -s "$PKGCFGDIR" "$cfgdir"/base
-
- mkdir -m755 -p "$PKGCFGDIR"
- _createDirs "$APTETCDIR" "$APTSTATEDIR" "$APTCACHEDIR" "$APTARCHIVDIR" \
- "$RPMETCDIR" "$RPMSTATEDIR"
- fi
-
- ## Copy the files...
- if test -n "$is_internalize"; then
- if test -n "$have_apt"; then
- _copySecure "$vdir" "$APTETCDIR" /etc/apt
- pushd "$vdir" >/dev/null
- _hashAuto /etc/apt/apt.conf '/'
- popd >/dev/null
- fi
-
- _copySecure "$vdir" "$RPMETCDIR" /etc/rpm
- _copySecure "$vdir" "$RPMSTATEDIR" /var/lib/rpm
-
- else
- if test -n "$have_apt"; then
- _copySecureRev "$vdir" /etc/apt "$APTETCDIR"
- _unhashAuto "$APTETCDIR"/apt.conf '/'
- fi
-
- _copySecureRev "$vdir" /etc/rpm "$RPMETCDIR"
- _copySecureRev "$vdir" /var/lib/rpm "$RPMSTATEDIR"
- fi
-
- ## Cleanups...
- if test -n "$is_internalize"; then
- :
- else
- tmpdir=$($_MKTEMPDIR /var/tmp/pgmgmt.XXXXXX)
- trap "$_RM -rf $tmpdir" EXIT
- pushd "$vdir" >/dev/null
- $_EXEC_CD /var/lib $_MV rpm $tmpdir/
- $_EXEC_CD /var/lib $_LN_S "$rpmdb_mntpoint" rpm
- $_RM -rf $tmpdir
- fi
-
- ## Finish it...
- if test -n "$is_internalize"; then
- $_TOUCH "$cfgdir"/internal
- else
- $_RM -f "$cfgdir"/internal
- fi
-}
-
-function processVserver_Debian()
-{
- local vserver=$1
- local is_internalize=$2
-
- if test -n "$is_internalize"; then
- echo $"Debian vservers should be internalized everytime; do not know how to handle '$vserver'" >&2
- else
- echo $"External packagemanagement is not supported for Debian vserver" >&2
- fi
-
- return 1
-}
-
-function processVserver()
-{
- local vserver=$1
- local is_external=
- local skip=1
- local vdir
-
- ! $_VSERVER_INFO -q "$vserver" RUNNING || {
- echo $"Can not operate on running vservers; please stop '$vserver' and retry again..."
- return 1
- } >&2
-
- vdir=$($_VSERVER_INFO "$vserver" VDIR) && test -d "$vdir" || {
- echo $"Vserver '$vserver' does not seem to exist; skipping it..."
- return 1
- } >&2
-
- pkgmgmt.isInternal "$vserver" || is_external=1
-
- case "$is_external"X"$IS_INTERNALIZE"X"$IS_EXTERNALIZE" in
- (*X1X1) echo $"Can not externalize and internalize at the same time";;
- (*XX) echo $"No operation specified; try '--help' for more information";;
- (1XX1) echo $"Vserver '$vserver' has already external packagemanagment; skipping it...";;
- (X1X) echo $"Vserver '$vserver' has already internal packagemanagment; skipping it...";;
- (*) skip=
- esac >&2
-
- test -z "$skip" || return 1
-
- local style
- _mountFilesystems "$vserver" || return 1
- pkgmgmt.guessStyle "$vserver" style || return 1
-
- case "$style" in
- (redhat|mandrake) processVserver_RH "$vserver" "$IS_INTERNALIZE";;
- (debian) processVserver_Debian "$vserver" "$IS_INTERNALIZE";;
- (*)
- echo $"Vserver style '$style' is not supported for packagemanagment" >&2
- return 1
- esac
-
- _umountFilesystems "$vserver" || return 1
-}
-
-tmp=$(getopt -o y --long debug,externalize,internalize,help,version -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-IS_EXTERNALIZE=
-IS_INTERNALIZE=
-IS_YES=
-
-while true; do
- case "$1" in
- (--help) showHelp $0;;
- (--version) showVersion;;
- (--debug) set -x;;
- (--externalize) IS_EXTERNALIZE=1;;
- (--internalize) IS_INTERNALIZE=1;;
- (-y) IS_YES=1;;
- (--) shift; break;;
- (*) echo $"vserver: internal error; arg=='$1'" >&2; exit 1;;
- esac
- shift
-done
-
-test -n "$1" || {
- echo $"No vserver specified; try '--help' for more information"
- exit 1
-} >&2
-
-
-set -e
-init
-
-ok=1
-passed=
-for i; do
- processVserver "$i" && passed=1 || ok=
-done
-
-test -z "$ok" || exit 0
-test -z "$passed" || exit 1
-exit 2
+++ /dev/null
-#! /bin/bash
-
-# Copyright (C) 2004 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.
-
-# Usage: start-vservers [-c <CFGDIR>] [-m <MARK>] [-j <NUM>] [--start|--stop|--status|--condrestart|--restart] [--test] [--all] [--debug] -- <name>+
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-### Some local functions
-
-function showHelp()
-{
- echo \
-$"Usage: $(basename $0) [-c <CFGDIR>] [-m <MARK>] [-j <NUM] [--test]
- [--start|--stop] [--all] -- <name>+
-
-Please report bugs to $PACKAGE_BUGREPORT"
- exit 0
-}
-
-
-function showVersion()
-{
- echo \
-$"start-vserver $PACKAGE_VERSION -- starts/stops a bunch of vservers
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2004 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit 0
-}
-
-function verifyVserver()
-{
- true
-}
-
-###
-
-set +e
-
-
-tmp=$(getopt -o c:j:m: --long debug,help,version,start,stop,test,all -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-declare -r TAB=$(echo -en "\t")
-OPTION_MARK=
-OPTION_ALL=
-OPTION_PARALLEL=99
-OPTION_DEBUG=
-NOOPTION_DEBUG=1
-
-case "`basename $0`" in
- start-*) OPTION_FLAVOR=start;;
- stop-*) OPTION_FLAVOR=stop;;
- *) OPTION_FLAVOR=;;
-esac
-
-while true; do
- case "$1" in
- --help) showHelp $0 ;;
- --version) showVersion $0 ;;
- -c) CONFDIR=$2; shift;;
- -m) OPTION_MARK=$2; shift;;
- -j) OPTION_PARALLEL=$2; shift;;
- --start) OPTION_FLAVOR=start;;
- --stop) OPTION_FLAVOR=stop;;
- --all) OPTION_ALL=1;;
- --debug) OPTION_DEBUG=1; NOOPTION_DEBUG=; set -x;;
- --) shift; break;;
- *) echo $"$0: internal error; arg=='$1'" >&2; exit 1;;
- esac
- shift
-done
-
-test -n "$OPTION_FLAVOR" || {
- echo "$0: unknown invocation method; aborting..." >&2
- exit 1
-}
-
-vservers=( "$@" )
-test -z "$OPTION_ALL" || getAllVservers vservers
-
-orig_vservers=$vservers
-i=${#vservers[*]}
-
-while test $i -gt 0; do
- let --i
- d=$__CONFDIR/${vservers[$i]}/apps/init
- f=$d/mark
- { test -n "$OPTION_MARK" -a -r "$f" && grep -qx "$OPTION_MARK" "$f"; } || \
- { test -z "$OPTION_MARK" && test ! -e "$f"; } || \
- unset vservers[$i]
-done
-
-makedir=$($_MKTEMPDIR /tmp/vserver-init.XXXXXX)
-okfile=$($_MKTEMP /tmp/vserver-init.XXXXXX)
-passedfile=$($_MKTEMP /tmp/vserver-init.XXXXXX)
-trap "$_RM -rf $makedir $resultfile $passedfile" EXIT
-
-test_cmd=false
-case "$OPTION_FLAVOR" in
- start) test_cmd="${_VSERVER} --silent '\$*' status";;
- stop) test_cmd="! ${_VSERVER} --silent '\$*' status";;
-esac
-
-{
- cat <<EOF
-.%.stamp:
-${TAB}$test_cmd || { \
-${TAB}echo -n '.' >>$passedfile ; \
-${TAB}$_VSERVER --defaulttty --sync ${OPTION_DEBUG:+--debug} "\$*" ${OPTION_FLAVOR}; }
-${TAB}echo -n '.' >>$okfile
-${TAB}@touch "\$@"
-EOF
-
- echo -ne "all:\t"
- for i in "${vservers[@]}"; do
- echo -n ".$i.stamp "
- done
- echo
-} >$makedir/Makefile
-
-for i in "${vservers[@]}"; do
- d="$__CONFDIR/$i"/apps/init
- echo "$i"
- test -e "$d"/depends || continue
- cat "$d"/depends
-done | sort -u | while read vserver; do
- d="$__CONFDIR/$vserver"/apps/init
-
- case "$OPTION_FLAVOR" in
- start)
- if test -e "$d"/depends; then
- echo -ne ".$vserver.stamp:\t"
- cat "$d"/depends | while read dep; do
- verifyVserver "$dep"
- echo -n ".$dep.stamp "
- done
- echo
- fi >>$makedir/Makefile
- ;;
- stop)
- if test -e "$d"/depends; then
- cat "$d"/depends | while read dep; do
- verifyVserver "$dep"
- echo -ne ".$dep.stamp:\t.$vserver.stamp"
- done
- echo
- fi >>$makedir/Makefile
- esac
-done
-
-#cat $makedir/Makefile
-make -k ${NOOPTION_DEBUG:+-s} ${OPTION_PARALLEL:+-j$OPTION_PARALLEL} -C $makedir
-
-test -s "$passedfile" || exit 0
-test -s "$okfile" || exit 1
-$_CMP -s "$passedfile" "$okfile" || exit 2
-exit 0
+++ /dev/null
-# $Id$ --*- sh -*--
-
-PACKAGE='@PACKAGE@'
-PACKAGE_BUGREPORT='@PACKAGE_BUGREPORT@'
-PACKAGE_NAME='@PACKAGE_NAME@'
-PACKAGE_STRING='@PACKAGE_STRING@'
-PACKAGE_TARNAME='@PACKAGE_TARNAME@'
-PACKAGE_VERSION='@PACKAGE_VERSION@'
-
-__CONFDIR='@CONFDIR@'
-__INCLUDEDIR='@INCLUDEDIR@'
-__INITRDDIR='@INITRDDIR@'
-__LEGACYDIR="@LEGACYDIR@"
-__LIBDIR='@LIBDIR@'
-__LOCKDIR="/var/lock"
-__PKGLIBDIR='@PKGLIBDIR@'
-__PKGSTATEDIR="@PKGSTATEDIR@"
-__PKGSTATEREVDIR="@PKGSTATEREVDIR@"
-__SBINDIR='@SBINDIR@'
-__SYSCONFDIR='@SYSCONFDIR@'
-__VSHELPERSTATEDIR="@VSHELPERSTATEDIR@"
-
-__DISTRIBDIR="$__PKGLIBDIR/distributions"
-__PKGLIBDEFAULTDIR="$__PKGLIBDIR/defaults"
-__RUNDIR="$__PKGSTATEDIR"
-
-__DEFAULT_VSERVERDIR='@VSERVERDIR@'
-__DEFAULT_VSERVERPKGDIR='@VSERVERPKGDIR@'
-
-_CAPCHROOT="$__PKGLIBDIR/capchroot"
-_CHAINECHO="$__PKGLIBDIR/chain-echo"
-_CHBIND="$__SBINDIR/chbind"
-_CHCONTEXT="$__SBINDIR/chcontext"
-_CHCONTEXT_COMPAT="$__PKGLIBDIR/chcontext-compat"
-_CHECK_UNIXFILE="$__PKGLIBDIR/check-unixfile"
-_CHROOT_CAT="$__PKGLIBDIR/chroot-cat"
-_CHROOT_RM="$__PKGLIBDIR/chroot-rm"
-_EXEC_CD="$__SBINDIR/exec-cd"
-_EXEC_ULIMIT="$__PKGLIBDIR/exec-ulimit"
-_FAKE_RUNLEVEL="$__PKGLIBDIR/fakerunlevel"
-_FILETIME="$__PKGLIBDIR/filetime"
-_IFSPEC="$__LEGACYDIR/ifspec"
-_INITSYNC_MINIT_START=:
-_KEEP_CTX_ALIVE="$__PKGLIBDIR/keep-ctx-alive"
-_LIB_FUNCTIONS="$__PKGLIBDIR/functions"
-_LIB_VSERVER_SETUP_FUNCTIONS="$__PKGLIBDIR/vserver-setup.functions"
-_LIB_VSERVER_BUILD_FUNCTIONS="$__PKGLIBDIR/vserver-build.functions"
-_LIB_VSERVER_BUILD_FUNCTIONS_APT="$__PKGLIBDIR/vserver-build.functions.apt"
-_LIB_VSERVER_BUILD_FUNCTIONS_RPM="$__PKGLIBDIR/vserver-build.functions.rpm"
-_LIB_VSERVER_BUILD_FUNCTIONS_YUM="$__PKGLIBDIR/vserver-build.functions.yum"
-_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT="$__PKGLIBDIR/vserver-build.functions.pkgmgmt"
-_LISTDEVIP="$__LEGACYDIR/listdevip"
-_LOCKFILE="$__PKGLIBDIR/lockfile"
-_MASK2PREFIX="$__PKGLIBDIR/mask2prefix"
-_PARSERPMDUMP="$__LEGACYDIR/parserpmdump"
-_PKGMGMT="$__PKGLIBDIR/pkgmgmt"
-_READLINK="$__PKGLIBDIR/readlink"
-_REBOOTMGR="$__LEGACYDIR/rebootmgr"
-_RPM_FAKE_SO="$__PKGLIBDIR/rpm-fake.so"
-_SAVE_S_CONTEXT="$__LEGACYDIR/save_s_context"
-_SAVE_CTXINFO="$__PKGLIBDIR/save_ctxinfo"
-_SECURE_MOUNT="$__PKGLIBDIR/secure-mount"
-_SETATTR="$__SBINDIR/setattr"
-_SHOWPERM="$__LEGACYDIR/showperm"
-_START_VSERVERS="$__PKGLIBDIR/start-vservers"
-_VAPT_GET="$__SBINDIR/vapt-get"
-_VAPT_GET_WORKER="$__PKGLIBDIR/vapt-get-worker"
-_VATTRIBUTE="$__SBINDIR/vattribute"
-_VCONTEXT="$__SBINDIR/vcontext"
-_VHASHIFY="$__PKGLIBDIR/vhashify"
-_VKILL="$__SBINDIR/vkill"
-_VLIMIT="$__SBINDIR/vlimit"
-_VNAMESPACE="$__SBINDIR/vnamespace"
-_VPKG="$__PKGLIBDIR/vpkg"
-_VPROCUNHIDE="$__PKGLIBDIR/vprocunhide"
-_VPS="$__SBINDIR/vps"
-_VREBOOT="$__LEGACYDIR/vreboot"
-_VRPM="$__SBINDIR/vrpm"
-_VRPM_PRELOAD="$__PKGLIBDIR/vrpm-preload"
-_VRPM_WORKER="$__PKGLIBDIR/vrpm-worker"
-_VSCHED="$__SBINDIR/vsched"
-_VSERVER="$__SBINDIR/vserver"
-_VSERVER_LEGACY="$__LEGACYDIR/vserver"
-_VSERVER_BUILD="$__PKGLIBDIR/vserver-build"
-_VSERVER_INFO="$__SBINDIR/vserver-info"
-_VSERVERKILLALL="$__LEGACYDIR/vserverkillall"
-_VSHELPER="$__PKGLIBDIR/vshelper"
-_VSHELPER_SYNC="$__PKGLIBDIR/vshelper-sync"
-_VSOMETHING="$__SBINDIR/vsomething"
-_VUNAME="$__SBINDIR/vuname"
-_VUNIFY="$__PKGLIBDIR/vunify"
-_VYUM="$__SBINDIR/vyum"
-_VYUM_WORKER="$__PKGLIBDIR/vyum-worker"
-
-_AWK="@AWK@"
-_CAT="@CAT@"
-_CHOWN="@CHOWN@"
-_CMP="@CMP@"
-_CP="@CP@"
-_DIRNAME="@DIRNAME@"
-_EGREP="@EGREP@"
-_ENV="@ENV@"
-_GREP="@GREP@"
-_IP="@IP@"
-_IPTABLES="@IPTABLES@"
-_LN="@LN@"
-_LN_S="$_LN -s"
-_MKDIR="@MKDIR@"
-_MKFIFO="@MKFIFO@"
-_MKTEMP="@MKTEMP@"
-_MKTEMPDIR="$_MKTEMP -d"
-_MODPROBE="@MODPROBE@"
-_MOUNT="@MOUNT@"
-_MV="@MV@"
-_NAMEIF="@NAMEIF@"
-_NICE="@NICE@"
-_RM="@RM@"
-_RMDIR="@RMDIR@"
-_RMMOD="@RMMOD@"
-_SED="@SED@"
-_SH="@SH@"
-_TAC="@TAC@"
-_TAR="@TAR@"
-_TOUCH="@TOUCH@"
-_TTY="@TTY@"
-_UMOUNT="@UMOUNT@"
-_VCONFIG="@VCONFIG@"
-_WC="@WC@"
-_WGET="@WGET@"
-
-# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=106057
-WORKAROUND_106057=1
-# /var/lib/rpm is hardcoded into apt-get which does not honor the
-# %_dbpath variable therefore
-# http://distro2.conectiva.com.br/pipermail/apt-rpm/2003-October/001985.html
-WORKAROUND_APT_DBPATH=1
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-
-function showHelp()
-{
- echo \
-$"Usage: $0 <vserver-name>* [--all] -- <params>+
-
-Report bugs to <$PACKAGE_BUGREPORT>."
- exit $1
-}
-
-function showVersion()
-{
- echo \
-$"vapt-get $PACKAGE_VERSION -- apt-get for vservers
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2003 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit $1
-}
-
-is_quiet=
-declare -a vservers=()
-
-while test "$#" -ge 1; do
- case "$1" in
- --) shift; break;;
- --help) showHelp 0;;
- --quiet|-q) is_quiet=1 ;;
- --all)
- getAllVservers tmp
- vservers=( "${vservers[@]}" "${tmp[@]}" )
- ;;
- --version)
- showVersion 0;;
- *) vservers=( "${vservers[@]}" "$1" )
- esac
- shift
-done
-
-test "$#" -ge 1 || showHelp 1 >&2
-test "${#vservers[@]}" -ne 1 || is_quiet=1
-
-cnt=0
-res=255
-for i in "${vservers[@]}"; do
- cnt=$[ cnt + 1 ]
-
- test -n "$is_quiet" || {
- colorize bold echo -n "vaptget: operating on vserver "
- colorize bold colorize emph echo "$i"
- xtermTitle "vaptget: operating on vserver '$i' [$cnt/${#vservers[@]}]"
- }
-
- if pkgmgmt.isInternal "$i"; then
- $_VSERVER "$i" exec apt-get "$@"
- else
- callInNamespace "$i" \
- "$_VNAMESPACE" --new -- "$_VAPT_GET_WORKER" "$i" "$@"
- fi
- res=$?
-
- test $res -eq 0 -o -n "$is_quiet" || {
- colorize error echo -n $"vapt-get failed on vserver '$i' with errorcode $res"
- echo
- }
-
- test -n "$is_quiet" || echo
-done
-
-test "$cnt" -ge 0 || echo "No vservers specified" >&2
-exit $res
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# 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.
-
-set -e
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-
-function createAptFileSys()
-{
- mkdir -p /var/state/apt/lists/partial
- mkdir -p /var/cache/apt/archives/partial
-}
-
-vserver="$1"
-shift
-
-pkgInit "$vserver" rpm apt
-
-createAptFileSys
-
-test -z "$_APT_GET" || {
- warning $"The environment variable \$_APT_GET is not supported anymore; please use \$APT_GET instead of"
- ${APT_GET:=$_APT_GET}
-}
-
-exec ${_APT_GET:-apt-get} \
- -o "RPM::RootDir=$VDIR" \
- -o "Dir=$VDIR" \
- -o "Dir::State=$APTSTATEDIR" \
- -o "Dir::Cache=$APTCACHEDIR" \
- -o "Dir::Cache::archives=$APTARCHIVDIR" \
- -o "Dir::Bin::rpm=$RPM_BINARY" \
- -o "Dir::Etc=$APTETCDIR" \
- -o "RPM::Order=true" \
- -o "RPM::PM=external" \
- "$@"
+++ /dev/null
-#!/bin/bash
-# $Id$
-
-# Copyright (C) 2004 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-function showHelp()
-{
- echo \
-$"Usage: $0 <vserver-name> <tag>
-
-Report bugs to <$PACKAGE_BUGREPORT>."
- exit 0
-}
-
-function showVersion()
-{
- echo $"\
-vpkg $PACKAGE_VERSION -- shows information about packages in vservers
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2004 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit 0
-}
-
-
-case "$1" in
- (--help) showHelp $(basename $0);;
- (--version) showVersion ;;
-esac
-
-test "$1" -a "$2" || {
- echo $"No vserver and/or tag given; use '--help' for more information" >&2
- exit 1
-}
-
-vserver=$1
-tag=$2
-shift 2
-
-case "$tag" in
- get-conffiles|install) ;;
- *) echo $"Unsupport tag '$tag'" >&2; exit 1;;
-esac
-
-cfgdir=$($_VSERVER_INFO "$vserver" APPDIR pkgmgmt) || :
-vdir=$($_VSERVER_INFO "$1" VDIR) || :
-
-style=
-is_external=
-pkgmgmt.guessStyle "$vserver" style || exit 2
-pkgmgmt.isInternal "$vserver" || is_external=1
-
-cmd=()
-
-case "$style" in
- (redhat|mandrake)
- rpm_param=
- apt_param=
- case "$tag" in
- ## rpm outputs sometimes '(contains no files)', so return
- ## only the valid output
- (get-conffiles)
- rpm_param=( -qac --pipe "$_SED '\!^/!p;d'" );;
- (install)
- rpm_param=( -Uvh "$@" )
- apt_param=( install "$@" )
- ;;
- esac
-
- if test -n "$is_external"; then
- have_apt=1
- test -d "$cfgdir"/base/apt -o -d "$cfgdir"/aptetc || have_apt=
- else
- have_apt=
- for i in /bin /usr/bin /usr/local/bin; do
- test ! -x "$vdir$i"/apt-get || { have_apt=1; break; }
- done
- fi
-
- if test -n "$is_external"; then
- if test "$have_apt" -a "$apt_param"; then
- cmd=( "$_VAPT_GET" "$vserver" -- "${apt_param[@]}" )
- else
- cmd=( "$_VRPM" "$vserver" -- "${rpm_param[@]}" )
- fi
- else
- if test "$have_apt" -a "$apt_param"; then
- cmd=( "$_VSERVER" --silent "$vserver" exec apt-get "${apt_param[@]}" )
- else
- cmd=( "$_VSERVER" --silent "$vserver" exec rpm "${rpm_param[@]}" )
- fi
- fi
- ;;
- (debian)
- case "$tag" in
- (get-conffiles)
- cmd=( sh -c "cat /var/lib/dpkg/info/*.conffiles 2>/dev/null" )
- ;;
- (install)
- cmd=( apt-get install "$@" )
- ;;
- esac
-
- if test -n "$is_external"; then
- echo $"'external' packagemanagement is not supported for Debian" >&2
- exit 1
- else
- cmd=( "$_VSERVER" --silent "$vserver" exec "${cmd[@]}" )
- fi
- ;;
- (*)
- echo $"Packagemanagement is not supported for '$style' style" >&2
- exit 2
- ;;
-esac
-
-export LANG=C
-exec "${cmd[@]}"
+++ /dev/null
-#!/bin/bash
-# $Id$
-#
-# Copyright (C) 2004 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.
-
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-function showHelp()
-{
- echo $\
-"Usage: vprocunhide
-
-Return values:
- 0 ... no errors
- 1 ... configuration error
- 2 ... some files were changed but errors occured on other ones
- 3 ... operation failed on every file
-
-Report bugs to <$PACKAGE_BUGREPORT>."
- exit 0
-}
-
-function showVersion()
-{
- echo \
-$"vprocunhide $PACKAGE_VERSION -- unhides /proc entries
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2004 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit 0
-}
-
-
-while test -n "$1"; do
- case "$1" in
- --help) showHelp;;
- --version) showVersion;;
- esac
-done
-
-findFile UNHIDEFILE \
- "$__CONFDIR"/.defaults/apps/vprocunhide/files \
- "$__PKGLIBDEFAULTDIR"/vprocunhide-files
-
-ok=1
-passed=
-while read filename; do
- params=()
-
- case "$filename" in
- (\#*) continue;;
- (-*) params=( --admin --hide ); filename=${filename#-};;
- (~*) params=( --admin --watch --hide ); filename=${filename#~};;
- (:*) params=( --watch --hide ); filename=${filename#:};;
- (!*) params=( --hide ); filename=${filename#!};;
- (+*) params=( --!hide ); filename=${filename#+};;
- (*) params=( --!hide );;
- esac
-
- case "$filename" in
- (*/) params=( "${params[@]}" -R );;
- (*) ;;
- esac
-
- set -- $filename
- test -e "$1" || continue
-
- $_SETATTR -x "${params[@]}" "$@" && passed=1 || ok=
-done <"$UNHIDEFILE"
-
-test -n "$ok" && exit 0 || \
-test -n "$passed" && exit 2 || \
-exit 3
+++ /dev/null
-#!/bin/sh
-
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on vpstree by Jacques Gelinas
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-#Presents the processes running in all virtual servers
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-exec $__SBINDIR/chcontext --silent --ctx 1 pstree "$@"
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-function showHelp()
-{
- echo \
-$"Usage: $0 <vserver-name>* [--all] [--quiet|-q] [--help] [--version] [--unify] -- <rpm-params>+
-
-Report bugs to <$PACKAGE_BUGREPORT>."
-
- exit $1
-}
-
-function showVersion()
-{
- echo \
-$"vrpm $PACKAGE_VERSION -- rpm for vservers
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2003 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
-
- exit $1
-}
-
-do_unify=
-is_quiet=
-declare -a vservers=()
-
-while test "$#" -ge 1; do
- case "$1" in
- --quiet|-q)
- is_quiet=1
- ;;
- --all)
- getAllVservers tmp
- vservers=( "${vservers[@]}" "${tmp[@]}" )
- ;;
- --unify)
- do_unify=1
- ;;
- --)
- shift; break;;
- --help)
- showHelp 0;;
- --version)
- showVersion 0;;
- *) vservers=( "${vservers[@]}" "$1" )
- esac
- shift
-done
-
-test "$#" -ge 1 || showHelp 1 >&2
-test "${#vservers[@]}" -ne 1 || is_quiet=1
-
-cnt=0
-res=255
-
-for i in "${vservers[@]}"; do
- cnt=$[ cnt + 1 ]
-
- test -n "$is_quiet" || {
- colorize bold echo -n "vrpm: operating on vserver "
- colorize bold colorize emph echo "$i"
- xtermTitle "vrpm: operating on vserver '$i' [$cnt/${#vservers[@]}]"
- }
-
- if pkgmgmt.isInternal "$i"; then
- $_VSERVER "$i" exec rpm "$@"
- else
- callInNamespace "$i" \
- "$_VNAMESPACE" --new -- "$_VRPM_WORKER" "$i" "$@"
- fi
- res=$?
-
- test $res -eq 0 -o "$is_quiet" || {
- colorize error echo -n $"vrpm failed on vserver '$i' with errorcode $res"
- echo
- }
-
- test -n "$is_quiet" || echo
-done
-
-test -z "$do_unify" || echo "unify currently unsupported" >&2
-test "$cnt" -ge 0 || echo "No vservers specified" >&2
-exit $res
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# 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.
-
-set -e
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-for bin in `which rpm` /bin/rpm /usr/lib/rpm/rpm${RPM_FLAVOR:-i} ""; do
- ldd "$bin" &>/dev/null && break
-done
-
-test -x "$bin" ||
- panic $"No dynamically linked rpm binary found; exiting..."
-
-rpmFake.init "$CUR_VSERVER"
-rpmFake.exec "$bin" "$@"
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# 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.
-
-set -e
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-vserver=$1
-shift
-
-pkgInit "$vserver" rpm
-
-exec $RPM_BINARY --root "$VDIR" "$@"
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# 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.
-
-# set -e
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-### Some local functions
-
-function showHelp()
-{
- echo \
-$"Usage: $(basename $0) [-s|--sync] [-v|--verbose] [--silent]
- [--] <vserver> <command> <args>*
-
-<vserver> is the name of a vserver.
-
-Possible commands are:
- start [--nodeps] <start-vservers-opts>*
- ... starts the specified vserver
- stop [--nodeps] <start-vservers-opts>*
- ... stops the specified vserver
- restart ... restarts the specified vserver; this is the subsequent
- execution of a synchronized 'stop' and a 'start'
- condrestart ... restarts the vserver when it is running already
- suexec <user> <shell-command> <args*>
- ... executes a command as the specified user in the vserver
- exec <shell-command> <args*>
- ... executes a command as root in the vserver
- enter ... executes the configured shell in the vserver
- chkconfig <chkconfig-options*>
- ... modifies the init-system; currently, only Red Hat's
- chkconfig is supported
- running ... succeeds iff the vserver is running
- status ... gives out some human readable status information about
- the vserver, and succeeds iff the vserver is running
-
- build <buildopts>*
- ... builds a new vserver from scratch
-
- unify [-R]
- ... (de)unify vserver
-
- pkg install <pkg>
- ... installs package(s) in the vserver
-
- apt-get,apt-config,apt-cache <apt-opts>*
- ... execute the apt-* command for the given vserver
- rpm <rpm-opts>*
- ... execute the rpm command for the given vserver
-
- pkgmgmt externalize|internalize [-y]
- ... externalize or internalize the package-management for the
- given vserver. 'Externalize' means that package metadata
- and management tools (apt-get,rpm) are living in the host,
- while 'internalize' means that data and programs from the
- vserver will be used.
-
- unify <vunify-opts>*
- ... unify the vserver with its reference vserver(s).
-
-
-Please report bugs to $PACKAGE_BUGREPORT"
- exit 0
-}
-
-function showVersion()
-{
- echo \
-$"vserver $PACKAGE_VERSION -- manages the state of vservers
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2003 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit 0
-}
-
-function suexec()
-{
- . $__PKGLIBDIR/vserver.suexec
-}
-
-function restart()
-{
- "${SELF[@]}" --sync "$vserver" stop
- exec "${SELF[@]}" "$vserver" start
-}
-
-function msg()
-{
- test -z "$OPTION_SILENT" || return 0
- echo "$@"
-}
-
-### main starts here
-
-set +e
-
-OPTIONS_ORIG=( "$@" )
-tmp=$(getopt -o +sv --long nonamespace,--nonamespace,--insecure,defaulttty,help,debug,version,sync,verbose,silent -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-OPTION_FORCE_SYNC=
-OPTION_VERBOSE=
-OPTION_SILENT=
-OPTION_DEBUG=
-OPTION_NONAMESPACE=
-OPTION_INSECURE=
-OPTION_DEFAULTTTY=
-
-while true; do
- case "$1" in
- (--help) showHelp $0 ;;
- (--version) showVersion ;;
- (--debug) OPTION_DEBUG=$1; set -x;;
- (-v|--verbose) OPTION_VERBOSE=$1;;
- (-s|--sync) OPTION_FORCE_SYNC=$1;;
- (--silent) OPTION_SILENT=$1;;
- (----nonamespace)OPTION_NONAMESPACE=$1;;
- (--defaulttty) OPTION_DEFAULTTTY=$1;;
- (----insecure) OPTION_INSECURE=1;;
- (--) shift; break;;
- (*) echo $"vserver: internal error; arg=='$1'" >&2; exit 1;;
- esac
- shift
-done
-
-OPTION_ALL=( $OPTION_SILENT $OPTION_VERBOSE $OPTION_DEBUG $OPTION_DEFAULTTTY )
-SELF=( "$0" "${OPTION_ALL[@]}" )
-
-vserver=$1
-cmd=$2
-
-test "$cmd" != build || { shift 2; exec "$_VSERVER_BUILD" -n "$vserver" "$@"; }
-
-
-allow_legacy=
-
-case "$vserver" in
- (./*) VSERVER_DIR=`pwd`/$vserver;;
- (/*) VSERVER_DIR=$vserver;;
- (*) VSERVER_DIR=$__CONFDIR/$vserver
- allow_legacy=1
- ;;
-esac
-
-if test -n "$allow_legacy"; then
- do_legacy=
- test ! -e "$VSERVER_DIR/legacy" || do_legacy=1
- test -d "$VSERVER_DIR" -o ! -e "$__CONFDIR/$vserver.conf" || do_legacy=1
-
- test -z "$do_legacy" || {
- echo $"WARNING: can not find configuration, assuming legacy method" >&2
- exec "$_VSERVER_LEGACY" "$@"
- }
-fi
-
-test -d "$VSERVER_DIR" || {
- echo $"\
-Can not find a vserver-setup at '$VSERVER_DIR/'.
-
-Possible solutions:
-* fix the spelling of the '$vserver' vserver name
-* read 'vserver $vserver build --help' about ways to create a new vserver
-* see 'vserver --help' for the syntax of this command
-"
- exit 5
-} >&2
-
-if test -e "$VSERVER_DIR"/name; then
- read VSERVER_NAME <"$VSERVER_DIR"/name
-else
- VSERVER_NAME=$(basename "$VSERVER_DIR")
-fi
-
-test "$2" != start -o -n "$OPTION_NONAMESPACE" || isAvoidNamespace "$VSERVER_DIR" || \
- exec $_VNAMESPACE --new -- $_VSERVER ----nonamespace "${OPTIONS_ORIG[@]}"
-
-. $__PKGLIBDIR/vserver.functions
-case "$2" in
- (start|stop)
- shift 2
- . $__PKGLIBDIR/vserver.$cmd
- ;;
- (suexec|restart)
- shift 2
- $cmd "$@"
- ;;
- (condrestart)
- test ! isVserverRunning "$VSERVER_DIR" || restart
- ;;
- (exec)
- shift 2
- suexec root "$@"
- ;;
- (chkconfig)
- shift 2
- suexec root chkconfig "$@"
- ;;
- (enter)
- getEnterShell "$VSERVER_DIR"
- suexec root "${ENTER_SHELL[@]}"
- ;;
- (running)
- isVserverRunning "$VSERVER_DIR"
- ;;
-
- (unify)
- shift 2
- exec $_VUNIFY "$@" "$vserver"
- ;;
-
- (hashify)
- shift 2
- exec $_VHASHIFY "$@" "$vserver"
- ;;
-
- (pkg)
- shift 2
- exec $_VPKG "$vserver" "$@"
- ;;
-
- (pkgmgmt)
- op=$3
- shift 3
- exec $_VNAMESPACE --new -- $_PKGMGMT ${op:+--$op} "$@" -- "$vserver"
- ;;
-
- (apt-get|apt-config|apt-cache)
- export _APT_GET=$2
- shift 2
- exec $_VAPT_GET -- "$@"
- ;;
- (rpm)
- exec $_VRPM -- "$@"
- ;;
-
- (status)
- if getVserverStatus "$VSERVER_DIR" ctx procnum; then
- msg $"Vserver '$vserver' is running at context '$ctx'"
-
- if test "$2" = status; then
- msg $"Number of processes: " $procnum
- msg $"Uptime: " $("$_FILETIME" "$VSERVER_DIR/run")
- fi
- exit 0
- else
- msg $"Vserver '$vserver' is stopped"
- exit 3
- fi
- ;;
- (*)
- echo $"Usage: $0 {start|stop|suexec|restart|condrestart|exec|enter|chkconfig|running|status}" >&2
- exit 2
- ;;
-esac
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# Copyright (C) 2003,2004,2005 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-. "$_LIB_VSERVER_SETUP_FUNCTIONS"
-. "$_LIB_VSERVER_BUILD_FUNCTIONS"
-
-### Some local functions
-
-function showHelp()
-{
- echo \
-$"Usage: $(basename $0) -m <method> -n <name> --force <cfg-options>*
- --rootdir <dir> --pkgbase <dir> [--] <method-args>*
-
-Options:
- --force ... remove/rename already existing vservers with the same name
- -m <method> ... use method <method>; see below for possible values
- --rootdir <dir>
- ... [default: $__DEFAULT_VSERVERDIR]
- --pkgbase <dir>
- ... [default: $__DEFAULT_VSERVERPKGDIR]
-
-cfg-options are: $SETUP_HELPMSG
-
-Possible methods are:
- legacy ... the \"old\" copy-all-from-host method, which requires the
- old legacy vserver-legacy script; with this method the
- cfg-options will be ignored
- copy ... the copy-all-from-host method which uses the recent
- configuration scheme
- apt-rpm ... -- -d <distribution>
- ... installs the base-packages of the given distribution with
- help of 'vapt-get'
- yum ... -- -d <distribution>
- ... installs the base-packages of the given distribution with
- help of 'vyum'
- rpm ... -- [-d <distribution>] --empty|([--force] [--nodeps] <manifest>)+
- ... installs lists of rpm-packages
- skeleton ... -- [<cmd> <args>*]
- ... installs a minimal skeleton filesystem, creates the
- configuration file and calls an optional command then
- debootstrap ... -- -d <distribution> [-m <mirror>] [-- <debootstrap-options>*]
- bootstraps the vserver with Debian's 'debootstrap' package
-
-Please report bugs to $PACKAGE_BUGREPORT"
- exit 0
-}
-
-function showVersion()
-{
- echo \
-$"vserver-build $PACKAGE_VERSION -- initializes a vserver
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2003,2004,2005 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit 0
-}
-
-### main starts here
-
-set -e
-
-declare -a default_opts=()
-test -n "$NO_DEFAULT_OPTS" || getFileArray default_opts "$__CONFDIR/.defaults/apps/build/options" || :
-
-tmp=$(getopt -o +m:n: --long force,debug,help,version,rootdir:,pkgbase:,$SETUP_OPTIONS -n "$(basename $0)" -- \
- "${default_opts[@]}" "$@") || exit 1
-eval set -- "$tmp"
-
-VSERVER_NAME=
-OPTION_FORCE=
-OPTION_DEBUG=0
-
-while true; do
- case "$1" in
- (--help) showHelp $0 ;;
- (--version) showVersion ;;
- (--force) OPTION_FORCE=1;;
- (--debug) let ++OPTION_DEBUG; set -x;;
- (--rootdir) ROOTDIR=$2; shift;;
- (--pkgbase) PKGCFGBASE=$2; shift;;
- (-m) method=$2; shift;;
- (-n) VSERVER_NAME=$2; shift;;
- (--) shift; break;;
- (*)
- { setup_setOption2 "$1" "$2" && shift; } || \
- panic $"vserver-build: internal error."
- ;;
- esac
- shift
-done
-
-test -n "$VSERVER_NAME" ||
- panic $"Name of vserver not specified"
-
-setup_setDefaults "$VSERVER_NAME"
-
-case x"$method" in
- (xlegacy) exec $_VSERVER_LEGACY "$VSERVER_NAME" build "$@" ;;
- (xapt-rpm|xcopy|xskeleton|xdebootstrap|xyum|xrpm)
- . $__PKGLIBDIR/vserver-build.$method
- ;;
- (x) panic $"No build-method specified";;
- (*) panic $"Unknown build-method '$method'";;
-esac
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-tmp=$(getopt -o +d: --long debug -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_RPM"
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_APT"
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
-
-while true; do
- case "$1" in
- (-d) DISTRIBUTION=$2; shift;;
- (--debug) set -x;;
- (--) shift; break ;;
- (*) echo "vserver-build.apt-rpm: internal error: unrecognized option '$1'" >&2
- exit 1
- ;;
- esac
- shift
-done
-
-getDistribution
-
-base.initVariables
-pkgmgmt.initVariables
-rpm.initVariables
-apt.initVariables
-
-base.initFilesystem "$OPTION_FORCE"
-pkgmgmt.initFilesystem "$OPTION_FORCE"
-rpm.initFilesystem
-apt.initFilesystem
-
-setup_writeOption "$VSERVER_NAME"
-setup_writeInitialFstab
-
-test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
-rpm.initDB "$SETUP_CONFDIR"
-rpm.importGPGPubKeys "$SETUP_CONFDIR" \
- "$__CONFDIR/.distributions/$DISTRIBUTION/pubkeys" \
- "$__CONFDIR/.distributions/.common/pubkeys" \
- "$__DISTRIBDIR/$DISTRIBUTION/pubkeys"
-
-$_VAPT_GET "$SETUP_CONFDIR" -- update
-apt.installBasePackages "$SETUP_CONFDIR" "$PKGINSTALLDIR"
-$_VAPT_GET "$SETUP_CONFDIR" -- dist-upgrade -y
-$_VAPT_GET "$SETUP_CONFDIR" -- clean
-test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-function cleanUp
-{
- test ! -d "$workdir" || $_RM -rf "$workdir"
-}
-
-function init
-{
- workdir=
- mirror=
- trap "cleanUp" EXIT
-}
-
-function initVariables
-{
- base.initVariables
-
- test -n "${mirror-unset}" || {
- local aux
- findFile aux "$__CONFDIR"/.defaults/apps/debootstrap/mirror ''
- test -z "$aux" || read mirror <"$aux"
- }
-}
-
-function initFilesystem
-{
- base.initFilesystem "$1"
-
- mkdir -p "$SETUP_CONFDIR"/apps/pkgmgmt
- touch "$SETUP_CONFDIR"/apps/pkgmgmt/internal
-}
-
-function findDebootstrap
-{
- pushd . &>/dev/null
- DEBOOTSTRAP=$(which debootstrap 2>/dev/null) || {
- dir=$($_MKTEMPDIR /var/tmp/debootstrap.XXXXXX)
- workdir=$dir
- dst=$dir/debootstrap.deb
-
- findFile DEBOOTSTRAP_URI "$__CONFDIR"/.defaults/apps/debootstrap/uri "$__PKGLIBDEFAULTDIR"/debootstrap.uri
- read tmp <$DEBOOTSTRAP_URI
- case "$tmp" in
- (/*) ln -s "$tmp" "$dst";;
- (http://*|ftp://*)
- $_WGET -nv -O "$dst" "$tmp" || {
- $_CAT <<EOF >&2
-ERROR: Could not download the debootstrap package from
-
- $dst
-
-Usually, this means that Debian released a new version which is unknown
-to util-vserver and removed the known ones. To fix this, go to
-
- http://ftp.debian.org/debian/pool/main/d/debootstrap/
-
-(or a nearby mirror) and search the URL for the most recent *.deb
-package matching your platform. Then, put this URL into
-
- $__CONFDIR/.defaults/apps/debootstrap/uri
-
-and retry the vserver-build command again.
-EOF
- exit 1
- }
- ;;
- (*) echo $"Unsupported URI scheme '$tmp'" >&2
- exit 1;;
- esac
- cd $dir
- ar x "$dst"
- tar xzf data.tar.gz
- export DEBOOTSTRAP_DIR=`pwd`/usr/lib/debootstrap
- DEBOOTSTRAP=`pwd`/usr/sbin/debootstrap
- }
- popd &>/dev/null
-
- test -x "$DEBOOTSTRAP" || { echo $"Can not find debootstrap at '$DEBOOTSTRAP'" >&2; exit 1; }
-}
-
-function fixupDebian
-{
- $_RM -rf "$1"/dev
- $_MV "$1"/dev.X "$1"/dev
-}
-
-
-### main starts here <---
-
-
-tmp=$(getopt -o '+d:m:' --long debug -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-init
-
-while true; do
- case "$1" in
- -d) DISTRIBUTION=$2; shift;;
- -m) mirror=$2; shift;;
- --debug) set -x;;
- --) shift; break ;;
- *) echo "vserver-build.debootstrap: internal error: unrecognized option '$1'" >&2
- exit 1
- ;;
- esac
- shift
-done
-
-getDistribution
-
-initVariables
-initFilesystem "$OPTION_FORCE"
-
-setup_writeOption "$VSERVER_NAME"
-setup_writeInitialFstab
-
-findDebootstrap
-
-test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
-mv "$VDIR"/dev "$VDIR"/dev.X
-"$DEBOOTSTRAP" "$@" "$DISTRIBUTION" "$VDIR" "$mirror" || : ## HACK: ignore all errors...
-fixupDebian "$VDIR"
-test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-# Expected environment:
-# $VSERVER_NAME ... name of vserver
-
-ROOTDIR=
-ROOTDIR_REL=
-VSERVERDIRNAME=
-
-VDIR=
-
-_DEV_FILE=
-_EXEC_DIR=
-
-BUILD_INITPRE=
-BUILD_INITPOST=
-
-function makeDevEntry
-{
- local dst=$1/$2
- case "$3" in
- (c|b) mknod -m$6 "$dst" $3 $4 $5;;
- (d) mkdir -p -m$4 "$dst";;
- (f) touch "$dst"
- chmod $4 "$dst"
- ;;
- (*) echo "Unknown dev-entry mode '$3'" >&2
- false
- ;;
- esac
-}
-
-function populateDirectory
-{
- local dst=$1
- local i
-
- shift
- for i; do
- local file=
-
- for file in "$i"/*; do
- test -e "$file" || continue
- case "$file" in
- (*/CVS) test ! -d "$file" || continue;;
- (*.rpmsave|*.rpmnew|*.rpmorig)
- continue;;
- esac
-
- cp -a "$file" "$dst/"
- done
- done
-}
-
-function _setRootDir
-{
- test -z "$ROOTDIR" || return 0
-
- for item in "\"$__CONFDIR/.defaults/vdirbase\" 1" "$__DEFAULT_VSERVERDIR"; do
- eval set -- "$item"
- ROOTDIR=$1
- ROOTDIR_REL=$2
- test ! -d "$ROOTDIR" || break
- done
-
- test -d "$ROOTDIR" || {
- echo "Root-directory '$ROOTDIR' does not exist or is invalid" >&2
- exit 1
- }
-}
-
-function _setVserverDir
-{
- test -z "$VSERVERDIRNAME" || return 0
- VSERVERDIRNAME="$VSERVER_NAME"
-}
-
-function _setVdir
-{
- VDIR="$ROOTDIR/$VSERVERDIRNAME"
-}
-
-function say
-{
- test -z "$OPTION_SILENT" || return 0
- echo "$@"
-}
-
-function _renameVserverCfg
-{
- local suffix=.~$(date +'%s')~
- local i
-
- for i in "$VDIR" "$SETUP_CONFDIR"; do
- test ! -e "$i" || {
- mv "$i" "$i$suffix"
- say "Renamed '$i' to '$i$suffix'"
- }
- done
-}
-
-
-## Usage: getDistribution [<default>]
-function getDistribution
-{
- test -z "$DISTRIBUTION" || return 0
-
- if test -e /etc/fedora-release; then
- set -- $(cat /etc/fedora-release)
- DISTRIBUTION=fdr$4
- elif test -e /etc/redhat-release; then
- set -- $(cat /etc/redhat-release)
- DISTRIBUTION=rh$5
- elif test -e /etc/debian_version; then
- set -- $(cat /etc/debian_version)
- DISTRIBUTION=deb$1
- elif test -e /etc/SuSE-release; then
- set -- $(cat /etc/SuSE-release)
- DISTRIBUTION=suse$3
- elif test -e /etc/gentoo-release; then
- set -- $(cat /etc/gentoo-release)
- DISTRIBUTION=gentoo$5
- elif test -e /etc/slackware-release; then
- set -- $(cat /etc/slackware-release)
- DISTRIBUTION=slackware$2
- elif test -n "$1"; then
- DISTRIBUTION=$1
- else
- echo \
-"Can not determine distribution; please specify it manually
-with the '-d' option" >&2
- exit 1
- fi >&2
-}
-
-## Usage: initFilesystem [force]
-function base.initFilesystem
-{
- test -z "$1" || _renameVserverCfg
- test ! -d "$VDIR" -a ! -d "$SETUP_CONFDIR" || {
- echo \
-"vserver-topdirectory '$VDIR' and/or configuration at '$SETUP_CONFDIR'
-exist already; please try to use '--force', or remove them manually"
->&2
- exit 1
- } >&2
-
- mkdir -p -m755 "$VDIR"
- chattr -t "$VDIR"
- mkdir -p -m755 "$SETUP_CONFDIR"/apps "$VDIR"/{dev/pts,etc}
-
- ln -s "$VDIR" "$SETUP_CONFDIR/vdir"
-
- local spec
- while read spec; do
- makeDevEntry "$VDIR"/dev $spec
- done <$_DEV_FILE
-
- mkdir -p "$VDIR"/proc
- findAndCopy "$VDIR"/etc/hosts "$__CONFDIR"/.defaults/files/hosts "$__CONFDIR/.distributions/$DISTRIBUTION"/files/hosts \
- "$__DISTRIBDIR/$DISTRIBUTION"/files/hosts "$__DISTRIBDIR"/defaults/files/hosts ""
-
- for i in nsswitch.conf krb5.conf krb.conf krb.realms ldap.conf localtime resolv.conf; do
- findAndCopy "$VDIR"/etc/$i "$__CONFDIR/.defaults/files/$i" "$__CONFDIR/.distributions/$DISTRIBUTION/files/$i" ""
- done
-}
-
-function base.initVariables
-{
- _setRootDir
- _setVserverDir
- _setVdir
-
- findFile _DEV_FILE "$__CONFDIR/.distributions/$DISTRIBUTION/devs" "$__DISTRIBDIR/$DISTRIBUTION/devs" "$__DISTRIBDIR/defaults/devs"
- findDir _EXECDIR "$__CONFDIR/.distributions/$DISTRIBUTION/execdir" "$__DISTRIBDIR/$DISTRIBUTION/execdir" /
- findFile BUILD_INITPRE "$__CONFDIR/.distributions/$DISTRIBUTION/initpre" "$__DISTRIBDIR/$DISTRIBUTION/initpre" ""
- findFile BUILD_INITPOST "$__CONFDIR/.distributions/$DISTRIBUTION/initpost" "$__DISTRIBDIR/$DISTRIBUTION/initpost" ""
-}
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-function apt.installBasePackages
-{
- local name="$1"
- local dir="$2"
-
- test "$dir" != / || return 0
- for filelist in "$dir"/*; do
- test -f "$filelist" || continue
- local idx=0
- local can_fail=false
- local flags=
-
- set -- $(<$filelist)
- while test "$#" -gt 0; do
- case "$1" in
- --reinstall) flags='--reinstall';;
- --can-fail) can_fail=true;;
- *) break;;
- esac
- shift
- done
- "$_VAPT_GET" "$name" -- install -y $flags $* || $can_fail
- done
-}
-
-function apt.initVariables
-{
- findFile APTCONFDEFAULT \
- "$__CONFDIR/.distributions/$DISTRIBUTION/apt.conf" \
- "$__CONFDIR/.defaults/apps/pkgmgmt/apt.conf" \
- "$__DISTRIBDIR/$DISTRIBUTION/apt.conf" \
- "$__DISTRIBDIR/defaults/apt.conf" \
- ''
-
- findFile APTVENDORDEFAULT \
- "$__CONFDIR/.distributions/$DISTRIBUTION/vendor.conf" \
- "$__CONFDIR/.defaults/apps/pkgmgmt/vendor.conf" \
- /etc/apt/vendors.list \
- "$__DISTRIBDIR/$DISTRIBUTION/vendor.conf" \
- "$__DISTRIBDIR/defaults/vendor.conf" \
- ''
-}
-
-function apt.initFilesystem
-{
- mkdir -p "$PKGCFGDIR"/apt/{etc/sources.list.d,etc/vendors.list.d,etc/apt.conf.d,archives/partial,cache,state/lists/partial}
-
- populateDirectory "$PKGCFGDIR/apt/etc" \
- "$__DISTRIBDIR/defaults/apt" \
- "$__DISTRIBDIR/$DISTRIBUTION/apt" \
- "$__CONFDIR/.distributions/$DISTRIBUTION/apt"
-
- local f="$PKGCFGDIR"/apt/etc/apt.conf
- if test -e "$f"; then
- $_SED -e "s!@APTETCDIR@!$PKGCFGDIR/apt/etc!g" "$f" >"$f.tmp"
- $_CMP -s "$f" "$f.tmp" || $_CAT "$f.tmp" >"$f"
- $_RM -f "$f.tmp"
- fi
-
- test -z "$APTCONFDEFAULT" || \
- $_LN_S "$APTCONFDEFAULT" "$PKGCFGDIR"/apt/etc/apt.conf.d/default.conf
-
- test -z "$APTVENDORDEFAULT" || \
- $_LN_S "$APTVENDORDEFAULT" "$PKGCFGDIR"/apt/etc/vendors.list.d/default.conf
-}
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# Copyright (C) 2004 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.
-
-PKGCFGBASE=
-PKGCFGBASE_REL=
-
-function pkgmgmt._setPkgCfgBase
-{
- test -z "$PKGCFGBASE" || return 0
-
- for item in "\"$__CONFDIR/.defaults/apps/pkgmgmt/base\" 1" ${ROOTDIR:+"$ROOTDIR/.pkg"} "$__DEFAULT_VSERVERPKGDIR"; do
- eval set -- "$item"
- PKGCFGBASE=$1
- PKGCFGBASE_REL=$2
- test ! -d "$PKGCFGBASE" || break
- done
-
- test -d "$PKGCFGBASE" || {
- echo "pkgcfgbase-dir '$PKGCFGBASE' does not exist or is invalid" >&2
- exit 1
- }
-}
-
-function pkgmgmt._setPkgCfg
-{
- pkgmgmt._setPkgCfgBase
-
- test -z "$PKGCFGDIR" || return 0
- PKGCFGDIR="$PKGCFGBASE/$VSERVERDIRNAME"
-}
-
-function pkgmgmt._renameVserverPkgCfg
-{
- local suffix=.~$(date +'%s')~
- local i
-
- for i in "$PKGCFGDIR"; do
- test ! -e "$i" || {
- mv "$i" "$i$suffix"
- say "Renamed '$i' to '$i$suffix'"
- }
- done
-}
-
-function pkgmgmt.initFilesystem
-{
- test -z "$1" || pkgmgmt._renameVserverPkgCfg
- test ! -d "$PKGCFGDIR" || {
- echo $\
-"vserver pkgmgmt-directory exists already; please try to use
-'--force'; or remove it manually" >&2
- exit 1
- }
-
- mkdir -p "${SETUP_CONFDIR:?}"/apps/pkgmgmt
-
- test -z "$PKGCFGDIR" || {
- ln -s "$PKGCFGDIR" "$SETUP_CONFDIR/apps/pkgmgmt/base"
-
- test "$_EXECDIR" = / || ln -s "${_EXECDIR:?}" "$SETUP_CONFDIR/apps/pkgmgmt/execdir"
- }
-
-}
-
-function pkgmgmt.initVariables
-{
- pkgmgmt._setPkgCfg
- findDir PKGINSTALLDIR "$__CONFDIR/.distributions/$DISTRIBUTION/pkgs" "$__DISTRIBDIR/$DISTRIBUTION/pkgs" /
-}
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-RPMDB_PATH=
-RPMLIBDIR=
-
-function rpm.importGPGPubKeys
-{
- local dst=$1
- local pkgs
- declare -a pkgs
- local i
-
- shift
- for i; do
- local file=
- for file in "$i"/*; do
- test -f "$file" || continue
-
- pkgs=( "${pkgs[@]}" "$file" )
- done
- done
-
- test -n "$pkgs" || return 0
- "$_VRPM" "$dst" -- --import "${pkgs[@]}"
-}
-
-function rpm.initVariables
-{
- test -n "$WORKAROUND_106057" && \
- RPMDB_PATH=/.rpmdb || \
- RPMDB_PATH=/dev
-
- findDir RPMLIBDIR "$__CONFDIR/.distributions/$DISTRIBUTION/rpmlib" "$__DISTRIBDIR/$DISTRIBUTION/rpmlib" /
-}
-
-function rpm.initFilesystem
-{
- test -z "$WORKAROUND_106057" || mkdir -p "$RPMDB_PATH"
- mkdir -p "$VDIR$RPMDB_PATH"
-
- test -z "$WORKAROUND_APT_DBPATH" || {
- mkdir -p "$VDIR/var/lib"
- ln -s "$RPMDB_PATH" "$VDIR/var/lib/rpm"
- }
-
- mkdir -p "$PKGCFGDIR"/rpm/{etc,state}
- populateDirectory "$PKGCFGDIR/rpm/etc" \
- "$__DISTRIBDIR/defaults/rpm" \
- "$__DISTRIBDIR/$DISTRIBUTION/rpm" \
- "$__CONFDIR/.distributions/$DISTRIBUTION/rpm"
-
- echo "%_dbpath $RPMDB_PATH" >>"$PKGCFGDIR/rpm/etc/macros"
-
- test "$RPMLIBDIR" = / || ln -s "$RPMLIB" "$SETUP_CONFDIR/apps/pkgmgmt/rpmlib"
-}
-
-function rpm.initDB
-{
- RPM_FLAVOR=d "$_VRPM" "$1" -- --initdb
-}
-
-
-
-## Usage: rpmlist.install <vserver> <basedir> <tmpfile> <listfile> <rpm-options>*
-function rpmlist.install()
-{
- local cfgdir=$1
- local basedir=$2
- local manifest=$3
- local listfile=$4
- shift 4
-
- while read; do
- case x"$REPLY" in
- (x|\#*) continue;;
- esac
-
- echo "$basedir/$REPLY"
- done >"$manifest" <"$listfile"
-
- test "$OPTION_DEBUG" -eq 0 || cat "$manifest"
- test ! -s "$manifest" || $_VRPM "$cfgdir" -- -U "$@" "$manifest"
-}
-
-
-## Usage: rpmlist.initByDistribution <result-var> <distribution>
-function rpmlist.initByDistribution()
-{
- local _rlid_listdir
- declare -a _rlid_res=()
-
-
- findDir _rlid_listdir "$__CONFDIR/.distributions/$2/rpmlist.d" \
- "$__DISTRIBDIR/$2/rpmlist.d" \
- ''
-
- test -d "$_rlid_listdir" || return 0
-
- local _rlid_lst
- for _rlid_lst in "$_rlid_listdir"/*.lst; do
- test -e "$_rlid_lst" || continue
-
- local _rlid_opts=${_rlid_lst%%lst}cmd
- declare -a _rlid_tmp=()
-
- test ! -e "$_rlid_opts" || getFileArray _rlid_tmp "$_rlid_opts"
- _rlid_res=( "${_rlid_res[@]}" "${_rlid_tmp[@]}" "$_rlid_lst" )
- done
-
- eval "$1"='( "${_rlid_res[@]}" )'
-}
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-function yum.installBasePackages
-{
- local name="$1"
- local dir="$2"
-
- test "$dir" != / || return 0
- for filelist in "$dir"/*; do
- test -f "$filelist" || continue
- local idx=0
- local can_fail=false
- local flags=
-
- set -- $(<$filelist)
- while test "$#" -gt 0; do
- case "$1" in
- --reinstall) flags='';;
- --can-fail) can_fail=true;;
- *) break;;
- esac
- shift
- done
- "$_VYUM" "$name" -- -y install $flags $* || $can_fail
- done
-}
-
-function yum.initVariables
-{
- findDir YUMREPOSDEFAULT \
- "$__CONFDIR/.distributions/$DISTRIBUTION/yum.repos.d" \
- "$__DISTRIBDIR/$DISTRIBUTION/yum.repos.d" \
- ''
-}
-
-function yum.__substituteConf
-{
- local f=$1
- local prefix=$2
-
- if test -e "$f"; then
- $_SED -e "s!@YUMETCDIR@!$prefix$PKGCFGDIR/yum/etc!g;
- s!@YUMCACHEDIR@!$prefix$PKGCFGDIR/yum/cache!g;
- s!@YUMLOGDIR@!$prefix$PKGCFGDIR/yum!g;
- " "$f" >"$f.tmp"
- $_CMP -s "$f" "$f.tmp" || $_CAT "$f.tmp" >"$f"
- $_RM -f "$f.tmp"
- fi
-}
-
-function yum.initFilesystem
-{
- mkdir -p "$PKGCFGDIR"/yum/{etc,cache}
-
- populateDirectory "$PKGCFGDIR/yum/etc" \
- "$__DISTRIBDIR/defaults/yum" \
- "$__DISTRIBDIR/$DISTRIBUTION/yum" \
- "$__CONFDIR/.distributions/$DISTRIBUTION/yum"
-
- ## workaround for yum's automatism to search the configuration in the chroot
-
- local f0="$PKGCFGDIR"/yum/etc/yum.conf
- local f1="$PKGCFGDIR"/yum/etc/yum-hack.conf
- cp -a "$f0" "$f1"
-
- yum.__substituteConf "$f0" 'hostfs://'
- yum.__substituteConf "$f1" '/../../../../../../../../../../../../'
-
- test -z "$YUMREPOSDEFAULT" -o -e "$PKGCFGDIR/yum/etc/yum.repos.d" || \
- $_LN_S "$YUMREPOSDEFAULT" "$PKGCFGDIR/yum/etc/yum.repos.d"
-}
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# Copyright (C) 2005 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.
-
-tmp=$(getopt -o +d:b:e --long debug,empty -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_RPM"
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
-
-set -e
-
-
-BASEDIR=$(pwd)
-DISTRIBUTION=
-EMPTY=
-
-echo "$@"
-
-while true; do
- case "$1" in
- (-d) DISTRIBUTION=$2; shift;;
- (-b) BASEDIR=$2; shift;;
- (-e|--empty) EMPTY=1;;
- (--debug) set -x;;
- (--) shift; break ;;
- (*) echo "vserver-build.rpm: internal error: unrecognized option '$1'" >&2
- exit 1
- ;;
- esac
- shift
-done
-
-
-####### some basic initializations
-
-getDistribution "template"
-
-base.initVariables
-pkgmgmt.initVariables
-rpm.initVariables
-
-if test -z "$EMPTY" -a "$#" -eq 0; then
- rpmlist.initByDistribution rpm_lists "$DISTRIBUTION"
- set -- "${rpm_lists[@]}"
-fi
-
-test -n "$EMPTY" -o "$#" -gt 0 || \
- panic $"\
-No rpm-lists specified and no list found for distribution '$DISTRIBUTION'.
-When this is really indented, please use the '--empty' option."
-
-rpm_dflt_opts=()
-test "$OPTION_DEBUG" -lt 2 || rpm_dflt_opts=( "${rpm_dflt_opts[@]}" -v )
-test "$OPTION_DEBUG" -lt 3 || rpm_dflt_opts=( "${rpm_dflt_opts[@]}" -v )
-test -n "$OPTION_SILENT" || rpm_dflt_opts=( "${rpm_dflt_opts[@]}" -vh )
-
-
-###### init the filesystem
-
-base.initFilesystem "$OPTION_FORCE"
-pkgmgmt.initFilesystem "$OPTION_FORCE"
-rpm.initFilesystem
-
-setup_writeOption "$VSERVER_NAME"
-setup_writeInitialFstab
-
-
-# when basedir is a non-local location, rpm will download it into the
-# current directory. Therefore, create and go into a temporay directory
-# before doing the operations.
-tmpdir=$($_MKTEMPDIR /var/tmp/vserver-build.rpm.XXXXXX)
-manifest=$($_MKTEMP /tmp/vserver-build.rpm.manifest.XXXXXX)
-trap "rm -rf $tmpdir $manifest" EXIT
-cd "$tmpdir"
-
-
-###### do the real work
-
-test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
-rpm.initDB "$SETUP_CONFDIR"
-rpm.importGPGPubKeys "$SETUP_CONFDIR" \
- "$__CONFDIR/.distributions/$DISTRIBUTION/pubkeys" \
- "$__CONFDIR/.distributions/.common/pubkeys" \
- "$__DISTRIBDIR/$DISTRIBUTION/pubkeys"
-
-opts=()
-for i; do
- case "$i" in
- (--force|--nodeps) opts=( "${opts[@]}" "$i" ); continue;;
- esac
-
- rpmlist.install "$VSERVER_NAME" "$BASEDIR" "$manifest" "$i" "${rpm_dflt_opts[@]}" "${opts[@]}"
- opts=()
-done
-
-test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-tmp=$(getopt -o '+d:' --long debug,pkgmgmt -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
-
-DISTRIBUTION=:
-use_pkgmgmt=
-while true; do
- case "$1" in
- -d) DISTRIBUTION=$2; shift;;
- --debug) set -x;;
- --pkgmgmt) use_pkgmgmt=1;;
- --) shift; break ;;
- *) echo "vserver-build.skeleton: internal error: unrecognized option '$1'" >&2
- exit 1
- ;;
- esac
- shift
-done
-
-getDistribution
-
-base.initVariables
-test -z "$use_pkgmgmt" || pkgmgmt.initVariables
-
-base.initFilesystem "$OPTION_FORCE"
-test -z "$use_pkgmgmt" || pkgmgmt.initFilesystem "$OPTION_FORCE"
-
-
-setup_writeOption "$VSERVER_NAME"
-setup_writeInitialFstab
-
-test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
-test -z "$1" || "$@"
-test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# Copyright (C) 2005 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.
-
-tmp=$(getopt -o +d: --long debug -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_RPM"
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_YUM"
-. "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
-
-while true; do
- case "$1" in
- (-d) DISTRIBUTION=$2; shift;;
- (--debug) set -x;;
- (--) shift; break ;;
- (*) echo "vserver-build.yum-rpm: internal error: unrecognized option '$1'" >&2
- exit 1
- ;;
- esac
- shift
-done
-
-getDistribution
-
-base.initVariables
-pkgmgmt.initVariables
-rpm.initVariables
-yum.initVariables
-
-base.initFilesystem "$OPTION_FORCE"
-pkgmgmt.initFilesystem "$OPTION_FORCE"
-rpm.initFilesystem
-yum.initFilesystem
-
-setup_writeOption "$VSERVER_NAME"
-setup_writeInitialFstab
-
-test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
-rpm.initDB "$SETUP_CONFDIR"
-rpm.importGPGPubKeys "$SETUP_CONFDIR" \
- "$__CONFDIR/.distributions/$DISTRIBUTION/pubkeys" \
- "$__CONFDIR/.distributions/.common/pubkeys" \
- "$__DISTRIBDIR/$DISTRIBUTION/pubkeys"
-yum.installBasePackages "$SETUP_CONFDIR" "$PKGINSTALLDIR"
-$_VYUM "$SETUP_CONFDIR" -- clean all
-test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
+++ /dev/null
-#!/bin/sh
-
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on vserver-copy by Mark Lawrence <nomad@null.net>
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-# Copy/Sync a virtual host from one machine to another
-#
-# History:
-#
-# 2003-04-04: Version 0.4 - Mark lawrence
-# - Set "ONBOOT=no" in the destination .conf file when --startstop
-# is not used, in case the destination roothost reboots. We don't
-# want two copies of a vserver running at the same time.
-#
-# 2003-03-04: Version 0.3 - Mark lawrence
-# - Changed all checks for [ "" != "$var" ] into [ -n|-z "$var" ]. "" doesn't
-# seem to work for bash on the Sparc architecture.
-# - Changed $ssh variable into $shcmd.
-#
-# 2003-02-23: Version 0.2 - Mark Lawrence
-# - Set ONBOOT to "no" in the original .conf file when the "-s" flag is
-# used so that if/when you reboot the source roothost you don't have the
-# same vserver and IP address running on two machines.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-VERSION="0.4"
-umask 022
-me=${0##*/}
-
-
-### Helper functions ###
-
-# Save stdin and stdout for later use
-exec 3>&1
-exec 4>&2
-
-noninteractive () {
- exec &> /dev/null
-}
-
-interactive () {
- exec 1>&3
- exec 2>&4
-}
-
-info () {
- ! $quiet && echo "I: $me: $1" >&3
-}
-
-warn () {
- ! $quiet && echo "W: $me: $1" >&4
-}
-
-error () {
- ! $quiet && echo "E: $me: $2" >&4
- exit $1
-}
-
-
-### Usage/Info functions ###
-
-usage () {
- cat <<EOF 1>&2
-Usage: $me [-hVvqidrRs] vserver newname
- $me [-hVvqidrRs] vserver host:[newname]
-EOF
-}
-
-full_usage () {
- usage
- cat <<EOF
-
-$me uses rsync to make a copy of a vserver. If the destination
-name contains a host specification the vserver will be synchronised to
-the remote destination over ssh/rsh.
-
-This can be used on a running vserver to make a warm backup. With the -s
-flag a vserver can even be operationally moved to different hardware within
-seconds.
-
-The -i and -d flags can be used to minimally reconfigure the destination
-vserver (rewrites /etc/vservers/newname.conf and $__DEFAULT_VSERVERDIR/newname/etc/hosts)
-
-Options:
- -h, --help this help
- -V, --version copyright and version information
- -v, --verbose show all output
- -q, --quiet direct all output to /dev/null (no password
- prompt for logins on remote hosts!)
- -d, --domain [string] new dns domain (must be used with -i)
- -i, --ip [addr] new IP address (must be used with -d)
- -r, --vsroot location of "/vserver/" directory
- -R, --rsh use rsh (instead of default ssh) for
- network transport
- -s, --stopstart stop the local vserver before copying and start
- it on the destination host afterwards
-
-EOF
-}
-
-full_version () {
- cat <<EOF
-$me version $VERSION
-Copyright (c) 2002 Mark Lawrence <nomad@null.net>
-
-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; either version 2 of the License, or (at
-your option) any later version.
-
-EOF
-}
-
-
-### Default values and Command line options ###
-
-stopstart=(false)
-verbose=(false)
-quiet=(false)
-shcmd="ssh"
-rsflag="-e"
-rsh=(false)
-colon=":"
-domain=""
-ip=""
-vsroot=$__DEFAULT_VSERVERDIR
-
-if [ $# -eq 0 ]; then # Script invoked with no command-line args?
- usage
- exit 1
-fi
-
-temp=$(getopt -o hVvqd:i:rRs --long help,version,verbose,quiet,domain:,ip:,vsroot,rsh,stopstart, -n $me -- "$@")
-
-if [ $? -ne 0 ]; then
- echo " (See -h for help)"
- exit 1
-fi
-
-# Note the quotes around `$temp': they are essential!
-eval set -- "$temp"
-
-while true; do
- case "$1" in
- -h|--help) full_usage
- exit 1
- ;;
- -V|--version) full_version
- exit 1
- ;;
- -v|--verbose) verbose=(true)
- shift
- ;;
- -q|--quiet) quiet=(true)
- shift
- ;;
- -d|--domain) domain="$2"
- shift 2
- ;;
- -i|--ip) ip="$2"
- shift 2
- ;;
- -r|--vsroot) vsroot="$2"
- shift 2
- ;;
- -R|--rsh) rsh=(true)
- shift
- ;;
- -s|--stopstart) stopstart=(true)
- shift
- ;;
- --) shift
- break
- ;;
- *) echo "Internal error!"
- exit 1
- ;;
- esac
-done
-
-if [ $# -ne 2 ]; then
- usage
- exit 1
-fi
-
-
-### ###
-
-# By default we are reasonably quiet (ouput only via info, warn & error)
-if $verbose; then
- interactive
-else
- noninteractive
-fi
-
-now=$(date)
-info "called on $(hostname) at $now"
-
-
-vserver=$1
-vconf=/etc/vservers/$vserver.conf
-vroot=$vsroot/$vserver
-
-if $rsh; then
- shcmd="rsh"
-fi
-
-if (echo $2 | grep '^[a-z][a-z0-9]\+$'); then
- dhost=""
- newname=$2
- shcmd=""
- rsflag=""
- colon=""
- if $rsh; then
- warn "rsh is set but not used for a local copy"
- fi
-elif (echo $2 | grep '^[a-z].*[a-z0-9]:$'); then
- dhost=${2/:/}
- newname=$vserver
-elif (echo $2 | grep '^[a-z].*[a-z0-9]:[a-z].*[a-z0-9]$'); then
- dhost=${2/:*/}
- newname=${2/*:/}
-else
- error 1 "Second argument must be of the form \"[host:]name\" or \"host:\""
-fi
-
-target=$vsroot/$newname
-targetconf=/etc/vservers/$newname.conf
-
-
-### Perform some sanity checks ###
-
-if [ ! -d $vroot ]; then
- error 1 "Directory \"$vroot\" does not exist"
-fi
-
-if [ ! -e $vconf ]; then
- error 1 "Vserver file \"$vconf\" does not exist"
-fi
-
-if [ -z "$dhost" ] && [ "$vserver" == "$newname" ]; then
- error 1 "Source and destination names cannot be the same on the localhost"
-fi
-
-if [ -n "$dhost" ] && ! (host $dhost | grep 'has address'); then
- warn "$dhost does not resolve into an IP address"
-fi
-
-if [ \( -n "$ip" -a -z "$domain" \) -o \
- \( -z "$ip" -a -n "$domain" \) ]
-then
- error 1 "Both IP address and domain must be specified together"
-fi
-
-if [ -n "$ip" ] && \
-! (echo $ip | grep '^[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}$' ); then
- error 1 "\"$ip\" is not a valid IP address"
-fi
-
-# This works both locally and remote
-if ($shcmd $dhost $__SBINDIR/vserver $newname running | grep 'is running'); then
- warn "destination vserver \"$newname\" is running"
- error 1 "Cannot copy over a running vserver"
-fi
-
-
-### Do the copy ###
-
-info "Attempting to copy $vserver to $dhost$colon$newname"
-
-if $stopstart; then
- info "Stopping virtual server \"$vserver\" on localhost"
- $__SBINDIR/vserver $vserver stop
-fi
-
-info "Syncing directories"
-# trailing slashes very important in the rsync!
-if ! rsync -avxz $rsflag $shcmd $vroot/ $dhost$colon$target/; then
- error 1 "rsync failed"
-fi
-
-if [ -n "$ip" -a -n "$domain" ]; then
- # Insert the new IPROOT/S_HOSTNAME values into the config file
- info "Modifying $targetconf"
- tmpf=$(tempfile)
- if (sed -e "s/^S_HOSTNAME=.*/S_HOSTNAME=\"$newname\"/" \
- -e "s/^IPROOT=.*/IPROOT=\"$ip\"/" $vconf > $tmpf)
- then
- if ! rsync -v $rsflag $shcmd $tmpf $dhost$colon$targetconf; then
- error $? "vserver config file copy/change failed"
- fi
-
- else
- warn "Unable to reconfigure virtual server config file"
- fi
-
- # create a new /etc/hostname
- info "Creating hostname file"
- echo $newname > $tmpf
- if ! rsync -v $rsflag $shcmd $tmpf $dhost$colon$target/etc/hostname; then
- error 1 "vserver /etc/hostname copy failed"
- fi
-
- info "Creating /etc/hosts"
- cat << EOF > $tmpf
-# /etc/hosts (automatically generated by $me)
-
-127.0.0.1 localhost
-$ip $newname.$domain $newname
-
-# The following lines are desirable for IPv6 capable hosts
-
-::1 ip6-localhost ip6-loopback
-fe00::0 ip6-localnet
-ff00::0 ip6-mcastprefix
-ff02::1 ip6-allnodes
-ff02::2 ip6-allrouters
-ff02::3 ip6-allhosts
-EOF
-
- # copy /etc/hosts
- if ! rsync -v $rsflag $shcmd $tmpf $dhost$colon$target/etc/hosts; then
- error 1 "vserver /etc/hosts copy failed"
- fi
- rm -f $tmpf
-
-else
- if ! $stopstart; then
- # Make sure that this vserver doesn't start on the
- # destination host if it reboots
- tmpf=$(tempfile)
- sed -e 's/^ONBOOT=.*/ONBOOT=no/' $vconf > $tmpf
- vconf=$tmpf
- fi
-
- # copy newname.conf unchanged
- info "Copying $targetconf"
- if ! rsync -v $rsflag $shcmd $vconf $dhost$colon$targetconf; then
- error 1 "vserver config file copy/change failed"
- fi
-
- rm -f $tmpf
-fi
-
-
-if $stopstart; then
- info "Starting virtual server \"$vserver\" on $dhost"
- $shcmd $dhost $__SBINDIR/vserver $vserver start
- if ($shcmd $dhost $__SBINDIR/vserver $vserver running | \
- grep 'not running'); then
- error 1 "Virtual server \"$vserver\" failed to start on $dhost"
- fi
-
- # Make sure that we don't start the original on next boot
- tmpf=$(tempfile)
- sed -e 's/^ONBOOT=.*/ONBOOT=no/' $vconf > $tmpf
- mv $tmpf $vconf
-fi
-
-exit 0
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-SETUP_HOSTNAME=
-SETUP_NETDEV=
-SETUP_NETMASK=
-SETUP_NETPREFIX=
-SETUP_NETBCAST=
-SETUP_LOCKFILE=
-SETUP_CONFDIR=
-SETUP_CONTEXT=
-SETUP_INITSTYLE=
-
-declare -a SETUP_INTERFACES=()
-declare -a SETUP_FLAGS=()
-
-declare -r SETUP_OPTIONS="confdir:,lockfile:,hostname:,netdev:,netmask:,netprefix:,netbcast:,interface:,flags:,context:,initstyle:"
-declare -r SETUP_HELPMSG=$"
- --context ... the static context of the vserver [default: none; a dynamic
- context will be assumed]
- --confdir ... [default: $__CONFDIR/<name>]
- --lockfile <filename>
- ... [default: $__RUNDIR/<name>]
- --hostname <hostname>
- --netdev <device>
- --netbcast <broadcast>
- --netmask <netmask>|--netprefix <prefixlen>
- ... sets the default netmask (a.b.c.d quadruple) or prefixlen
- (length of the interface)
- --interface [<name-suffix>=][<device>:]<ip>[/<mask|prefixlen>]
- ... declares an network-interface; this option can be specified
- multiple times
- --flags <flags>+
- ... sets comma-separated list of flags; possible flags are
- lock: Prevent the vserver from setting new security context
- sched: Merge scheduler priority of all processes in the
- vserver so that it acts a like a single
- one (kernel 2.4 only).
- nproc: Limit the number of processes in the vserver
- according to ulimit (instead of a per user limit,
- this becomes a per vserver limit)
- private: No other process can join this security context.
- Even root
- --initstyle <style>
- ... configures the initstyle (e.g. minit,sysv,plain)
-"
-
-function setup_setOption2
-{
- case "$1" in
- (--context) SETUP_CONTEXT=$2;;
- (--confdir) SETUP_CONFDIR=$2;;
- (--lockfile) SETUP_LOCKFILE=$2;;
- (--hostname) SETUP_HOSTNAME=$2;;
- (--netdev) SETUP_NETDEV=$2;;
- (--netmask) SETUP_NETMASK=$2;;
- (--netprefix) SETUP_NETPREFIX=$2;;
- (--netbcast) SETUP_NETBCAST=$2;;
- (--interface) SETUP_INTERFACES=( "${SETUP_INTERFACES[@]}" "$2" );;
- (--initstyle) SETUP_INITSTYLE=$2;;
- (--flags) old_IFS=$IFS
- IFS=,
- set -- $2
- SETUP_FLAGS=( "${SETUP_FLAGS[@]}" "$@" )
- IFS=$old_IFS
- ;;
- (*) return 1;;
- esac
-
- return 0
-}
-
-function _setup_writeSingleOption
-{
- test -z "$1" || echo "$1" >"$2"
-}
-
-function _setup_writeInterface
-{
- local vdir=$1
- local idx=$2
- local tmp=$3
-
- local name=${tmp%%=*}
- test "$name" != "$tmp" || name=
-
- tmp=${tmp##${name}=}
- local dev=${tmp%%:*}
- test "$dev" != "$tmp" || dev=
-
- tmp=${tmp##${dev}:}
- local mask=${tmp##*/}
- test "$mask" != "$tmp" || mask=
-
- local ip=${tmp%%/${mask}}
-
- local prefix=
- test "${mask%%.*}" != "$mask" || {
- prefix=$mask
- mask=
- }
-
- d=$vdir/interfaces/$idx
- mkdir "$d"
-
- _setup_writeSingleOption "$name" $d/name
- _setup_writeSingleOption "$dev" $d/dev
- _setup_writeSingleOption "$ip" $d/ip
- _setup_writeSingleOption "$mask" $d/mask
- _setup_writeSingleOption "$prefix" $d/prefix
-
- test -n "$dev" -o -n "$SETUP_NETDEV" || \
- echo $"No device specified for interface '$idx'; do not forget to set the 'nodev' option" >&2
-}
-
-function setup_setDefaults
-{
- : ${SETUP_CONFDIR:=$__CONFDIR/$1}
- : ${SETUP_LOCKFILE:=$__RUNDIR/$1}
- findFile SETUP_FSTAB "$__CONFDIR"/.defaults/fstab "$__PKGLIBDEFAULTDIR"/fstab
-}
-
-function setup_writeOption
-{
- local name=$1
- local cfgdir=${SETUP_CONFDIR:?}
- local i
-
- mkdir -p "$cfgdir"/interfaces "$cfgdir"/apps/init "$cfgdir"/uts
-
- _setup_writeSingleOption "$name" "$cfgdir"/name
- _setup_writeSingleOption "$SETUP_CONTEXT" "$cfgdir"/context
- _setup_writeSingleOption "$SETUP_HOSTNAME" "$cfgdir"/uts/nodename
- _setup_writeSingleOption "$SETUP_NETDEV" "$cfgdir"/interfaces/dev
- _setup_writeSingleOption "$SETUP_NETMASK" "$cfgdir"/interfaces/mask
- _setup_writeSingleOption "$SETUP_NETPREFIX" "$cfgdir"/interfaces/prefix
- _setup_writeSingleOption "$SETUP_NETBCAST" "$cfgdir"/interfaces/bcast
- _setup_writeSingleOption "$SETUP_INITSTYLE" "$cfgdir"/apps/init/style
-
- local idx=0
- for i in "${SETUP_INTERFACES[@]}"; do
- _setup_writeInterface "$cfgdir" $idx "$i"
- let ++idx
- done
-
- test -z "$SETUP_FLAGS" || for i in "${SETUP_FLAGS[@]}"; do
- echo "$i"
- done >"$cfgdir"/flags
-
- ln -s "$SETUP_LOCKFILE" "$cfgdir"/run
-}
-
-function setup_writeInitialFstab
-{
- cat "${SETUP_FSTAB:?}" >"${SETUP_CONFDIR:?}"/fstab
-}
-
-function setup_test
-{
- SETUP_INTERFACES=()
-
- setup_setOption2 --interface foo0=eth0:1.2.3.4/1
- setup_setOption2 --interface foo1=eth0:1.2.3.4/255.255.248.0
- setup_setOption2 --interface foo2=eth0:1.2.3.4
- setup_setOption2 --interface foo3=1.2.3.4
- setup_setOption2 --interface foo4=1.2.3.4/1
- setup_setOption2 --interface eth0:1.2.3.4
- setup_setOption2 --interface eth0:1.2.3.4/1
- setup_setOption2 --interface 1.2.3.4
- setup_setOption2 --interface 1.2.3.4/1
-
- setup_writeOption xx
-}
+++ /dev/null
-#! /bin/bash
-
-# Copyright (C) 2004 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-test -n "$MARK" || MARK=default
-: ${LOCKFILE:=vservers-$MARK}
-: ${NUMPARALLEL:=6}
-
-
-if test -e /etc/init.d/functions; then
- . /etc/init.d/functions
- lockfile=/var/lock/subsys/$LOCKFILE
-else
- success() { echo .; }
- passed() { echo .; }
- failure() { echo ERROR; }
- lockfile=/var/run/$LOCKFILE
-fi
-
-
-function _tellResult()
-{
- local rc=$1
- case "$rc" in
- (0) success;;
- (2) passed; rc=0;;
- (*) failure;;
- esac
- echo
- return $rc
-}
-
-function start()
-{
- echo -n $"Starting vservers of type '$MARK'..."
- $_START_VSERVERS -m "$MARK" -j "$NUMPARALLEL" --all --start
- _tellResult $?
- local rc=$?
- test "$rc" -ne 0 || touch "$lockfile"
- return $rc
-}
-
-function stop()
-{
- echo -n $"Stopping vservers of type '$MARK'..."
- $_START_VSERVERS -m "$MARK" -j "$NUMPARALLEL" --all --stop
- _tellResult $?
- local rc=$?
- $_RM -f "$lockfile"
- return $rc
-}
-
-function restart()
-{
- stop
- start
-}
-
-case "$1" in
- start|stop|restart) $1;;
- condrestart)
- test -f $lockfile && restart || :
- ;;
- status)
- test -f $lockfile && {
- echo $"vservers of type '$MARK' were started"
- exit 0
- }
- echo $"vservers of type '$MARK' are not started"
- exit 1
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|condrestart|status}"
- exit 2
- ;;
-esac
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-## Expected env:
-# $VSERVER_DIR ... path to vserver-cfg dir
-# $VSERVER_NAME ... name of vserver
-
-declare -a NICE_CMD=()
-declare -a CHBIND_OPTS=()
-declare -a CAP_OPTS=()
-declare -a CHCONTEXT_INIT_OPTS=()
-declare -a CHCONTEXT_FLAG_OPTS=()
-declare -a CHCONTEXT_OPTS=()
-declare -a CAPCHROOT_OPTS=()
-declare -a INTERFACES=()
-
-declare -a INITCMD_START=()
-declare -a INITCMD_START_SYNC=()
-declare -a INITCMD_STOP=()
-declare -a INITCMD_STOP_SYNC=()
-declare -a INITCMD_PREPARE=()
-declare -a INITKILL_SEQ=()
-declare -a ENTER_SHELL=()
-
-declare -a OPTS_VCONTEXT_CREATE=()
-declare -a OPTS_VCONTEXT_MIGRATE=()
-declare -a OPTS_VATTRIBUTE=( --flag fakeinit )
-declare -a OPTS_VSCHED=()
-
-declare -a STOPCMD_PREPARE=()
-
-declare -a VSERVER_EXTRA_CMDS=()
-
-VSHELPER_SYNC_TIMEOUT=30
-USE_VNAMESPACE=
-INTERFACE_CMDS_IDX=0
-RUNLEVEL_START=
-RUNLEVEL_STOP=
-_HAVE_INTERFACE_OPTIONS=
-_HAVE_CHBIND_OPTIONS=
-_NEED_VSHELPER_SYNC=
-_IS_FAKEINIT=
-
-INITSTYLE=sysv
-
-S_CONTEXT=
-
-SILENT_OPT=
-
-: ${VSERVER_NAME:=$(basename "$VSERVER_DIR")}
-
-if test -e "$VSERVER_DIR"/noisy -o -n "$OPTION_VERBOSE"; then
- SILENT_OPT=
-else
- SILENT_OPT='--silent'
-fi
-
-function _generateChbindOptions
-{
- local vdir="$1"
- local i
- local bcast=
-
- test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$vdir"
-
- local f=$vdir/interfaces/bcast
- getFileValue bcast "$f"
-
- CHBIND_OPTS=( $SILENT_OPT ${bcast:+--bcast "$bcast"} )
-
- for i in "${INTERFACES[@]}"; do
- CHBIND_OPTS=( "${CHBIND_OPTS[@]}" --ip "$i" )
- done
-
- _HAVE_CHBIND_OPTIONS=1
-}
-
-function _generateNiceCommand
-{
- local vdir=$1
- local nice
-
- test -r "$vdir/nice" || return 0;
- read nice <"$vdir"/nice
-
- NICE_CMD=( $_NICE -$nice )
-}
-
-function _generateCCapabilityOptions
-{
- local vdir=$1
- local cap
- local f="$vdir"/ccapabilities
-
- test -e "$f" || return 0
- while read cap; do
- case x"$cap" in
- (x|x\#) ;;
- (*) OPTS_VATTRIBUTE=( "${OPTS_VATTRIBUTE[@]}" --ccap "$cap" );;
- esac
- done <"$f"
-}
-
-function _generateBCapabilityOptions
-{
- local vdir=$1
- local cap
- local f="$vdir"/bcapabilities
-
- test -e "$f" || return 0
- while read cap; do
- case x"$cap" in
- (x|x\#) ;;
- (*) OPTS_VATTRIBUTE=( "${OPTS_VATTRIBUTE[@]}" --bcap "$cap" );;
- esac
- done <"$f"
-}
-
-function _generateCapabilityOptions
-{
- local vdir=$1
- local cap
-
- _generateBCapabilityOptions "$vdir"
- _generateCCapabilityOptions "$vdir"
-
- test -e "$vdir"/capabilities || return 0
-
- CAP_OPTS=()
- CAPCHROOT_OPTS=()
-
- while read cap; do
- case x"$cap" in
- (x|x\#) ;;
- (!CAP_SYSCHROOT)
- CAP_OPTS=( "${CAP_OPTS[@]}" --cap "$cap" )
- CAPCHROOT_OPTS=( "${CAPCHROOT_OPTS[@]}" --nochroot )
- ;;
- (*)
- CAP_OPTS=( "${CAP_OPTS[@]}" --cap "$cap" )
- ;;
- esac
- done <"$vdir"/capabilities
-}
-
-function getEnterShell
-{
- local vdir=$1
- local shell_file
-
- ENTER_SHELL=()
-
- getFileValue ENTER_SHELL "$vdir"/shell "$__CONFDIR"/.defaults/shell
-
- test -n "$ENTER_SHELL" || {
- local i
- for i in "/bin/bash -login" "/bin/sh -l" /bin/csh; do
- set -- $i
- test -x "$vdir/vdir/$1" || continue
- ENTER_SHELL=( "$@" )
- break
- done
- }
-}
-
-## Usage: sendKillSequence <ctx> <signal> [<wait> <signal>]*
-function sendKillSequence
-{
- local ctx=$1
- local wait=
- shift
-
- while isCtxRunning "$ctx"; do
- test -z "$wait" || sleep "$wait"
-
- $_VKILL --xid "$ctx" ${1:+-s "$1"} 2>/dev/null || :
- test -n "$2" || break
- wait="$2"
- shift 2
- done
-}
-
-function _generateInitOptions
-{
- local vdir=$1
- local cfgdir=$vdir/apps/init
- local i f
-
- INITCMD_START=()
- INITCMD_STOP=()
- INITCMD_START_SYNC=()
- INITCMD_STOP_SYNC=()
- INITCMD_PREPARE=()
- STOPCMD_PREPARE=()
-
- INITKILL_SEQ=( 15 5 9 )
- CHCONTEXT_INIT_OPTS=()
-
-
- getFileValue INITSTYLE "$cfgdir"/style
- getFileValue RUNLEVEL_START "$cfgdir"/runlevel
- getFileValue RUNLEVEL_START "$cfgdir"/runlevel.start
- getFileValue RUNLEVEL_STOP "$cfgdir"/runlevel.stop
- getFileArray INITKILL_SEQ "$cfgdir"/killseq || :
-
- case x"$INITSTYLE" in
- (xsysv)
- test -n "$RUNLEVEL_START" || RUNLEVEL_START=3
- test -n "$RUNLEVEL_STOP" || RUNLEVEL_STOP=6
-
- for i in /etc/init.d/rc /etc/rc.d/rc; do
- test -x "$vdir/vdir/$i" || continue
- INITCMD_START=( "$i" "$RUNLEVEL_START" )
- INITCMD_STOP=( "$i" "$RUNLEVEL_STOP" )
- done
- INITCMD_PREPARE=( $_FAKE_RUNLEVEL "$RUNLEVEL_START" /var/run/utmp )
- ;;
-
- (xplain)
- INITCMD_START=( /sbin/init )
- INITCMD_STOP=( /sbin/init )
- _IS_FAKEINIT=1
- _NEED_VSHELPER_SYNC=1
- test -z "$RUNLEVEL_START" || INITCMD_START=( "${INITCMD_START[@]}" "$RUNLEVEL_START" )
- test -z "$RUNLEVEL_STOP" || INITCMD_STOP=( "${INITCMD_STOP[@]}" "$RUNLEVEL_STOP" )
- ;;
-
- (xminit)
- INITCMD_START=( /sbin/minit-start )
- INITCMD_STOP=( /sbin/minit-stop )
- _IS_FAKEINIT=1
- INITCMD_START_SYNC=( "$_INITSYNC_MINIT_START" "$vdir" )
- _NEED_VSHELPER_SYNC=1
- test -z "$RUNLEVEL_START" || INITCMD_START=( "${INITCMD_START[@]}" "$RUNLEVEL_START" )
- test -z "$RUNLEVEL_STOP" || INITCMD_STOP=( "${INITCMD_STOP[@]}" "$RUNLEVEL_STOP" )
- ;;
-
- (xgentoo)
- INITCMD_START=( /sbin/rc default )
- INITCMD_STOP=( /sbin/rc shutdown )
- ;;
-
- (x) ;;
- (*) echo "Unknown init-style '$INITSTYLE'; aborting" >&2;
- exit 1;;
- esac
-
- getFileArray INITCMD_START "$cfgdir"/cmd.start || :
- getFileArray INITCMD_STOP "$cfgdir"/cmd.stop || :
- getFileArray INITCMD_START_SYNC "$cfgdir"/cmd.start-sync || :
- getFileArray INITCMD_STOP_SYNC "$cfgdir"/cmd.stop-sync || :
- getFileArray INITCMD_PREPARE "$cfgdir"/cmd.prepare || :
-
-
- test -n "$OPTION_FORCE_SYNC" -o -e "$cfgdir"/sync || {
- INITCMD_START_SYNC=()
- INITCMD_STOP_SYNC=()
- _NEED_VSHELPER_SYNC=
- }
-
- if vshelper.isEnabled; then
- vshelper.getSyncTimeout "$vdir" VSHELPER_SYNC_TIMEOUT || :
- else
- _NEED_VSHELPER_SYNC=
- fi
-}
-
-function _generateFlagOptions
-{
- local vdir=$1
-
- CHCONTEXT_FLAG_OPTS=()
-
- test ! -e "$vdir"/flags || \
- while read flag; do
- case x"$flag" in
- (x|x\#) ;;
- (xnamespace) ;;
- (xfakeinit)
- _IS_FAKEINIT=1
- ;;
- (*)
- OPTS_VATTRIBUTE=( "${OPTS_VATTRIBUTE[@]}" --flag "$flag" )
- CHCONTEXT_FLAG_OPTS=( "${CHCONTEXT_FLAG_OPTS[@]}"
- --flag "$flag" )
- ;;
- esac
- done <"$vdir"/flags
-
- isAvoidNamespace "$vdir" || {
- USE_VNAMESPACE=1
- CHCONTEXT_FLAG_OPTS=( "${CHCONTEXT_FLAG_OPTS[@]}" --flag namespace )
- }
-}
-
-function _generateChcontextOptions
-{
- local vdir=$1
- local ctx hostname domainname
- local cap_opts
- local flag
-
- {
- read ctx <"$vdir"/context || :
- ## LEGACY ALERT
- read hostname <"$vdir"/uts/nodename || read hostname <"$vdir"/hostname || :
- read domainname <"$vdir"/uts/domainname || read domainname <"$vdir"/domainname || :
- } 2>/dev/null
-
- test -z "$S_CONTEXT" || ctx=$S_CONTEXT
-
- _generateCapabilityOptions "$vdir"
- _generateFlagOptions "$vdir"
-
- CHCONTEXT_OPTS=( $SILENT_OPT \
- "${CHCONTEXT_FLAG_OPTS[@]}" \
- "${CAP_OPTS[@]}" \
- --secure
- ${ctx:+--ctx "$ctx"} \
- ${hostname:+--hostname "$hostname"} \
- ${domainname:+--domainname "$domainname"} )
-
- OPTS_VCONTEXT_CREATE=( $SILENT_OPT \
- ${ctx:+--xid "$ctx"} )
- ## put '--secure' at front so that it can be overridden
- OPTS_VATTRIBUTE=( --secure "${OPTS_VATTRIBUTE[@]}" )
-}
-
-function _generateScheduleOptions
-{
- local vdir=$1
- local f="$vdir"/schedule
- test -e "$f" || return 0
-
- local fill_rate interval tokens tokens_min tokens_max prio_bias
- {
- {
- read fill_rate && \
- read interval && \
- read tokens && \
- read tokens_min && \
- read tokens_max && \
- read prio_bias || prio_bias=
- } <"$f"
- } 2>/dev/null
-
- test -n "$prio_bias" || {
- echo $"Bad content in '$f'; aborting..." >&2
- false
- }
-
- OPTS_VSCHED=( --fill-rate "$fill_rate" --interval "$interval" \
- --tokens "$tokens" --tokens_min "$tokens_min" \
- --tokens_max "$tokens_max" --priority-bias "$prio_bias" )
-}
-
-function _getInterfaceValue
-{
- local _giv_val=$1
- local _giv_dflt=$2
- shift 2
-
- local _giv_i
- local _giv_tmp
-
- for _giv_i; do
- read _giv_tmp <"$_giv_i/$_giv_val" && break || :
- done 2>/dev/null
-
- : ${_giv_tmp:=$_giv_dflt}
- eval $_giv_val=\$_giv_tmp
-}
-
-## Usage: _transformMask2Prefix <result-varname> <prefix> <mask>
-function _transformMask2Prefix
-{
- local _tm2p_tmp=$2
-
- test -n "$_tm2p_tmp" || {
- $_MASK2PREFIX "$3" || _tm2p_tmp=$?
- }
-
- eval $1=\$_tm2p_tmp
- return 0
-}
-
-function _addInterfaceCmd
-{
- eval INTERFACE_CMDS_${INTERFACE_CMDS_IDX}='( "$@" )'
- let ++INTERFACE_CMDS_IDX
-}
-
-## Usage: _generateMac <var> <iface> <ctx>
-function _generateMac
-{
- isNumber "$2" || {
- echo $"Interface basename '$iface' must be either a number, or the mac must be configured explicitly" >&2
- return 1
- }
-
- eval $1=$(printf "f0:ff:%02x:%02x:%02x:%02x" $[ (~($2>>8)) & 0xff ] $[ ($2 & 0xff) ] $[ ($3>>8) & 0xff ] $[ $3 & 0xff ])
-}
-
-## Usage: _processSingleInterface <interface-directory>
-function _processSingleInterface
-{
- local iface=$1
-
- local ip
- local dev
- local prefix
- local mask
- local bcast
- local name
- local scope
- local mac
- local extip
- local up="up"
-
- _getInterfaceValue ip '' "$iface"
- _getInterfaceValue extip '' "$iface" "$iface/.."
- _getInterfaceValue dev '' "$iface" "$iface/.."
- _getInterfaceValue prefix '' "$iface" "$iface/.."
- _getInterfaceValue mask '' "$iface" "$iface/.."
- _getInterfaceValue bcast '' "$iface" "$iface/.."
- _getInterfaceValue name '' "$iface"
- _getInterfaceValue scope '' "$iface" "$iface/.."
- _getInterfaceValue mac '' "$iface"
-
- test -n "$ip" || { echo $"Can not read ip for '$iface'" >&2; return 1; }
- test -n "$dev" -o -e "$iface"/nodev || {
- echo $"No device specified for '$iface'" >&2
- return 1;
- }
-
- test ! -e "$iface"/down || up=
-
- while true; do
- _transformMask2Prefix prefix "$prefix" "$mask"
- INTERFACES=( "${INTERFACES[@]}" "$ip${prefix:+/$prefix}" )
-
- test ! -e "$iface"/nodev || break
- ## LEGACY ALERT
- test ! -e "$iface"/only_ip || break
-
- case "$dev" in
- (*.*)
- test -d /proc/net/vlan || {
- echo -e $"VLAN device-name used, but vlan subsystem not enabled.\nTry to execute 'modprobe 8021q' before starting the vservers" >&2
- return 1
- }
- test -f /proc/net/vlan || {
- _addInterfaceCmd VCONFIG ${dev/./ }
- _addInterfaceCmd IP_ADDR 127.0.0.1/8 broadcast 127.255.255.255 dev "$dev"
- _addInterfaceCmd IP_LINK "$dev" $up
- }
- ;;
- esac
-
- if ! test -e "$iface"/indirect; then
- _addInterfaceCmd IP_ADDR "$ip${prefix:+/$prefix}" broadcast ${bcast:-+} ${name:+label "$dev:$name"} dev "$dev"
- #_addInterfaceCmd IP_ROUTE "$ip${prefix:+/$prefix}" dev "$dev"
- _addInterfaceCmd IP_LINK "$dev" $up
- elif ! test -n "$ctx"; then
- echo $"Using 'dummy' (indirect) for interface '$dev' requires a fixed context number; dynamic ctx are not supported" >&2
- return 1
- else
- test -z "$mac" || _generateMac mac "$(basename $iface)" "$ctx" || return 1
- _addInterfaceCmd MODPROBE dummy "$dev"
- _addInterfaceCmd IP_LINK dev dummy0 address "$mac"
- _addInterfaceCmd NAMEIF "$dev" "$mac"
- _addInterfaceCmd IP_ADDR "$ip${prefix:+/$prefix}" dev "$dev"
- test -z "$extip" || _addInterfaceCmd IPTABLES "$ip${prefix:+/$prefix}" ${name:+label "$dev:$name"} "$ctx" "$extip"
- fi
-
- break
- done
-}
-
-## Usage: _generateInterfaceOptions <vserver-directory>
-function _generateInterfaceOptions
-{
- local iface
- local ctx
-
- test ! -e "$1"/context || read ctx <"$1"/context
-
- for iface in "$1/interfaces/"*; do
- test -d "$iface" || continue
- test ! -e "$iface"/disabled || continue
-
- _processSingleInterface "$iface"
- done
- _HAVE_INTERFACE_OPTIONS=1
-}
-
-function enableInterfaces
-{
- local i=0
- declare -a var
-
- lock "$__LOCKDIR"/vserver.interfaces
-
- while test $i -lt $INTERFACE_CMDS_IDX; do
- eval var='( "${INTERFACE_CMDS_'$i'[@]}" )'
- local type=${var[0]}
- unset var[0]
-
- set -- "${var[@]}"
- case "$type" in
- IPTABLES) ;; ## TODO
- MODPROBE)
- local mod=$1
- local name=$2
- shift 2
- $_MODPROBE ${name:+-o "$name"} "$mod" "$@"
- ;;
- NAMEIF) $_NAMEIF "$@";;
- VCONFIG) $_VCONFIG add "$@";;
- IP_ADDR) $_IP addr add "$@";;
- IP_ADDR_FLUSH) $_IP addr flush "$@";;
- IP_LINK) $_IP link set "$@";;
- IP_ROUTE) $_IP route add "$@";;
- *) echo "Unknown interface-command type '$type'" >&2; false;;
- esac
-
- let ++i
- done
-
- unlock 1
-}
-
-function disableInterfaces
-{
- test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$1"
-
- local i=$INTERFACE_CMDS_IDX
- declare -a var
-
- lock "$__LOCKDIR"/vserver.interfaces
-
- while test $i -gt 0; do
- let --i || :
-
- eval var='( "${INTERFACE_CMDS_'$i'[@]}" )'
- local type=${var[0]}
- unset var[0]
-
- set -- "${var[@]}"
- case "$type" in
- IPTABLES) ;; ## TODO
- MODPROBE) $_RMMOD "${2:-$1}";;
- NAMEIF) ;;
- VCONFIG) $_VCONFIG rem "$@";;
- IP_ADDR) $_IP addr del "$@";;
- IP_ADDR_FLUSH) ;;
- IP_LINK) ;; ## Ignore the link-down command for now
- IP_ROUTE) $_IP route del "$@";;
- *) echo "Unknown interface-command type '$type'" >&2; false;;
- esac
- done
-
- unlock 1
-}
-
-## Usage: prepareInit <vserver-directory>
-function prepareInit
-{
- pushd "$1/vdir" >/dev/null
- case "$INITSTYLE" in
- sysv)
- { find var/run ! -type d -print0; \
- find var/lock ! -type d -print0; } | xargs -0r $_CHROOT_RM
- ;;
- plain)
- $_CHROOT_RM .autofsck forcefsck 2>/dev/null || :
- : | $_CHROOT_CAT fastboot 2>/dev/null || :
- ;;
- minit)
- ;;
- esac
- "${INITCMD_PREPARE[@]}"
- popd >/dev/null
-}
-
-## Usage: prepareInit <vserver-directory>
-function prepareStop
-{
- pushd "$1/vdir" >/dev/null
- case "$INITSTYLE" in
- (sysv)
- export PREVLEVEL=$RUNLEVEL_START # required by Debian's initscripts
- ;;
- esac
- "${STOPCMD_PREPARE[@]}"
- popd >/dev/null
-}
-
-
-function generateOptions
-{
- _generateInterfaceOptions "$1"
- test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
- _generateNiceCommand "$1"
- _generateInitOptions "$1"
- _generateChcontextOptions "$1"
- _generateScheduleOptions "$1"
-
- if test -n "$_IS_FAKEINIT"; then
- CHCONTEXT_INIT_OPTS=( --disconnect --flag fakeinit )
- OPTS_VCONTEXT_MIGRATE=( "${OPTS_VCONTEXT_MIGRATE[@]}" --initpid --disconnect )
- fi
-}
-
-function _mountVserverInternal
-{
- local fstab="$1"
- test -e "$fstab" || return 0
- shift
-
- pushd "$vdir" >/dev/null
- "$@" $_SECURE_MOUNT -a --chroot --fstab "$fstab" --rootfs no
- popd >/dev/null
-}
-
-function mountRootFS
-{
- local cfgdir=$1
- local vdir=$1/vdir
- local fstab="$cfgdir"/fstab
-
- test -e "$fstab" || return 0
- pushd "$vdir" >/dev/null
- $_SECURE_MOUNT -a --chroot --fstab "$fstab" --rootfs only -n
- popd >/dev/null
-}
-
-function mountVserver
-{
- local cfgdir=$1
- local ns_opt=$2
- local vdir=$1/vdir
- local mtab_src
-
- test -e "$cfgdir"/fstab -o \
- -e "$cfgdir"/fstab.local -o \
- -e "$cfgdir"/fstab.remote || return 0
-
- findObject -r mtab_src "$cfgdir"/apps/init/mtab "$__CONFDIR"/.defaults/init/mtab "$__PKGLIBDEFAULTDIR"/mtab /dev/null
-
- pushd "$vdir" >/dev/null
- $_CHROOT_CAT /etc/mtab <"$mtab_src"
- popd >/dev/null
-
- test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
-
- test -z "$NAMESPACE_CLEANUP" || isAvoidNamespace "$cfgdir" || \
- $_VNAMESPACE --cleanup
-
- _mountVserverInternal "$cfgdir"/fstab
- _mountVserverInternal "$cfgdir"/fstab.local
- _mountVserverInternal "$cfgdir"/fstab.remote $_CHBIND "${CHBIND_OPTS[@]}"
-
- isAvoidNamespace "$cfgdir" || \
- $_SECURE_MOUNT --rbind -n "$vdir" "/"
-}
-
-function _umountVserverInternal
-{
- local fstab="$1"
- test -e "$fstab" || return 0
- shift
-
- $_TAC "$fstab" | {
- is_ok=1
- while read src dst tmp; do
- test -n "$tmp" || continue
- case x"$src" in
- (x\#*) continue;;
- esac
-
-
- "$@" $_EXEC_CD "$dst" $_UMOUNT -lfn . || is_ok=
- done
- test -n "$is_ok"
- }
-}
-
-function umountVserver
-{
- local cfgdir=$1
- local vdir=$1/vdir
- local is_ok=1
-
- isAvoidNamespace "$cfgdir" || return 0
- test -e "$cfgdir"/fstab -o \
- -e "$cfgdir"/fstab.local || return 0
- test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
-
- pushd "$vdir/" >/dev/null || return 1
- _umountVserverInternal "$cfgdir"/fstab.local || is_ok=
- _umountVserverInternal "$cfgdir"/fstab $_CHBIND "${CHBIND_OPTS[@]}" || is_ok=
- popd >/dev/null || return 1
-
- test -n "$is_ok"
-}
-
-## Usage: waitForSync <vserver> <vshelper-fifo-varname>
-function initSync
-{
- test -z "$_NEED_VSHELPER_SYNC" || vshelper.initSync "$1" "$2"
-}
-
-## Usage: waitForSync <vserver> [<vshelper-fifo>]
-function waitForSync
-{
- local cfgdir=$1
- local fifo=$2
-
- if test -n "$_NEED_VSHELPER_SYNC"; then
- $_VSHELPER_SYNC "$fifo" "$VSHELPER_SYNC_TIMEOUT" || \
- warning $"\
-A timeout or other error occured while waiting for the synchronization
-signal from vserver '$VSERVER_NAME'.
-The vserver will be killed nevertheless..."
- elif test "${#INITCMD_STOP_SYNC[@]}" -ne 0; then
- "${INITCMD_STOP_SYNC[@]}" || \
- warning $"\
-Stop-synchronization for vserver '$VSERVER_NAME' failed. The vserver
-will be killed nevertheless..."
- fi
-
- test -z "$OPTION_FORCE_SYNC" -a ! -e "$cfgdir"/sync ||
- sleep 1
-}
-
-function _sourceWrap
-{
- local vdir name flavor start i already_handled base
- . "$@"
-}
-
-## Usage: execScriptlets <vserver-cfgdir> <vserver-name> <script-flavor>
-function execScriptlets
-{
- declare -r vdir=$1
- declare -r name=$2
- declare -r flavor=$3
- local base i
-
- for base in "$vdir"/scripts "$__CONFDIR"/.defaults/scripts; do
- local DONT_SKIP_DEFAULTS=
- local already_handled=
-
- for i in "$base/$flavor" "$base/$flavor.d"/*; do
- test -f "$i" -a -r "$i" || continue
- already_handled=1
- local start=
- test -x "$i" || start=_sourceWrap
- $start "$i" "$flavor" "$name"
- done
-
- test -z "$already_handled" -o -n "$DONT_SKIP_DEFAULTS" || break
- done
-}
-
-
-function sanityCheck
-{
- declare -r cfgdir=$1
-
- ! test -e "$cfgdir"/fstab.local ||
- warning $"\
-WARNING: 'fstab' will *not* be executed in the network context of the
- vserver anymore. Therefore, 'fstab.local' has the same functionality
- and is obsoleted. When you need the old behaviour, put the mounts
- into 'fstab.remote'"
-
- ! test -e "$cfgdir"/hostname -a ! -L "$cfgdir"/hostname ||
- warning $"\
-WARNING: The hostname is now configured in 'uts/nodename' but not in
- 'hostname'."
-
- ! test -e "$cfgdir"/domainname -a ! -L "$cfgdir"/domainname ||
- warning $"\
-WARNING: The domainname is now configured in 'uts/domainname' but not
- in 'domainname'." >&2
-
-
- local i
- for i in "$cfgdir"/interfaces/*/only_ip; do
- if test -e "$i"; then
- local iface
- iface=${i##$cfgdir/interfaces/}
- iface=${iface%%/only_ip}
- warning $"\
-WARNING: The 'only_ip' flag for interface '$iface' is deprecated; use
- 'nodev' instead of"
- fi
- done
-
- find "$cfgdir" -type f -exec "$_CHECK_UNIXFILE" '{}' ';'
-
- vshelper.doSanityCheck
-
- $_VSERVER_INFO - VERIFYCAP ||
- panic $"capabilities are not enabled in kernel-setup"
-}
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-
-lock "$__LOCKDIR"/vserver."$($_VSERVER_INFO "$VSERVER_DIR" CANONIFY)".startup
-
-if isVserverRunning "$VSERVER_DIR"; then
- warning $"vserver '$VSERVER_NAME' already running"
- exit 0
-fi
-
-function cleanup()
-{
- set +e
-
- test -z "$startsync_pipe" || $_RM -f "$startsync_pipe"
- test -z "$is_started" || { unlock; return 0; }
-
- if test -n "$is_configured" -a -z "$is_executed"; then
- warning $"
-An error occured while executing the vserver startup sequence; when
-there are no other messages, it is very likely that the init-script
-(${INITCMD_START[@]}) failed.
-
-Common causes are:
-* /etc/rc.d/rc on Fedora Core 1 and RH9 fails always; the 'apt-rpm' build
- method knows how to deal with this, but on existing installations,
- appending 'true' to this file will help."
- fi
-
- if test -n "$is_executed"; then
- warning $"
-An error occured after executing the vserver startup sequence. This
-means that some processes may exist in the created context and the
-manual execution of
-
- $_VSERVER '$VSERVER_DIR' stop
-
-is recommended to fix this."
- else
- warning $"
-
-Failed to start vserver '$VSERVER_NAME'"
- fi
-
- test -n "$OPTION_DEBUG" || exec 2>/dev/null >/dev/null
- test -z "$is_mounted" || umountVserver "$VSERVER_DIR" || :
- test -z "$have_interfaces" || disableInterfaces "$VSERVER_DIR" || :
-
- unlock || :
-}
-
-is_configured=
-is_executed=
-is_started=
-is_mounted=
-is_vshelper_init=
-have_interfaces=
-startsync_pipe=
-
-set -e
-trap "cleanup" EXIT
-
-sanityCheck "$VSERVER_DIR"
-
-mountRootFS "$VSERVER_DIR"
-generateOptions "$VSERVER_DIR"
-execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" prepre-start
-enableInterfaces "$VSERVER_DIR" && have_interfaces=1
-
-mountVserver "$VSERVER_DIR" && is_mounted=1
-prepareInit "$VSERVER_DIR"
-
-pushd "$VSERVER_DIR"/vdir/ >/dev/null
-execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" pre-start
-popd >/dev/null
-
-test -z "$OPTION_DEFAULTTTY" || setDefaultTTY "$VSERVER_DIR"
-
-pushd "$VSERVER_DIR"/vdir/ >/dev/null
-is_configured=1
-if $_VSERVER_INFO - FEATURE migrate; then
- ${NICE_CMD[@]} \
- $_CHBIND "${CHBIND_OPTS[@]}" -- \
- $_VCONTEXT --create "${OPTS_VCONTEXT_CREATE[@]}" -- \
- ${USE_VNAMESPACE:+$_VNAMESPACE --set -- } \
- $_VLIMIT --dir "$VSERVER_DIR"/rlimits --missingok -- \
- $_VSCHED --xid self "${OPTS_VSCHED[@]}" -- \
- $_VUNAME --xid self --dir "$VSERVER_DIR"/uts --missingok -- \
- "${VSERVER_EXTRA_CMDS[@]}" \
- $_VUNAME --xid self --set -t context="$VSERVER_DIR" -- \
- $_VATTRIBUTE --set "${OPTS_VATTRIBUTE[@]}" -- \
- $_SAVE_CTXINFO "$VSERVER_DIR" \
- $_ENV -i -- \
- $_VCONTEXT --migrate-self --endsetup --chroot $SILENT_OPT "${OPTS_VCONTEXT_MIGRATE[@]}" -- \
- "${INITCMD_START[@]}"
-else
- if test -n "$_IS_FAKEINIT"; then
- startsync_pipe=$($_MKTEMP /tmp/vserver-start.XXXXXX)
- $_RM -f "$startsync_pipe"
- $_MKFIFO -m600 "$startsync_pipe" ## safe, since mkfifo does not follow symlinks
- fi
-
- ${NICE_CMD[@]} \
- $_CHBIND "${CHBIND_OPTS[@]}" \
- $_EXEC_ULIMIT "$VSERVER_DIR/ulimits" \
- $_CHCONTEXT_COMPAT "${CHCONTEXT_OPTS[@]}" "${CHCONTEXT_INIT_OPTS[@]}" \
- $_SAVE_CTXINFO "$VSERVER_DIR" \
- $_ENV -i -- \
- $_CHAINECHO "${_IS_FAKEINIT:+$startsync_pipe}" "" \
- $_CAPCHROOT "${CAPCHROOT_OPTS[@]}" . \
- "${INITCMD_START[@]}"
-
- ## the additional synchronization step is needed since vshelper.doInit
- ## below might be executed before needed context information were
- ## saved by $_SAVE_CTXINFO
- ${_IS_FAKEINIT:+cat "$startsync_pipe"} >/dev/null
-fi
-is_executed=1
-
-"${INITCMD_START_SYNC[@]}"
-popd >/dev/null
-
-pushd "$VSERVER_DIR"/vdir/ >/dev/null
-execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" post-start
-popd >/dev/null
-
-is_vshelper_init=1
-! vshelper.isEnabled "" "$VSERVER_DIR" || vshelper.doInit "$VSERVER_DIR"
-
-is_started=1
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-
-lock "$__LOCKDIR"/vserver."$($_VSERVER_INFO "$VSERVER_DIR" CANONIFY)".startup
-
-if ! isVserverRunning "$VSERVER_DIR" S_CONTEXT; then
- warning $"vserver '$VSERVER_NAME' is not running" >&2
- test -n "$OPTION_DEBUG" || exec 2>/dev/null >/dev/null
- umountVserver "$VSERVER_DIR" || :
- disableInterfaces "$VSERVER_DIR" || :
- unlock
- exit 0
-fi
-
-function cleanup
-{
- set +e
- unlock
-
- test ! -p "$sync_fifo" || {
- $_RM -f "$sync_fifo"
- $_RMDIR $($_DIRNAME "$sync_fifo")
- }
-}
-
-sync_fifo=
-trap "cleanup" EXIT
-
-set -e
-generateOptions "$VSERVER_DIR"
-set +e
-
-vshelper.doDestroy "$VSERVER_DIR" "$S_CONTEXT"
-initSync "$VSERVER_DIR" sync_fifo
-prepareStop "$VSERVER_DIR"
-
-cd "$VSERVER_DIR"/vdir/
-execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" pre-stop
-cd "$VSERVER_DIR"/vdir/
-
-test -z "$OPTION_DEFAULTTTY" || setDefaultTTY "$VSERVER_DIR"
-
-fail=
-if test -n "$_IS_FAKEINIT" && \
- $_VSERVER_INFO - FEATURE vkill && \
- initpid=$($_VSERVER_INFO "$S_CONTEXT" INITPID 2>/dev/null); then
- $_VKILL -s INT --xid "$S_CONTEXT" -- 1 "$initpid" || fail=1
- ## HACK: remove the 'initpid' stuff above when PID virtualization
- ## is implemented
-elif $_VSERVER_INFO - FEATURE migrate; then
- "${NICE_CMD[@]}" \
- ${USE_VNAMESPACE:+$_VNAMESPACE --enter "$S_CONTEXT" -- } \
- $_VCONTEXT $SILENT_OPT --migrate --chroot --xid "$S_CONTEXT" -- \
- "${INITCMD_STOP[@]}" || fail=1
-else
- "${NICE_CMD[@]}" \
- "$_CHBIND" "${CHBIND_OPTS[@]}" \
- "$_EXEC_ULIMIT" "$VSERVER_DIR/ulimits" \
- ${USE_VNAMESPACE:+$_VNAMESPACE --enter "$S_CONTEXT"} \
- $_CHCONTEXT_COMPAT "${CHCONTEXT_OPTS[@]}" \
- "$_CAPCHROOT" "${CAPCHROOT_OPTS[@]}" "." \
- "${INITCMD_STOP[@]}" || fail=1
-fi
-
-test -n "$fail" || waitForSync "$VSERVER_DIR" "$sync_fifo"
-
-vshelper.doDestroy "$VSERVER_DIR" "$S_CONTEXT"
-sendKillSequence "$S_CONTEXT" "${INITKILL_SEQ[@]}"
-
-## Small hack... isVserverRunning removes stale runfiles as a sideeffect
-! isVserverRunning "$VSERVER_DIR" || \
- echo $"Vserver '$VSERVER_DIR' still running unexpectedly; please investigate it manually..." >&2
-
-execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" post-stop
-
-umountVserver "$VSERVER_DIR" || :
-disableInterfaces "$VSERVER_DIR"
-
-execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" postpost-stop
+++ /dev/null
-# $Id$ --*- sh -*--
-
-# 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.
-
-is_stopped=
-isVserverRunning "$VSERVER_DIR" S_CONTEXT || is_stopped=1
-test -z "$is_stopped" -o "$OPTION_INSECURE" || {
- echo $"'vserver ... suexec' is support for running vservers only; aborting..." >&2
- exit 1
-}
-generateOptions "$VSERVER_DIR"
-
-user=$1
-shift
-
-cd "$VSERVER_DIR"/vdir/
-
-if $_VSERVER_INFO - FEATURE migrate; then
- if test -z "$is_stopped"; then
- exec \
- $_CHBIND "${CHBIND_OPTS[@]}" \
- ${USE_VNAMESPACE:+$_VNAMESPACE --enter "$S_CONTEXT" -- } \
- $_VCONTEXT $SILENT_OPT --migrate --chroot --xid "$S_CONTEXT" --uid "$user" -- \
- "$@"
- else
- exec \
- $_CHBIND "${CHBIND_OPTS[@]}" \
- $_VCONTEXT --create "${OPTS_VCONTEXT_CREATE[@]}" -- \
- $_VUNAME --xid self --dir "$VSERVER_DIR"/uts --missingok -- \
- $_VUNAME --xid self --set -t context="$VSERVER_DIR" -- \
- $_VCONTEXT --migrate-self --endsetup --chroot $SILENT_OPT -- \
- "$@"
- fi
-else
- exec \
- "${NICE_CMD[@]}" \
- "$_CHBIND" "${CHBIND_OPTS[@]}" \
- "$_EXEC_ULIMIT" "$VSERVER_DIR/ulimits" \
- ${USE_VNAMESPACE:+$_VNAMESPACE --enter "$S_CONTEXT" --} \
- $_CHCONTEXT_COMPAT "${CHCONTEXT_OPTS[@]}" -- \
- "$_CAPCHROOT" "${CAPCHROOT_OPTS[@]}" --suid "$user" . \
- "$@"
-fi
+++ /dev/null
-#!/bin/sh
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on vservers.grabinfo.sh by Jacques Gelinas
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-# Produce some XML statistics about vservers
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-cd $__DEFAULT_VSERVERDIR
-for vserv in *
-do
- if [ -f /etc/vservers/$vserv.conf ] ; then
- . /etc/vservers/$vserv.conf
- echo "<m:vserver name=\"$vserv\" onboot=\"$ONBOOT\" HOSTNAME=\"$S_HOSTNAME\">"
- for ip in $IPROOT
- do
- case $ip in
- *:*)
- echo $ip | tr ':' ' ' | (read a b; echo " <m:ip num=\"$b\"/>")
- ;;
- *)
- echo " <m:ip num=\"$ip\"/>"
- ;;
- esac
- done
- echo " <status>"
- $_VSERVER $vserv status
- echo " </status>"
- echo "</m:vserver>"
- fi
-done
-
+++ /dev/null
-#! /usr/lib/util-vserver/sigexec /bin/bash
-
-# Copyright (C) 2004 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.
-
-## Usage: vshelper <xid> <action> <args>
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-function showHelp
-{
- echo $"\
-Usage: vshelper <xid> <event> <args>*
-
-Report bugs to <$PACKAGE_BUGREPORT>."
- exit 0
-}
-
-function showVersion
-{
- echo $"\
-vshelper $PACKAGE_VERSION -- userspace reboot helper
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2004 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit 0
-}
-
-function doInternalMethod
-{
- local method=$1
- case "$method" in
- (restart)
- case "$ACTION" in
- (restart)
- logging $"Restarting vserver '$VSERVER'"
- execute $_VSERVER --defaulttty "$VSERVER" restart
- ;;
- (halt|poweroff)
- logging $"Stopping vserver '$VSERVER'"
- execute $_VSERVER --defaulttty "$VSERVER" stop
- ;;
- (swsusp)
- ## TODO: any senseful action here? Perhaps shutdown scheduler for it?
- exit 0
- ;;
- (restart2) ;;
- (*)
- warning $"Unknown action '$ACTION' for vserver '$VSERVER'"
- exit 1
- esac
- ;;
-
- (sync)
- local f=${METHOD_ARGS[0]}
- test -n "$f" ||
- panic $"Insufficent arguments for method '$method' and vserver '$VSERVER'"
-
- test -p "$f" ||
- panic $"File '$f' which is required for synchronisation of vserver '$VSERVER' is not a pipe"
-
- echo "$ACTION" >"$f"
- ;;
-
- (*)
- local script
- findObject -x script "$__CONFDIR"/.defaults/apps/vshelper-methods/"$method" "$__PKGLIBDIR"/vshelper-methods/"$method" ''
-
- test -n '$script' || {
- warning $"No handler for internal method '$method' found"
- exit 1
- }
-
- export VSERVER
- execute "$script" "${ARGS[@]}"
- esac
-}
-
-function doDefaultMethod
-{
- local handler
-
- vshelper.getHandler handler "$VSERVER" "$ACTION" || {
- warning $"No handler configured for action '$ACTION' on vserver '$VSERVER'"
- exit 1
- }
-
- case "$handler" in
- (/*) execute "$handler" "${ARGS[@]}";;
- (:*) doInternalMethod "${handler##:}" "$@";;
- esac
-}
-
-#===========
-
-test "$1" != '--version' || showVersion
-test "$1" != '--help' || showHelp
-
-if ! tty -s; then
- findObject -e _VS_LOGFILE "$__CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
- findObject -e _VS_ERRFILE "$__CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
-
- exec </dev/null
- exec >>$_VS_LOGFILE
- exec 2>>$_VS_ERRFILE
-fi
-
-logging "$(date): vshelper $*"
-
-test "$#" -ge 2 ||
- panic $"vshelper called with missing arguments; try '--help' for more information"
-
-
-vshelper.isEnabled || exit 0
-! vshelper.isDebug || set -x
-
-set -eu
-
-if $_VSERVER_INFO - FEATURE vshelper0; then
- declare -r XID=$1
- declare -r ACTION=$2
-elif $_VSERVER_INFO - FEATURE vshelper; then
- declare -r ACTION=$1
- declare -r XID=$2
-else
- panic $"vshelper functionality not supported by kernel"
-fi
-
-findObject -x delegate "$__CONFDIR"/.defaults/apps/vshelper-delegate/"$ACTION" "$__PKGLIBDIR"/vshelper-delegate/"$ACTION" ''
-test -e "$delegate" && exec -a "$ACTION" "$delegate" "$@"
-
-this_xid=$($_VSERVER_INFO - XID)
-pxid=
-responsible_xid=$XID
-while true; do
- pxid=$($_VSERVER_INFO "$responsible_xid" PXID) || break
- test "$pxid" -ne "$this_xid" || break
- responsible_xid=$pxid
-done
-
-vserver_id=$($_VSERVER_INFO "$responsible_xid" ID) ||
- panic $"No responsible vserver found for xid '$responsible_xid' ($XID); aborting..."
-
-test "$XID" = "$responsible_xid" || {
- logging "Giving 'vshelper' task for '$XID' to parent vserver '$vserver_id' ($responsible_xid)"
- execute $_VSERVER "$vserver_id" exec $_VSHELPER "$@"
-}
-
-#===========
-
-ARGS=( "$@" )
-
-declare -a state
-getFileArray state "$__VSHELPERSTATEDIR/$XID" && test ${#state[@]} -ge 2 || {
- logging "'vshelper' not configured for xid '$XID'"
- exit 0
-}
-
-declare -r VSERVER=${state[0]}
-
-cfg_xid=$($_VSERVER_INFO "${state[0]}" CONTEXT false) ||
- panic $"Configured vserver '$VSERVER' does not seem to run; aborting..."
-
-test "$cfg_xid" = "$XID" ||
- panic $"Configured ($cfg_xid) and actual ($XID) xid for vserver '$VSERVER' are mismatching; aborting..."
-
-cur_xid=$($_VSERVER_INFO "$VSERVER" CONTEXT false) ||
- panic $"Vserver '$VSERVER' with '$XID' does not seem to run; strange..."
-
-test "$cur_xid" = "$XID" ||
- panic $"Expected ($XID) and actual ($cur_xid) xid for vserver '$VSERVER' are mismatching; strange..."
-
-
-method=${state[1]}
-if test "${#state[@]}" -gt 2; then
- unset state[0] state[1]
- declare -ra METHOD_ARGS=( "${state[@]}" )
-else
- declare -ra METHOD_ARGS=()
-fi
-
-case "$method" in
- (default) doDefaultMethod "$@";;
- (sync) doInternalMethod "$method" "$@";;
- (*) panic $"Unknown method '$method' used by vserver '$VSERVER'";;
-esac
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# Copyright (C) 2005 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-
-function showHelp()
-{
- echo \
-$"Usage: $0 [--quiet|-q] [--debug] <cmd> [--] <vserver-name>* [--all] -- <params>+
-
-Execute <cmd> <vserver> <params>* foreach vserver.
-
-Report bugs to <$PACKAGE_BUGREPORT>."
- exit 0
-}
-
-function showVersion()
-{
- echo \
-$"vsomething $PACKAGE_VERSION -- execute something for a set of vservers
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2005 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit 0
-}
-
-
-is_quiet=
-declare -a vservers=()
-
-tmp=$(getopt -o +q --long help,version,debug,quiet -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-while true; do
- case "$1" in
- (--help) showHelp $0 ;;
- (--version) showVersion ;;
- (--debug) set -x;;
- (--quiet|-q) is_quiet=1 ;;
- (--) shift; break;;
- (*) echo $"vserver: internal error; arg=='$1'" >&2; exit 1;;
- esac
- shift
-done
-
-test "$#" -ge 1 || \
- panic $"vsomething: no operation specified; try '--help' for more information"
-
-cmd=$1
-title=${VSOMETHING_TITLE:-$cmd}
-shift
-
-while test "$#" -ge 1; do
- case "$1" in
- --) shift; break;;
- --all)
- getAllVservers tmp
- vservers=( "${vservers[@]}" "${tmp[@]}" )
- ;;
- *) vservers=( "${vservers[@]}" "$1" )
- esac
- shift
-done
-
-
-test "${#vservers[@]}" -ne 1 || is_quiet=1
-
-
-cnt=0
-res=255
-for i in "${vservers[@]}"; do
- cnt=$[ cnt + 1 ]
-
- test -n "$is_quiet" || {
- colorize bold echo -n "$title: operating on vserver "
- colorize bold colorize emph echo "$i"
- xtermTitle "$title: operating on vserver '$i' [$cnt/${#vservers[@]}]"
- }
-
- if test -n "$VSOMETHING_PKGMGMT"; then
- if pkgmgmt.isInternal "$i"; then
- $_VSERVER "$i" exec "$cmd" "$@"
- else
- callInNamespace "$i" \
- "$_VNAMESPACE" --new -- "$VSOMETHING_WORKER" "$i" "$@"
- fi
- else
- "$cmd" "$i" "$@"
- fi
-
- res=$?
-
- test $res -eq 0 -o -n "$is_quiet" || {
- colorize error echo -n $"$title failed on vserver '$i' with errorcode $res"
- echo
- }
-
- test -n "$is_quiet" || echo
-done
-
-test "$cnt" -ge 0 || warning $"No vservers specified"
-exit $res
+++ /dev/null
-#!/bin/sh
-
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on vsyswrapper by Jacques Gelinas
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-# Helper script for all the v_xxx scripts
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-if [ $# = 0 ] ; then
- echo vsysvwrapper service_name >&2
- exit 6
-else
- SERVICE=$1
- shift
- IP=eth0
- if [ -f /etc/vservices/$SERVICE.conf ] ; then
- . /etc/vservices/$SERVICE.conf
- fi
- IPOPT=
- for oneip in $IP
- do
- IPOPT="$IPOPT --ip $oneip"
- done
- echo exec $CHBIND $IPOPT /etc/init.d/$SERVICE "$@"
- exec $CHBIND $IPOPT /etc/init.d/$SERVICE "$@"
-fi
+++ /dev/null
-#!/bin/sh
-
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-# based on vtop by Jacques Gelinas
-#
-# 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; either version 2, or (at your option)
-# any later version.
-#
-# 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.
-
-#Presents the processes running in all virtual servers
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-exec $__SBINDIR/chcontext --silent --ctx 1 top "$@"
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# Copyright (C) 2005 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.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-
-function showHelp()
-{
- echo \
-$"Usage: $0 <vserver-name>* [--all] -- <params>+
-
-Report bugs to <$PACKAGE_BUGREPORT>."
- exit 0
-}
-
-function showVersion()
-{
- echo \
-$"vyum $PACKAGE_VERSION -- yum for vservers
-This program is part of $PACKAGE_STRING
-
-Copyright (C) 2005 Enrico Scholz
-This program is free software; you may redistribute it under the terms of
-the GNU General Public License. This program has absolutely no warranty."
- exit 0
-}
-
-tmp=$(getopt -o +q --long help,version,debug,quiet,all -n "$0" -- "$@") || exit 1
-eval set -- "$tmp"
-
-declare -a send_through yum_opts
-
-while true; do
- case "$1" in
- (--help) showHelp $0 ;;
- (--version) showVersion ;;
- (--debug) send_through=( "${send_through[@]}" "$1" ); set -x;;
- (--quiet|-q) send_through=( "${send_through[@]}" "$1" );;
- (--all) yum_opts=( "${yum_opts[@]}" "$1" );;
- (--) shift; break;;
- (*) echo $"vyum: internal error; arg=='$1'" >&2; exit 1;;
- esac
- shift
-done
-
-VSOMETHING_TITLE=vyum
-VSOMETHING_WORKER=$_VYUM_WORKER
-VSOMETHING_PKGMGMT=1
-
-export VSOMETHING_TITLE VSOMETHING_WORKER VSOMETHING_PKGMGMT
-
-test ${#yum_opts[@]} -eq 0 || yum_opts=( "${yum_opts[@]}" -- )
-exec $_VSOMETHING "${send_through[@]}" yum "${yum_opts[@]}" "$@"
+++ /dev/null
-#! /bin/bash
-# $Id$
-
-# 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.
-
-set -e
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-. "$_LIB_FUNCTIONS"
-
-vserver=$1
-shift
-
-pkgInit "$vserver" rpm yum
-rpmFake.init "$vserver"
-
-test -z "$_YUM" || {
- warning $"The environment variable \$_YUM is not supported anymore; please use \$YUM instead of"
- ${YUM:=$_YUM}
-}
-
-yum=${YUM:-yum}
-case $(yum --version) in
- (2.[0123]*) conf=yum-hack.conf;;
- (*) conf=yum.conf;;
-esac
-
-rpmFake.exec $yum \
- -c "$YUMETCDIR/${YUM_CONF:-$conf}" \
- --installroot="$VDIR" \
- "$@"
+++ /dev/null
-.buexcl
-.deps
-.dirstamp
-.gdb_history
-.libs
-capchroot
-chain-echo
-chbind
-chcontext
-chcontext-compat
-check-unixfile
-chroot-cat
-chroot-rm
-chxid
-clearenv
-enter-namespace
-exec-cd
-exec-ulimit
-fakerunlevel
-filetime
-ifspec
-keep-ctx-alive
-listdevip
-lockfile
-lsxid
-mask2prefix
-new-namespace
-parserpmdump
-pipe-sync
-readlink
-rebootmgr
-reducecap
-rpm-fake-resolver
-rpm-fake.la
-save_ctxinfo
-secure-mount
-setattr
-setctxlimit
-showattr
-showperm
-sigexec
-src_rpm_fake_la-rpm-fake.lo
-vattribute
-vbuild
-vcheck
-vcontext
-vcopy
-vdlimit
-vdu
-vfiles
-vhashify
-vkill
-vlimit
-vnamespace
-vps
-vreboot
-vrsetup
-vsched
-vschedule
-vserver-info
-vserver-stat
-vshelper-sync
-vuname
-vunify
+++ /dev/null
-## $Id$ -*- makefile -*-
-
-## Copyright (C) 2003,2004 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; either version 2, or (at your option)
-## any later version.
-##
-## 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_sbin_CXX_PROGS = src/vfiles
-src_pkglib_CXX_PROGS = src/vbuild src/vcheck
-
-src_pkglib_C99_PROGS = src/vunify src/vcopy
-
-
-AM_INSTALLCHECK_STD_OPTIONS_EXEMPT += \
- src/parserpmdump \
- src/showperm \
- src/vbuild \
- src/vcheck \
- src/vreboot \
- src/save_ctxinfo \
- src/mask2prefix \
- src/chroot-cat \
- src/ifspec \
- src/rebootmgr \
- src/vdu \
- src/vfiles
-
-DIETPROGS += src/chcontext-compat \
- src/capchroot \
- src/chain-echo \
- src/check-unixfile \
- src/filetime \
- src/lockfile \
- src/readlink \
- src/secure-mount \
- src/save_ctxinfo \
- src/mask2prefix \
- src/chbind \
- src/chroot-cat \
- src/chroot-rm \
- src/exec-cd \
- src/fakerunlevel \
- src/keep-ctx-alive \
- src/exec-ulimit \
- src/vps \
- src/lsxid \
- src/chxid \
- src/reducecap \
- src/showattr \
- src/setattr \
- src/sigexec \
- src/vattribute \
- src/vlimit \
- src/vnamespace \
- src/vunify \
- src/vuname \
- src/rpm-fake-resolver \
- src/vcontext \
- src/vcopy \
- src/vkill \
- src/vsched \
- src/vshelper-sync \
- src/vrsetup \
- src/vserver-stat \
- src/vserver-info \
- src/vdlimit
-
-if ENSC_CAN_BEECRYPT_WITH_DIETLIBC
-DIETPROGS += src/vhashify
-endif
-
-noinst_HEADERS += src/vutil.h src/vutil.p \
- src/capability-compat.h \
- src/util.h \
- src/fstool.h \
- src/compat-pivot_root.h \
- src/stack-start.h \
- src/vcopy-init.hc \
- src/vunify.h \
- src/vunify-init.hc \
- src/vhashify.h \
- src/vhashify-init.hc \
- src/vserver-visitdir.hc \
- src/context-sync.hc \
- src/vserver.hh
-
-pkglib_PROGRAMS += src/capchroot \
- src/chain-echo \
- src/chcontext-compat \
- src/check-unixfile \
- src/chroot-cat \
- src/chroot-rm \
- src/fakerunlevel \
- src/filetime \
- src/keep-ctx-alive \
- src/lockfile \
- src/readlink \
- src/save_ctxinfo \
- src/secure-mount \
- src/mask2prefix \
- src/exec-ulimit \
- src/rpm-fake-resolver \
- src/vshelper-sync \
- src/sigexec \
- $(src_pkglib_C99_X_PROGS) \
- $(src_pkglib_CXX_X_PROGS)
-
-if ENSC_HAVE_C99_COMPILER
-if ENSC_HAVE_BEECRYPT
-pkglib_PROGRAMS += src/vhashify
-endif ENSC_HAVE_BEECRYPT
-endif ENSC_HAVE_C99_COMPILER
-
-legacy_PROGRAMS += src/ifspec \
- src/listdevip \
- src/parserpmdump \
- src/rebootmgr \
- src/showperm \
- src/vreboot
-
-pkglib_LTLIBRARIES += src/rpm-fake.la
-
-sbin_PROGRAMS += src/chbind \
- src/exec-cd \
- src/lsxid \
- src/chxid \
- src/vps \
- src/showattr \
- src/setattr \
- src/reducecap \
- src/vdu \
- src/vattribute \
- src/vcontext \
- src/vlimit \
- src/vkill \
- src/vnamespace \
- src/vrsetup \
- src/vsched \
- src/vserver-stat \
- src/vserver-info \
- src/vuname \
- $(src_sbin_CXX_X_PROGS)
-
-if ENSC_HAVE_C99_COMPILER
-sbin_PROGRAMS += src/vdlimit
-endif
-
-
-src_capchroot_SOURCES = src/capchroot.c
-src_capchroot_LDADD = $(VSERVER_LDADDS)
-src_capchroot_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_chbind_SOURCES = src/chbind.c
-src_chbind_LDADD = $(VSERVER_LDADDS)
-src_chbind_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_chcontext_compat_SOURCES = src/chcontext.c
-src_chcontext_compat_LDADD = $(VSERVER_LDADDS) $(LIBINTERNAL)
-src_chcontext_compat_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vcontext_SOURCES = src/vcontext.c
-src_vcontext_LDADD = $(VSERVER_LDADDS) $(LIBINTERNAL)
-src_vcontext_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vsched_SOURCES = src/vsched.c
-src_vsched_LDADD = $(VSERVER_LDADDS)
-src_vsched_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_filetime_SOURCES = src/filetime.c
-src_filetime_LDADD = $(VSERVER_LDADDS)
-src_filetime_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_chain_echo_SOURCES = src/chain-echo.c
-src_chroot_cat_SOURCES = src/chroot-cat.c
-src_chroot_rm_SOURCES = src/chroot-rm.c
-src_exec_cd_SOURCES = src/exec-cd.c
-src_fakerunlevel_SOURCES = src/fakerunlevel.c
-src_ifspec_SOURCES = src/ifspec.c
-src_listdevip_SOURCES = src/listdevip.c
-src_lockfile_SOURCES = src/lockfile.c
-src_parserpmdump_SOURCES = src/parserpmdump.c
-src_readlink_SOURCES = src/readlink.c
-src_rebootmgr_SOURCES = src/rebootmgr.c
-src_exec_ulimit_SOURCES = src/exec-ulimit.c
-src_vshelper_sync_SOURCES = src/vshelper-sync.c
-
-src_reducecap_SOURCES = src/reducecap.c
-src_reducecap_LDADD = $(VSERVER_LDADDS)
-src_reducecap_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vkill_SOURCES = src/vkill.c
-src_vkill_LDADD = $(VSERVER_LDADDS)
-src_vkill_LDFLAGS = $(VSERVER_LDFLGS)
-src_vkill_CPPFLAGS = $(AM_CPPFLAGS) -DLEGACYDIR=\"$(legacydir)\"
-
-src_vlimit_SOURCES = src/vlimit.c
-src_vlimit_LDADD = $(VSERVER_LDADDS)
-src_vlimit_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_save_ctxinfo_SOURCES = src/save_ctxinfo.c
-src_save_ctxinfo_LDADD = $(VSERVER_LDADDS)
-src_save_ctxinfo_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vdu_SOURCES = src/vdu.c
-src_vreboot_SOURCES = src/vreboot.c
-
-src_secure_mount_SOURCES = src/secure-mount.c
-src_secure_mount_LDADD = $(VSERVER_LDADDS)
-src_secure_mount_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vattribute_SOURCES = src/vattribute.c
-src_vattribute_LDADD = $(VSERVER_LDADDS)
-src_vattribute_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vnamespace_SOURCES = src/vnamespace.c
-src_vnamespace_LDADD = $(VSERVER_LDADDS) $(LIBINTERNAL)
-src_vnamespace_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_rpm_fake_resolver_SOURCES = src/rpm-fake-resolver.c
-src_rpm_fake_resolver_LDADD = $(VSERVER_LDADDS)
-src_rpm_fake_resolver_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_mask2prefix_SOURCES = src/mask2prefix.c
-
-src_vps_SOURCES = src/vps.c
-src_vps_LDADD = $(LIBINTERNAL) $(VSERVER_LDADDS)
-src_vps_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vserver_info_SOURCES = src/vserver-info.c
-src_vserver_info_LDADD = $(LIBINTERNAL) $(VSERVER_LDADDS)
-src_vserver_info_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vserver_stat_SOURCES = src/vserver-stat.c
-src_vserver_stat_LDADD = $(LIBINTERNAL) $(VSERVER_LDADDS) $(LIBENSCVECTOR)
-src_vserver_stat_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vfiles_SOURCES = src/vfiles.cc src/vutil.cc src/vserver.cc
-src_vbuild_SOURCES = src/vbuild.cc src/vutil.cc src/vserver.cc
-src_vcheck_SOURCES = src/vcheck.cc src/vutil.cc src/vserver.cc
-
-src_lsxid_SOURCES = src/fstool.c src/lsxid.c
-src_lsxid_LDADD = $(LIBINTERNAL) $(VSERVER_LDADDS) $(LIBENSCVECTOR)
-src_lsxid_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_chxid_SOURCES = src/fstool.c src/chxid.c
-src_chxid_LDADD = $(LIBINTERNAL) $(VSERVER_LDADDS)
-src_chxid_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_showattr_SOURCES = src/fstool.c src/showattr.c
-src_showattr_LDADD = $(LIBINTERNAL) $(VSERVER_LDADDS)
-src_showattr_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_setattr_SOURCES = src/fstool.c src/setattr.c
-src_setattr_LDADD = $(LIBINTERNAL) $(VSERVER_LDADDS)
-src_setattr_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_keep_ctx_alive_SOURCES = src/keep-ctx-alive.c
-src_keep_ctx_alive_LDADD = $(VSERVER_LDADDS)
-src_keep_ctx_alive_LDFLAGS = $(VSERVER_LDFLGS)
-
-
-src_vcopy_SOURCES = src/vcopy.c
-src_vcopy_LDADD = $(LIBINTERNAL) $(VSERVER_LDADDS)
-src_vcopy_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vunify_SOURCES = src/vunify.c
-src_vunify_LDADD = $(LIBINTERNAL) $(VSERVER_LDADDS)
-src_vunify_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_vhashify_SOURCES = src/vhashify.c
-if ENSC_CAN_BEECRYPT_WITH_DIETLIBC
-src_vhashify_LDADD = $(LIBINTERNAL) $(LIBENSCVECTOR) -lbeecrypt $(VSERVER_LDADDS)
-src_vhashify_LDFLAGS = $(VSERVER_LDFLGS)
-else
-src_vhashify_LDADD = $(LIBINTERNAL_GLIBC) $(LIBENSCVECTOR_GLIBC) $(LIBVSERVER_GLIBC) -lbeecrypt
-src_vhashify_LDFLAGS =
-endif
-
-src_vuname_SOURCES = src/vuname.c
-src_vuname_LDADD = $(VSERVER_LDADDS)
-src_vuname_LDFLAGS = $(VSERVER_LDFLGS)
-
-src_rpm_fake_la_SOURCES = src/rpm-fake.c
-src_rpm_fake_la_CFLAGS = $(AM_CFLAGS)
-src_rpm_fake_la_LDFLAGS = -module -avoid-version -rpath $(pkglibdir)
-src_rpm_fake_la_LIBADD = $(LIBVSERVER_GLIBC) -ldl
-
-src_vdlimit_SOURCES = src/vdlimit.c
-src_vdlimit_LDADD = $(VSERVER_LDADDS)
-src_vdlimit_LDFLAGS = $(VSERVER_LDFLGS)
-
-EXTRA_PROGRAMS += $(src_sbin_CXX_PROGS) $(src_pkglib_CXX_PROGS)
-
-TESTS_ENVIRONMENT += srctestsuitedir=$(top_builddir)/src/testsuite
-
-if ENSC_HAVE_C99_COMPILER
-src_sbin_C99_X_PROGS = $(src_sbin_C99_PROGS)
-src_pkglib_C99_X_PROGS = $(src_pkglib_C99_PROGS)
-else
-src_sbin_C99_X_PROGS =
-src_pkglib_C99_X_PROGS =
-endif
-
-if ENSC_HAVE_CXX_COMPILER
-src_sbin_CXX_X_PROGS = $(src_sbin_CXX_PROGS)
-src_pkglib_CXX_X_PROGS = $(src_pkglib_CXX_PROGS)
-else
-src_sbin_CXX_X_PROGS =
-src_pkglib_CXX_X_PROGS =
-endif
-
-install-exec-hook: src_install_exec_hook
-
-src_install_exec_hook:
- -rm -f $(DESTDIR)$(pkglibdir)/rpm-fake.a $(DESTDIR)$(pkglibdir)/rpm-fake.la
-
-include $(top_srcdir)/src/testsuite/Makefile-files
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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
-
-#ifdef HAVE_SYS_CAPABILITY_H
-# include <sys/capability.h>
-#else
-# include <linux/capability.h>
-
-extern int capget (struct __user_cap_header_struct *, struct __user_cap_data_struct *);
-extern int capset (struct __user_cap_header_struct *, struct __user_cap_data_struct *);
-
-#endif
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on capchroot.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- This chroot command does very little. Once the chroot
- system call is executed, it (option) remove the CAP_SYS_CHROOT
- capability. Then it executes its argument
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "vserver.h"
-#include "util.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <pwd.h>
-#include <grp.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <libgen.h>
-
-#define ENSC_WRAPPERS_PREFIX "capchroot: "
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_VSERVER 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-#define CMD_NOCHROOT 0x2000
-#define CMD_SUID 0x2001
-
-int wrapper_exit_code = 255;
-
-static struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "nochroot", no_argument, 0, CMD_NOCHROOT },
- { "suid", required_argument, 0, CMD_SUID },
- {0,0,0,0}
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- VSERVER_DECLARE_CMD(cmd);
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " --nochroot [--suid <user>] [--] <directory> <command> <args>*\n"
- "\n"
- "Options:\n"
- " --nochroot ... remove the CAP_SYS_CHROOT capability\n"
- " after the chroot system call.\n"
- " --suid <user> ... switch to a different user (in the vserver\n"
- " context) before executing the command.\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "capchroot " VERSION " -- a capability aware chroot\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-setUser(char const *user)
-{
- struct passwd *p = 0;
- if (user!=0 && strcmp(user, "root")!=0) {
- errno = 0;
- p = getpwnam(user);
- if (p==0) {
- if (errno==0) errno = ENOENT;
- PERROR_Q(ENSC_WRAPPERS_PREFIX "getpwnam", user);
- exit(wrapper_exit_code);
- }
- }
-
- if (p!=0) {
- Esetgroups(1, &p->pw_gid);
- Esetgid(p->pw_gid);
- Esetuid(p->pw_uid);
-
- if (getuid()!=p->pw_uid || getgid()!=p->pw_gid) {
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "Something went wrong while changing uid; expected uid/gid do not match the actual one\n");
- exit(wrapper_exit_code);
- }
- }
-}
-
-int main (int argc, char *argv[])
-{
- bool nochroot = false;
- char const * suid_user = 0;
-
- while (1) {
- int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_NOCHROOT : nochroot = true; break;
- case CMD_SUID : suid_user = optarg; break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- if (optind==argc)
- WRITE_MSG(2, "No directory specified; try '--help' for more information\n");
- else if (optind+1==argc)
- WRITE_MSG(2, "No command specified; try '--help' for more information\n");
- else {
- // We resolve the UID before doing the chroot.
- // If we do the getpwnam after the chroot, we will end
- // up loading shared object from the vserver.
- // This is causing two kind of problem: Incompatibilities
- // and also a security flaw. The shared objects in the vserver
- // may be tweaked to get control of the root server ...
- getpwnam("root");
- Echroot(argv[optind]);
- if (nochroot)
- Evc_new_s_context(VC_SAMECTX, 1<<VC_CAP_SYS_CHROOT,0);
- setUser(suid_user);
- EexecvpD(argv[optind+1], argv+optind+1);
- }
-
- return EXIT_FAILURE;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#define ENSC_WRAPPERS_PREFIX "chain-echo: "
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_IO 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 255;
-
-static void
-showHelp(char const *cmd)
-{
- WRITE_MSG(1, "Usage: ");
- WRITE_STR(1, cmd);
- WRITE_MSG(1,
- " [--] <file> <data> <command> <args>*\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(0);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "chain-echo " VERSION " -- puts data into a file within a command-chain\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int main(int argc, char *argv[])
-{
- int idx = 1;
- int fd;
-
- if (argc>=2) {
- if (strcmp(argv[1], "--help") ==0) showHelp(argv[0]);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (strcmp(argv[1], "--") ==0) ++idx;
- }
-
- if (argc<idx+3) {
- WRITE_MSG(2, "Not enough parameters; use '--help' for more information\n");
- return wrapper_exit_code;
- }
-
- if (argv[idx][0]=='\0')
- fd = 1;
- else {
- fd = Eopen(argv[idx], O_WRONLY|O_NOFOLLOW, 0600);
- Efcntl(fd, F_SETFD, FD_CLOEXEC);
- }
-
- if (argv[idx+1][0]!='\0')
- EwriteAll(fd, argv[idx+1], strlen(argv[idx+1]));
-
- Eexecv(argv[idx+2], argv+idx+2);
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on chbind.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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 "vserver.h"
-#include "util.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <unistd.h>
-#include <errno.h>
-#include <getopt.h>
-#include <fcntl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#define ENSC_WRAPPERS_PREFIX "chbind: "
-#define ENSC_WRAPPERS_IO 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include "wrappers.h"
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-
-#define CMD_SILENT 0x2000
-#define CMD_IP 0x2001
-#define CMD_BCAST 0x2002
-
-int wrapper_exit_code = 255;
-
-
-static struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "silent", no_argument, 0, CMD_SILENT },
- { "ip", required_argument, 0, CMD_IP },
- { "bcast", required_argument, 0, CMD_BCAST },
- { 0,0,0,0 }
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage:\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--silent] [--ip <ip_num>[/<mask>]] [--bcast <broadcast>] [--] <commands> <args>*\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "chbind " VERSION " -- bind to an ip and execute a program\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003,2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-/*
- Check if a network device exist in /proc/net/dev.
- This is used because ifconfig_ioctl triggers modprobe if requesting
- information about non existant devices.
-
- Return != 0 if the device exist.
-*/
-static bool
-existsDevice(char const *dev_raw)
-{
- size_t buf_size=8192;
- char dev[strlen(dev_raw)+2];
-
- strcpy(dev, dev_raw);
- strcat(dev, ":");
- for (;;) {
- char buf[buf_size];
- char * pos;
- bool too_small;
- int fd=open("/proc/net/dev", O_RDONLY);
-
- if (fd==-1) return false;
- too_small = EreadAll(fd, buf, buf_size);
- close(fd);
-
- if (too_small) {
- buf_size *= 2;
- continue;
- }
-
- pos = strstr(buf, dev);
- return (pos && (pos==buf || pos[-1]==' ' || pos[-1]=='\n'));
- }
-}
-
-static int ifconfig_ioctl(
- int fd,
- const char *ifname,
- int cmd,
- struct ifreq *ifr)
-{
- strcpy(ifr->ifr_name, ifname);
- return ioctl(fd, cmd,ifr);
-}
-
-/*
- Fetch the IP number of an interface from the kernel.
- Assume the device is already available in the kernel
- Return -1 if any error.
-*/
-int ifconfig_getaddr (
- const char *ifname,
- uint32_t *addr,
- uint32_t *mask,
- uint32_t *bcast)
-{
- int ret = -1;
- if (existsDevice(ifname)){
- int skfd = socket(AF_INET, SOCK_DGRAM, 0);
- *addr = 0;
- *bcast = 0xffffffff;
- if (skfd != -1){
- struct ifreq ifr;
- if (ifconfig_ioctl(skfd,ifname,SIOCGIFADDR, &ifr) >= 0){
- struct sockaddr_in *sin = (struct sockaddr_in*)&ifr.ifr_addr;
- *addr = sin->sin_addr.s_addr;
- ret = 0;
- }
- if (ifconfig_ioctl(skfd,ifname,SIOCGIFNETMASK, &ifr) >= 0){
- struct sockaddr_in *sin = (struct sockaddr_in*)&ifr.ifr_addr;
- *mask = sin->sin_addr.s_addr;
- ret = 0;
- }
- if (ifconfig_ioctl(skfd,ifname,SIOCGIFBRDADDR, &ifr) >= 0){
- struct sockaddr_in *sin = (struct sockaddr_in*)&ifr.ifr_addr;
- *bcast = sin->sin_addr.s_addr;
- ret = 0;
- }
- close (skfd);
- }
- }
- return ret;
-}
-
-static void
-readIP(char const *str, struct vc_ip_mask_pair *ip, uint32_t *bcast)
-{
- if (ifconfig_getaddr(str, &ip->ip, &ip->mask, bcast)==-1) {
- char *pt;
- char tmpopt[strlen(str)+1];
- struct hostent *h;
-
- strcpy(tmpopt,str);
- pt = strchr(tmpopt,'/');
-
- if (pt==0)
- ip->mask = ntohl(0xffffff00);
- else {
- *pt++ = '\0';
-
- // Ok, we have a network size, not a netmask
- if (strchr(pt,'.')==0) {
- int sz = atoi(pt);
- ;
- for (ip->mask = 0; sz>0; --sz) {
- ip->mask >>= 1;
- ip->mask |= 0x80000000;
- }
- ip->mask = ntohl(ip->mask);
- }
- else {
- struct hostent *h = gethostbyname (pt);
- if (h==0) {
- WRITE_MSG(2, "Invalid netmask '");
- WRITE_STR(2, pt);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
-
- memcpy (&ip->mask, h->h_addr, sizeof(ip->mask));
- }
- }
-
- h = gethostbyname (tmpopt);
- if (h==0) {
- WRITE_MSG(2, "Invalid IP number or host name '");
- WRITE_STR(2, tmpopt);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
-
- memcpy (&ip->ip, h->h_addr,sizeof(ip->ip));
- }
-}
-
-static void
-readBcast(char const *str, uint32_t *bcast)
-{
- uint32_t tmp;
- if (ifconfig_getaddr(str, &tmp, &tmp, bcast)==-1){
- struct hostent *h = gethostbyname (str);
- if (h==0){
- WRITE_MSG(2, "Invalid broadcast number '");
- WRITE_STR(2, optarg);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
- memcpy (bcast, h->h_addr,sizeof(*bcast));
- }
-}
-
-int main (int argc, char *argv[])
-{
- size_t const nb_ipv4root = vc_get_nb_ipv4root();
- bool is_silent = false;
- struct vc_ip_mask_pair ips[nb_ipv4root];
- size_t nbaddrs = 0;
- uint32_t bcast = 0xffffffff;
-
- while (1) {
- int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_SILENT : is_silent = true; break;
- case CMD_BCAST : readBcast(optarg, &bcast); break;
- case CMD_IP :
- if (nbaddrs>=nb_ipv4root) {
- WRITE_MSG(2, "Too many IP numbers, max 16\n");
- exit(wrapper_exit_code);
- }
- readIP(optarg, ips+nbaddrs, &bcast);
- ++nbaddrs;
- break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- exit(wrapper_exit_code);
- break;
- }
- }
-
- if (optind==argc) {
- WRITE_MSG(2, "No command given; try '--help' for more information\n");
- exit(wrapper_exit_code);
- }
-
-
- if (vc_set_ipv4root(bcast,nbaddrs,ips)!=0) {
- perror("chbind: vc_set_ipv4root()");
- exit(wrapper_exit_code);
- }
-
- if (!is_silent) {
- size_t i;
-
- WRITE_MSG(1, "ipv4root is now");
- for (i=0; i<nbaddrs; ++i) {
- WRITE_MSG(1, " ");
- WRITE_STR(1, inet_ntoa(*reinterpret_cast(struct in_addr *)(&ips[i].ip)));
- }
- WRITE_MSG(1, "\n");
- }
-
- Eexecvp (argv[optind],argv+optind);
- return EXIT_SUCCESS;
-}
-
-#ifdef ENSC_TESTSUITE
-#include <assert.h>
-
-void test()
-{
- struct vc_ip_mask_pair ip;
- uint32_t bcast;
-
- bcast = 0;
- readIP("1.2.3.4", &ip, &bcast);
- assert(ip.ip==ntohl(0x01020304) && ip.mask==ntohl(0xffffff00) && bcast==0);
-
- readIP("1.2.3.4/8", &ip, &bcast);
- assert(ip.ip==ntohl(0x01020304) && ip.mask==ntohl(0xff000000) && bcast==0);
-
- readIP("1.2.3.4/255.255.0.0", &ip, &bcast);
- assert(ip.ip==ntohl(0x01020304) && ip.mask==ntohl(0xffff0000) && bcast==0);
-
- readIP("localhost", &ip, &bcast);
- assert(ip.ip==ntohl(0x7f000001) && ip.mask==ntohl(0xffffff00) && bcast==0);
-
-#if 0
- if (ifconfig_getaddr("lo", &tmp, &tmp, &tmp)!=-1) {
- readIP("lo", &ip, &bcast);
- assert(ip.ip==ntohl(0x7f000001) && ip.mask==ntohl(0xff000000) && bcast==ntohl(0x7fffffff));
- }
-#endif
-}
-#endif
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003,2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on chcontext.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- chcontext is a wrapper to user the new_s_context system call. It
- does little more than mapping command line option to the system call
- arguments.
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "util.h"
-#include "vserver.h"
-#include "internal.h"
-#include "lib_internal/jail.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <getopt.h>
-#include <assert.h>
-#include <fcntl.h>
-#include <libgen.h>
-#include <signal.h>
-
-#define ENSC_WRAPPERS_PREFIX "chcontext: "
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-#define CMD_CAP 0x4000
-#define CMD_CTX 0x4001
-#define CMD_DISCONNECT 0x4002
-#define CMD_DOMAINNAME 0x4003
-#define CMD_FLAG 0x4004
-#define CMD_HOSTNAME 0x4005
-#define CMD_SECURE 0x4006
-#define CMD_SILENT 0x4007
-
-int wrapper_exit_code = 255;
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "cap", required_argument, 0, CMD_CAP },
- { "ctx", required_argument, 0, CMD_CTX },
- { "xid", required_argument, 0, CMD_CTX },
- { "disconnect", no_argument, 0, CMD_DISCONNECT },
- { "domainname", required_argument, 0, CMD_DOMAINNAME },
- { "flag", required_argument, 0, CMD_FLAG },
- { "hostname", required_argument, 0, CMD_HOSTNAME },
- { "secure", no_argument, 0, CMD_SECURE },
- { "silent", no_argument, 0, CMD_SILENT },
- { 0,0,0,0 }
-};
-
-struct Arguments {
- size_t nbctx;
- xid_t ctxs[16];
- bool do_disconnect;
- bool do_silent;
- unsigned int flags;
- uint32_t remove_caps;
- uint32_t add_caps;
- char const * hostname;
- char const * domainname;
-};
-
-static struct Arguments const * global_args = 0;
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- VSERVER_DECLARE_CMD(cmd);
-
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--cap [!]<cap_name>] [--secure] [--xid <num>] [--disconnect]\n"
- " [--domainname <name>] [--hostname <name>] [--flag <flags>+]\n"
- " [--silent] [--] command arguments ...\n"
- "\n"
- "chcontext allocate a new security context and executes\n"
- "a command in that context.\n"
- "By default, a new/unused context is allocated\n"
- "\n"
- "--cap CAP_NAME\n"
- " Add a capability from the command. This option may be\n"
- " repeated several time.\n"
- " See /usr/include/linux/capability.h\n"
- " In general, this option is used with the --secure option\n"
- " --secure removes most critical capabilities and --cap\n"
- " adds specific ones.\n"
- "\n"
-
- "--cap !CAP_NAME\n"
- " Remove a capability from the command. This option may be\n"
- " repeated several time.\n"
- " See /usr/include/linux/capability.h\n"
- "\n"
- "--xid num\n"
- " Select the context. On root in context 0 is allowed to\n"
- " select a specific context.\n"
- " Context number 1 is special. It can see all processes\n"
- " in any contexts, but can't kill them though.\n"
- " Option --xid may be repeated several times to specify up to 16 contexts.\n"
-
- "--disconnect\n"
- " Start the command in background and make the process\n"
- " a child of process 1.\n"
-
- "--domainname new_domainname\n"
- " Set the domainname (NIS) in the new security context.\n"
- " Use \"none\" to unset the domain name.\n"
-
- "--flag\n"
- " Set one flag in the new or current security context. The following\n"
- " flags are supported. The option may be used several time.\n"
- "\n"
- " fakeinit: The new process will believe it is process number 1.\n"
- " Useful to run a real /sbin/init in a vserver.\n"
- " lock: The new process is trapped and can't use chcontext anymore.\n"
- " sched: The new process and its children will share a common \n"
- " execution priority.\n"
- " nproc: Limit the number of process in the vserver according to\n"
- " ulimit setting. Normally, ulimit is a per user thing.\n"
- " With this flag, it becomes a per vserver thing.\n"
- " private: No one can join this security context once created.\n"
- " ulimit: Apply the current ulimit to the whole context\n"
-
- "--hostname new_hostname\n"
- " Set the hostname in the new security context\n"
- " This is need because if you create a less privileged\n"
- " security context, it may be unable to change its hostname\n"
-
- "--secure\n"
- " Remove all the capabilities to make a virtual server trustable\n"
-
- "--silent\n"
- " Do not print the allocated context number.\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "chcontext-compat " VERSION " -- allocates/enters a security context\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003,2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static inline void
-setCap(char const *str, uint32_t *add_caps, uint32_t *remove_caps)
-{
- uint32_t *cap;
- int bit;
-
- if (str[0] != '!')
- cap = add_caps;
- else {
- cap = remove_caps;
- str++;
- }
-
- bit = vc_text2cap(str);
-
- if (bit!=-1) *cap |= (1<<bit);
- else {
- WRITE_MSG(2, "Unknown capability '");
- WRITE_STR(2, str);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
-}
-
-static inline void
-setFlags(char const *str, uint32_t *flags)
-{
- struct vc_err_listparser err;
-
- *flags = vc_list2cflag_compat(str, 0, &err);
-
- if (err.ptr!=0) {
- WRITE_MSG(2, "Unknown flag '");
- Vwrite(2, err.ptr, err.len);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
-}
-
-static inline ALWAYSINLINE void
-setHostname(char const *name)
-{
- if (name == NULL) return;
-
- if (sethostname(name, strlen(name))==-1) {
- perror("chcontext: sethostname()");
- exit(255);
- }
- if (!global_args->do_silent) {
- WRITE_MSG(1, "Host name is now ");
- WRITE_STR(1, name);
- WRITE_MSG(1, "\n");
- }
-}
-
-static inline ALWAYSINLINE void
-setDomainname(char const *name)
-{
- if (name == NULL) return;
-
- if (setdomainname(name, strlen(name))==-1) {
- perror("chcontext: setdomainname()");
- exit(255);
- }
- if (!global_args->do_silent) {
- WRITE_MSG(1, "Domain name is now ");
- WRITE_STR(1, name);
- WRITE_MSG(1, "\n");
- }
-}
-
-static inline ALWAYSINLINE void
-tellContext(xid_t ctx)
-{
- char buf[sizeof(xid_t)*3+2];
- size_t l;
-
- if (global_args->do_silent) return;
-
- l = utilvserver_fmt_long(buf,ctx);
-
- WRITE_MSG(1, "New security context is ");
- Vwrite(1, buf, l);
- WRITE_MSG(1, "\n");
-}
-
-#include "context-sync.hc"
-
-int main (int argc, char *argv[])
-{
- struct Arguments args = {
- .nbctx = 0,
- .do_disconnect = false,
- .do_silent = false,
- .flags = 0,
- .remove_caps = 0,
- .add_caps = 0,
- .hostname = 0,
- .domainname = 0
- };
- xid_t newctx;
- int xflags;
- int p[2][2];
- pid_t pid;
-
- global_args = &args;
- signal(SIGCHLD, SIG_DFL);
-
- while (1) {
- int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_DISCONNECT : args.do_disconnect = true; break;
- case CMD_SILENT : args.do_silent = true; break;
- case CMD_DOMAINNAME : args.domainname = optarg; break;
- case CMD_HOSTNAME : args.hostname = optarg; break;
-
- case CMD_CAP :
- setCap(optarg, &args.add_caps, &args.remove_caps);
- break;
- case CMD_SECURE :
- args.remove_caps |= vc_get_insecurebcaps();
- break;
- case CMD_FLAG :
- setFlags(optarg, &args.flags);
- break;
- case CMD_CTX :
- if (args.nbctx>0)
- WRITE_MSG(2, "WARNING: More than one ctx not supported by this version\n");
- if (args.nbctx>=DIM_OF(args.ctxs)) {
- WRITE_MSG(2, "Too many contexts given\n");
- exit(255);
- }
- args.ctxs[args.nbctx++] = Evc_xidopt2xid(optarg, true);
- break;
-
-
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return 255;
- break;
- }
- }
-
- if (optind>=argc) {
- WRITE_MSG(2, "No command given; use '--help' for more information.\n");
- exit(255);
- }
-
- if (args.domainname && strcmp(args.domainname, "none")==0)
- args.domainname = "";
-
- if (args.nbctx == 0)
- args.ctxs[args.nbctx++] = VC_DYNAMIC_XID;
-
- xflags = args.flags & S_CTX_INFO_INIT;
- args.flags &= ~S_CTX_INFO_INIT;
-
- pid = initSync(p, args.do_disconnect);
- if (pid==0) {
- doSyncStage0(p, args.do_disconnect);
-
- newctx = Evc_new_s_context(args.ctxs[0],0,args.flags);
- args.remove_caps &= (~args.add_caps);
- setHostname(args.hostname);
- setDomainname(args.domainname);
-
- if (args.remove_caps!=0 || xflags!=0)
- Evc_new_s_context (VC_SAMECTX,args.remove_caps,xflags);
- tellContext(args.ctxs[0]==VC_DYNAMIC_XID ? newctx : args.ctxs[0]);
-
- doSyncStage1(p, args.do_disconnect);
- execvp (argv[optind],argv+optind);
- doSyncStage2(p, args.do_disconnect);
-
- PERROR_Q("chcontext: execvp", argv[optind]);
- exit(255);
- }
-
- waitOnSync(pid, p, args.ctxs[0]!=VC_DYNAMIC_XID);
- return EXIT_SUCCESS;
-}
-
-#ifdef ENSC_TESTSUITE
-#define FLAG_TEST(STR,EXP) \
- { \
- uint32_t flag=0; \
- setFlags(STR, &flag); \
- assert(flag==(EXP)); \
- }
-
-#define CAP_TEST(STR,EXP_ADD,EXP_DEL) \
- { \
- uint32_t add=0,del=0; \
- setCap(STR, &add, &del); \
- assert(add==(EXP_ADD)); \
- assert(del==(EXP_DEL)); \
- }
-
-void
-test()
-{
- FLAG_TEST("lock", 1);
- FLAG_TEST("lock,sched", 3);
-
- CAP_TEST("CHOWN", 1, 0);
- CAP_TEST("CAP_CHOWN", 1, 0);
- CAP_TEST("!CHOWN", 0, 1);
- CAP_TEST("!CAP_CHOWN", 0, 1);
-}
-#endif
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "util.h"
-
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <limits.h>
-
-#define ENSC_WRAPPERS_PREFIX "check-unixfile: "
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 255;
-
-static void
-showHelp(int fd, char const *cmd)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--] <file>+\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(0);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "check-unixfile " VERSION " -- execute some basic fileformat checks\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2005 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static bool
-checkFile(char const *fname)
-{
- int fd = Eopen(fname, O_RDONLY, 0);
- off_t l = Elseek(fd, 0, SEEK_END);
- char const * data = 0;
- bool res = true;
-
- if (l>100*1024*1024) {
- WRITE_MSG(2, "WARNING: '");
- WRITE_STR(2, fname);
- WRITE_STR(2, "' is too large for a vserver configuration file\n");
- res = false;
- }
- else if (l>0) {
- data = mmap(0, l, PROT_READ, MAP_PRIVATE, fd, 0);
- if (data==0) {
- perror("mmap()");
- exit(wrapper_exit_code);
- }
-
- if (data[l-1]!='\n') {
- WRITE_MSG(2, "WARNING: '");
- WRITE_STR(2, fname);
- WRITE_MSG(2, "' does not end on newline\n");
- res = false;
- }
-
- munmap(const_cast(char *)(data), l);
- }
-
- Eclose(fd);
-
- return res;
-}
-
-int main(int argc, char *argv[])
-{
- int idx = 1;
- bool ok = true;
- bool passed = false;
-
- if (argc>=2) {
- if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0]);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (strcmp(argv[1], "--") ==0) ++idx;
- }
-
- for (; idx<argc; ++idx)
- if (checkFile(argv[idx])) passed = true;
- else ok = false;
-
- if (ok) return 0;
- else if (passed) return 2;
- else return 1;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2003 Enrico Scholz <>
-//
-// 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 "util.h"
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 1;
-
-int main(int argc, char *argv[])
-{
- int fd;
-
- if (argc!=2) {
- WRITE_MSG(2, "Usage: chroot-cat file\n");
- return EXIT_FAILURE;
- }
-
- Echroot(".");
- Echdir("/");
-
- fd = Eopen(argv[1], O_WRONLY|O_CREAT|O_TRUNC, 0644);
- for (;;) {
- char buf[4096];
- char const * ptr=buf;
- ssize_t len;
-
- len = Eread(0, buf, sizeof(buf));
- if (len<=0) break;
-
- while (len>0) {
- size_t l = Ewrite(fd, ptr, len);
- ptr += l;
- len -= l;
- }
- }
- Eclose(fd);
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2003,2004 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 "util.h"
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-
-#define ENSC_WRAPPERS_PREFIX "chroot-rm: "
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 1;
-
-static void
-showHelp(char const *cmd)
-{
- WRITE_MSG(1, "Usage: ");
- WRITE_STR(1, cmd);
- WRITE_MSG(1,
- " [--] <files>+\n\n"
- "This program removes <files> by assuming the current directory\n"
- "as a chroot directory.\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(0);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "chroot-rm " VERSION " -- removes files under current directory\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003,2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int main(int argc, char *argv[])
-{
- int res = EXIT_SUCCESS;
- int idx = 1;
-
- if (argc>1) {
- if (strcmp(argv[1], "--help") ==0) showHelp(argv[0]);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (strcmp(argv[1], "--")==0) ++idx;
- }
-
- if (idx==argc) {
- WRITE_MSG(2, "No files given; use '--help' for more information\n");
- return EXIT_FAILURE;
- }
-
- Echroot(".");
-
- for (; idx<argc; ++idx) {
- if (unlink(argv[idx])==-1) {
- PERROR_Q(ENSC_WRAPPERS_PREFIX "unlink", argv[idx]);
- res = EXIT_FAILURE;
- }
- }
-
- return res;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "fstool.h"
-#include "util.h"
-
-#include "lib/vserver.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { 0,0,0,0 }
-};
-
-char const CMDLINE_OPTIONS_SHORT[] = "Rc:x";
-
-void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " -c <ctx|vserver> [-Rx] [--] <file>+\n\n"
- " Options:\n"
- " -R ... recurse through directories\n"
- " -c ... assign the given context/vserver to the file(s)\n"
- " -x ... do not cross filesystems\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-void
-showVersion()
-{
- WRITE_MSG(1,
- "chxid " VERSION " -- assigns a context to a file\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-bool
-handleFile(char const *name, char const * display_name)
-{
- int rc = vc_set_iattr(name, global_args->ctx, 0, VC_IATTR_XID);
-
- if (rc==-1) {
- perror(display_name);
- return false;
- }
-
- return true;
-}
-
-void
-fixupParams(struct Arguments UNUSED *args, int argc)
-{
- if (optind==argc) {
- WRITE_MSG(2, "No filename given; use '--help' for more information\n");
- exit(1);
- }
-
- if (args->ctx_str==0) {
- WRITE_MSG(2, "No context given; use '--help' for more information\n");
- exit(1);
- }
-
- args->ctx = vc_xidopt2xid(args->ctx_str, true, 0);
- args->do_display_dir = !args->do_recurse;
- args->do_display_dot = true;
-}
+++ /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_SRC_COMPAT_PIVOT_ROOT_H
-#define H_UTIL_VSERVER_SRC_COMPAT_PIVOT_ROOT_H
-
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <asm/unistd.h>
-#include <errno.h>
-
-inline static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
-
-#endif // H_UTIL_VSERVER_SRC_COMPAT_PIVOT_ROOT_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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.
-
-
-/// \args p[0] used for parent -> child sync (child waits till parent is in deathrow)
-/// \args p[1] used for child -> parent sync (recognize execv() errors)
-static inline ALWAYSINLINE int
-initSync(int p[2][2], bool do_disconnect)
-{
- if (!do_disconnect) return 0;
-
- Epipe(p[0]);
- Epipe(p[1]);
- fcntl(p[1][1], F_SETFD, FD_CLOEXEC);
- return Efork();
-}
-
-static inline ALWAYSINLINE void
-doSyncStage0(int p[2][2], bool do_disconnect)
-{
- char c;
- if (!do_disconnect) return;
-
- Eclose(p[0][1]);
- Eread (p[0][0], &c, 1);
- Eclose(p[0][0]);
-}
-
-static inline ALWAYSINLINE void
-doSyncStage1(int p[2][2], bool do_disconnect)
-{
- int fd;
-
- if (!do_disconnect) return;
-
- fd = EopenD("/dev/null", O_RDONLY|O_NONBLOCK, 0);
- Esetsid();
- Edup2(fd, 0);
- Eclose(p[1][0]);
- if (fd!=0) Eclose(fd);
- Ewrite(p[1][1], ".", 1);
-}
-
-static inline ALWAYSINLINE void
-doSyncStage2(int p[2][2], bool do_disconnect)
-{
- if (!do_disconnect) return;
-
- Ewrite(p[1][1], "X", 1);
-}
-
-/// \args p[0] used for parent -> child sync (child waits till parent is in deathrow)
-/// \args p[1] used for child -> parent sync (recognize execv() errors)
-static void
-waitOnSync(pid_t pid, int p[2][2], bool is_prevent_race)
-{
- char c;
- size_t l;
-
- if (is_prevent_race &&
- !jailIntoTempDir(0)) {
- perror(ENSC_WRAPPERS_PREFIX "jailIntoTempDir()");
- exit(255);
- }
-
- Eclose(p[0][0]);
- Ewrite(p[0][1], "X", 1);
- Eclose(p[0][1]);
-
- Eclose(p[1][1]);
- l = Eread(p[1][0], &c, 1);
- if (l!=1) exitLikeProcess(pid,0, wrapper_exit_code);
- l = Eread(p[1][0], &c, 1);
- if (l!=0) exitLikeProcess(pid,0, wrapper_exit_code);
-}
+++ /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 "util.h"
-#include <fcntl.h>
-#include <errno.h>
-
-#define ENSC_WRAPPERS_PREFIX "exec-cd: "
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 255;
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--] <dir> <cmd> <args>*\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "exec-cd " VERSION " -- executes commands within a safely changed cwd\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int main(int argc, char *argv[])
-{
- int dirfd_root = Eopen("/", O_RDONLY, 0);
- int idx = 1;
- int dirfd_cur;
-
- if (argc>=2) {
- if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0], 0);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (strcmp(argv[1], "--") ==0) ++idx;
- }
-
- if (argc<idx+2) {
- WRITE_MSG(2, "Not enough parameters; use '--help' for more information\n");
- return wrapper_exit_code;
- }
-
-
- Echroot(".");
- Echdir(argv[idx]);
-
- dirfd_cur = Eopen(".", O_RDONLY, 0);
-
- Efchdir(dirfd_root);
- Echroot(".");
-
- Efchdir(dirfd_cur);
-
- Eclose(dirfd_cur);
- Eclose(dirfd_root);
-
- Eexecv(argv[idx+1], argv+idx+1);
-}
+++ /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 "util.h"
-
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#define ENSC_WRAPPERS_PREFIX "exec-ulimit: "
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_RESOURCE 1
-#include <wrappers.h>
-
-#define DECLARE_LIMIT(RES,FNAME) { #FNAME, RLIMIT_##RES }
-
-int wrapper_exit_code = 255;
-
-static struct {
- char const *fname;
- int code;
-} const LIMITS[] = {
- DECLARE_LIMIT(CORE, core),
- DECLARE_LIMIT(CPU, cpu),
- DECLARE_LIMIT(DATA, data),
- DECLARE_LIMIT(FSIZE, fsize),
- DECLARE_LIMIT(LOCKS, locks),
- DECLARE_LIMIT(MEMLOCK, memlock),
- DECLARE_LIMIT(NOFILE, nofile),
- DECLARE_LIMIT(NPROC, nproc),
- DECLARE_LIMIT(RSS, rss),
- DECLARE_LIMIT(STACK, stack),
-};
-
-static rlim_t
-readValue(int fd, char const *filename)
-{
- char buf[128];
- size_t len = Eread(fd, buf, sizeof(buf)-1);
- long int res;
- char * errptr;
-
- buf[len] = '\0';
- if (strncmp(buf, "inf", 3)==0) return RLIM_INFINITY;
- res = strtol(buf, &errptr, 0);
-
- if (errptr!=buf) {
- switch (*errptr) {
- case 'M' : res *= 1024; /* fallthrough */
- case 'K' : res *= 1024; ++errptr; break;
- case 'm' : res *= 1000; /* fallthrough */
- case 'k' : res *= 1000; ++errptr; break;
- default : break;
- }
- }
-
- if (errptr==buf || (*errptr!='\0' && *errptr!='\n')) {
- WRITE_MSG(2, "Invalid limit in '");
- WRITE_STR(2, filename);
- WRITE_STR(2, "'\n");
- exit(255);
- }
-
- return res;
-}
-
-static bool
-readSingleLimit(struct rlimit *lim, char const *fname_base)
-{
- size_t fname_len = strlen(fname_base);
- char fname[fname_len + sizeof(".hard")];
- int fd;
- bool is_modified = false;
-
- strcpy(fname, fname_base);
-
- fd = open(fname, O_RDONLY);
- if (fd!=-1) {
- rlim_t tmp = readValue(fd, fname_base);
- lim->rlim_cur = tmp;
- lim->rlim_max = tmp;
- Eclose(fd);
-
- is_modified = true;
- }
-
- strcpy(fname+fname_len, ".hard");
- fd = open(fname, O_RDONLY);
- if (fd!=-1) {
- lim->rlim_max = readValue(fd, fname_base);
- Eclose(fd);
-
- is_modified = true;
- }
-
- strcpy(fname+fname_len, ".soft");
- fd = open(fname, O_RDONLY);
- if (fd!=-1) {
- lim->rlim_cur = readValue(fd, fname_base);
- Eclose(fd);
-
- is_modified = true;
- }
-
- if (is_modified &&
- lim->rlim_max!=RLIM_INFINITY &&
- (lim->rlim_cur==RLIM_INFINITY ||
- lim->rlim_cur>lim->rlim_max))
- lim->rlim_cur = lim->rlim_max;
-
- return is_modified;
-}
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_STR(fd,
- "<ulimit-cfgdir> <cmd> <argv>*\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "exec-ulimit " VERSION " -- executes programs with resource limits\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int main(int argc, char *argv[])
-{
- size_t i;
- int cur_fd = Eopen(".", O_RDONLY, 0);
-
- if (argc==2) {
- if (strcmp(argv[1], "--help")==0) showHelp(1,argv[0],0);
- if (strcmp(argv[1], "--version")==0) showVersion();
- }
-
- if (argc<3) {
- WRITE_MSG(2, "Bad parameter count; use '--help' for more information.\n");
- exit(255);
- }
-
- if (chdir(argv[1])!=-1) {
- for (i=0; i<sizeof(LIMITS)/sizeof(LIMITS[0]); ++i) {
- struct rlimit limit;
-
- Egetrlimit(LIMITS[i].code, &limit);
- if (readSingleLimit(&limit, LIMITS[i].fname))
- Esetrlimit(LIMITS[i].code, &limit);
- }
- Efchdir(cur_fd);
- }
- Eclose(cur_fd);
-
- Eexecv(argv[2], argv+2);
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on fakerunlevel.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- This program add a RUNLEVEL record in a utmp file.
- This is used when a vserver lack a private init process
- so runlevel properly report the fake runlevel.
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "util.h"
-
-#include <utmp.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <grp.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#define ENSC_WRAPPERS_PREFIX "fakerunlevel: "
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 1;
-
-static void
-showHelp(int fd, int exit_code)
-{
- WRITE_MSG(fd,
- "Usage: fakerunlevel <runlevel> <utmp_file>\n\n"
- "Put a runlevel record in file <utmp_file>\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(exit_code);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "fakerunlevel " VERSION "\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int main (int argc, char *argv[])
-{
- if (argc==1) showHelp(2,1);
- if (strcmp(argv[1], "--help")==0) showHelp(1,0);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (argc!=3) showHelp(2,1);
-
- {
- int const runlevel = atoi(argv[1]);
- char const * const fname = argv[2];
- int fd;
- struct utmp ut;
-
- gid_t gid;
- char *gid_str = getenv("UTMP_GID");
-
- if (runlevel<0 || runlevel>6) showHelp(2,1);
-
- Echroot(".");
- Echdir("/");
-
- // Real NSS is too expensive/insecure in this state; therefore, use the
- // value detected at ./configure stage or overridden by $UTMP_GID
- // env-variable
- gid = gid_str ? atoi(gid_str) : UTMP_GID;
- Esetgroups(1, &gid);
- Esetgid(gid);
-
- if (getgid()!=gid) {
- WRITE_MSG(2, "fakerunlevel: Failed to set group\n");
- return EXIT_FAILURE;
- }
-
- umask(002);
- fd = EopenD(fname, O_WRONLY|O_CREAT|O_APPEND, 0664);
- Eclose(fd);
-
- utmpname (fname);
- setutent();
- memset (&ut,0,sizeof(ut));
- ut.ut_type = RUN_LVL;
- ut.ut_pid = ('#' << 8) + runlevel+'0';
- pututline (&ut);
- endutent();
- }
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on filetime.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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 "util.h"
-#include "lib/internal.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <time.h>
-#include <sys/stat.h>
-
-static void
-showHelp(char const *cmd)
-{
- WRITE_MSG(1, "Usage: ");
- WRITE_STR(1, cmd);
- WRITE_MSG(1,
- " [--] <filename>\n"
- "\n"
- "Shows the relative age of <filename>\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(0);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "filetime " VERSION " -- shows age of a file\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int main (int argc, char *argv[])
-{
- int idx = 1;
- struct stat st;
-
- if (argc>=2) {
- if (strcmp(argv[1], "--help") ==0) showHelp(argv[0]);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (strcmp(argv[1], "--") ==0) ++idx;
- }
- if (argc<idx+1)
- WRITE_MSG(2, "No filename specified; use '--help' for more information\n");
- else if (stat(argv[idx], &st)==-1)
- PERROR_Q("stat", argv[idx]);
- else {
- time_t now = time(NULL);
- time_t since = now - st.st_mtime;
- int days = since / (24*60*60);
- int today = since % (24*60*60);
- int hours = today / (60*60);
- int minutes = (today % (60*60)) / 60;
-
- char buf[3*sizeof(time_t)*3 + 128];
- size_t l = 0;
-
- if (days > 0) {
- l = utilvserver_fmt_ulong(buf, days);
- buf[l++] = ' ';
- #define MSG "days, "
- memcpy(buf+l, MSG, sizeof(MSG)-1); l += sizeof(MSG)-1;
- }
-
- if (hours<10) buf[l++] = '0';
- l += utilvserver_fmt_ulong(buf+l, hours);
- buf[l++] = ':';
- if (minutes<10) buf[l++] = '0';
- l += utilvserver_fmt_ulong(buf+l, minutes);
- buf[l++] = '\n';
-
- Vwrite(1, buf, l);
- return EXIT_SUCCESS;
- }
-
- return EXIT_FAILURE;
-}
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "fstool.h"
-#include "util.h"
-
-#include <lib/vserver.h>
-
-#include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#define ENSC_WRAPPERS_DIRENT 1
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-struct Arguments const * global_args = 0;
-
-int wrapper_exit_code = 1;
-
-inline static bool
-isSpecialDir(char const *d)
-{
- return ( (d[0]=='.' && !global_args->do_display_dot) ||
- (d[0]=='.' && (d[1]=='\0' || (d[1]=='.' && d[2]=='\0'))) );
-}
-
-#define CONCAT_PATHS(LHS, LHS_LEN, RHS) \
- size_t l_rhs = strlen(RHS); \
- char new_path[(LHS_LEN) + l_rhs + sizeof("/")]; \
- memcpy(new_path, LHS, (LHS_LEN)); \
- memcpy(new_path+(LHS_LEN), "/", 1); \
- memcpy(new_path+(LHS_LEN)+1, RHS, l_rhs); \
- new_path[(LHS_LEN)+1+l_rhs] = '\0';
-
-static uint64_t
-iterateFilesystem(char const *path)
-{
- bool do_again = false;
- size_t path_len = strlen(path);
- uint64_t err = 0;
- struct stat cur_st;
- DIR * dir = opendir(".");
-
- if (dir==0) {
- perror("opendir()");
- return 1;
- }
-
- // show current directory entry first
- if (lstat(".", &cur_st)==-1) perror("lstat()");
- else err += handleFile(".", path) ? 0 : 1;
-
- // strip trailing '/'
- while (path_len>0 && path[path_len-1]=='/') --path_len;
-
- // process regular files before directories
- for (;;) {
- struct dirent *ent = Ereaddir(dir);
- struct stat st;
-
- if (ent==0) break;
- if (isSpecialDir(ent->d_name)) continue;
-
- if (lstat(ent->d_name, &st)==-1) {
- perror("lstat()");
- ++err;
- continue;
- }
-
- if (S_ISDIR(st.st_mode) && global_args->do_recurse) {
- do_again = true;
- continue;
- }
-
- {
- CONCAT_PATHS(path, path_len, ent->d_name);
- err += handleFile(ent->d_name, new_path) ? 0 : 1;
- }
- }
-
- if (do_again) {
- int cur_dir = Eopen(".", O_RDONLY, 0);
- rewinddir(dir);
-
- for (;;) {
- struct dirent *ent = Ereaddir(dir);
- struct stat st;
-
- if (ent==0) break;
- if (isSpecialDir(ent->d_name)) continue;
-
- if (lstat(ent->d_name, &st)==-1) {
- perror("lstat()");
- ++err;
- continue;
- }
-
- if (!S_ISDIR(st.st_mode) ||
- (global_args->local_fs && st.st_dev!=cur_st.st_dev))
- continue;
-
- if (safeChdir(ent->d_name, &st)==-1) {
- perror("chdir()");
- ++err;
- continue;
- }
-
- {
- CONCAT_PATHS(path, path_len, ent->d_name);
- err += iterateFilesystem(new_path);
- }
- Efchdir(cur_dir);
- }
- Eclose(cur_dir);
- }
-
- Eclosedir(dir);
-
- return err;
-}
-#undef CONCAT_PATHS
-
-static uint64_t
-processFile(char const *path)
-{
- struct stat st;
-
- if (lstat(path, &st)==-1) {
- perror("lstat()");
- return 1;
- }
-
- if (S_ISDIR(st.st_mode) && !global_args->do_display_dir) {
- Echdir(path);
- return iterateFilesystem(path);
- }
- else
- return handleFile(path, path) ? 0 : 1;
-}
-
-int main(int argc, char *argv[])
-{
- uint64_t err_cnt = 0;
- int i;
- struct Arguments args = {
- .do_recurse = false,
- .do_display_dot = false,
- .do_display_dir = false,
- .do_mapping = true,
- .ctx = VC_NOCTX,
- .is_legacy = false,
- .do_set = false,
- .do_unset = false,
- .local_fs = false,
- .set_mask = 0,
- .del_mask = 0
- };
-
- global_args = &args;
- while (1) {
- int c = getopt_long(argc, argv, CMDLINE_OPTIONS_SHORT,
- CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_IMMU : args.set_mask |= VC_IATTR_IMMUTABLE; /*@fallthrough@*/
- case CMD_IMMUX : args.set_mask |= VC_IATTR_IUNLINK; break;
- case CMD_ADMIN : args.set_mask |= VC_IATTR_ADMIN; break;
- case CMD_WATCH : args.set_mask |= VC_IATTR_WATCH; break;
- case CMD_HIDE : args.set_mask |= VC_IATTR_HIDE; break;
- case CMD_BARRIER : args.set_mask |= VC_IATTR_BARRIER; break;
- case CMD_UNSET_IMMU : args.del_mask |= VC_IATTR_IMMUTABLE; /*@fallthrough@*/
- case CMD_UNSET_IMMUX : args.del_mask |= VC_IATTR_IUNLINK; break;
- case CMD_UNSET_ADMIN : args.del_mask |= VC_IATTR_ADMIN; break;
- case CMD_UNSET_WATCH : args.del_mask |= VC_IATTR_WATCH; break;
- case CMD_UNSET_HIDE : args.del_mask |= VC_IATTR_HIDE; break;
- case CMD_UNSET_BARRIER : args.del_mask |= VC_IATTR_BARRIER; break;
- case 'R' : args.do_recurse = true; break;
- case 'a' : args.do_display_dot = true; break;
- case 'd' : args.do_display_dir = true; break;
- case 'n' : args.do_mapping = false; break;
- case 's' : args.do_set = true; break;
- case 'u' : args.do_unset = true; break;
- case 'c' : args.ctx_str = optarg; break;
- case 'x' : args.local_fs = true; break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- fixupParams(&args, argc);
-
- if (optind==argc)
- err_cnt = processFile(".");
- else for (i=optind; i<argc; ++i)
- err_cnt += processFile(argv[i]);
-
- return err_cnt>0 ? EXIT_FAILURE : EXIT_SUCCESS;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_SRC_FSTOOL_H
-#define H_UTIL_VSERVER_SRC_FSTOOL_H
-
-#include <getopt.h>
-#include <stdbool.h>
-
-#define CMD_HELP 0x8000
-#define CMD_VERSION 0x8001
-#define CMD_IMMUTABLE 0x8002
-#define CMD_IMMULINK 0x8003
-#define CMD_LEGACY 0x8004
-#define CMD_IMMU 0x8010
-#define CMD_ADMIN 0x8011
-#define CMD_WATCH 0x8012
-#define CMD_HIDE 0x8013
-#define CMD_BARRIER 0x8014
-#define CMD_IMMUX 0x8015
-#define CMD_UNSET_IMMU 0x8020
-#define CMD_UNSET_ADMIN 0x8021
-#define CMD_UNSET_WATCH 0x8022
-#define CMD_UNSET_HIDE 0x8023
-#define CMD_UNSET_BARRIER 0x8024
-#define CMD_UNSET_IMMUX 0x8025
-
-
-struct stat;
-
-struct Arguments {
- bool do_recurse;
- bool do_display_dot;
- bool do_display_dir;
- bool do_mapping;
- char const * ctx_str;
- xid_t ctx;
- bool is_legacy;
- bool do_set;
- bool do_unset;
- bool local_fs;
-
- uint32_t set_mask;
- uint32_t del_mask;
-};
-
-extern struct option const CMDLINE_OPTIONS[];
-extern char const CMDLINE_OPTIONS_SHORT[];
-extern struct Arguments const * global_args;
-
-void fixupParams(struct Arguments *, int argc);
-bool handleFile(char const *d_name, char const *full_name);
-void showHelp(int fd, char const *cmd, int res);
-void showVersion();
-
-#endif // H_UTIL_VSERVER_SRC_FSTOOL_H
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on ifspec.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- Prints the specs of a network device in shell like form
-
- ADDR=
- NETMASK=
- BCAST=
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <net/if.h>
-
-static void usage()
-{
- fprintf (stderr,"ifspec version %s\n",VERSION);
- fprintf (stderr
- ,"ifspec network-device [ ipaddr netmask broadcast ]\n"
- "prints device specification in a shell usable way\n");
- exit (-1);
-}
-
-static int ifconfig_ioctl(
- int fd,
- const char *ifname,
- int cmd,
- struct ifreq *ifr)
-{
- strcpy(ifr->ifr_name, ifname);
- return ioctl(fd, cmd,ifr);
-}
-
-static unsigned long ip_cnv (const char *str)
-{
- const char *start_str = str;
- unsigned tb[4];
- int no = 0;
- unsigned long ret;
-
- memset (tb,-1,sizeof(tb));
- while (*str != '\0' && no < 4){
- if (isdigit(*str)){
- int val = atoi(str);
- if (val > 255) break;
- tb[no++] = val;
- while (isdigit(*str)) str++;
- if (*str == '.'){
- str++;
- }else{
- break;
- }
- }else{
- break;
- }
- }
-
- ret = (tb[0] << 24) | (tb[1]<<16) | (tb[2] << 8) | tb[3];
- if (no != 4 || *str != '\0'){
- fprintf (stderr,"Invalid IP number or netmask: %s\n",start_str);
- ret = 0xffffffff;
- }
- return ret;
-}
-
-
-/*
- Fetch the IP number of an interface from the kernel.
- Assume the device is already available in the kernel
- Return -1 if any error.
-*/
-int ifconfig_print (
- const char *ifname,
- const char *addrstr,
- const char *maskstr,
- const char *bcaststr)
-{
- int ret = -1;
- int skfd = socket(AF_INET, SOCK_DGRAM, 0);
- if (skfd != -1){
- struct ifreq ifr;
- struct {
- unsigned long addr;
- unsigned long mask;
- } solved = {0,0};
- if (addrstr != NULL && addrstr[0] != '\0'){
- printf ("ADDR=%s\n",addrstr);
- solved.addr = ip_cnv (addrstr);
- }else if (ifconfig_ioctl(skfd,ifname,SIOCGIFADDR, &ifr) >= 0){
- struct sockaddr_in *sin = (struct sockaddr_in*)&ifr.ifr_addr;
- unsigned long addr = ntohl(sin->sin_addr.s_addr);
- printf ("ADDR=%lu.%lu.%lu.%lu\n"
- ,(addr>>24)&0xff
- ,(addr>>16)&0xff
- ,(addr>>8)&0xff
- ,addr&0xff);
- solved.addr = addr;
- ret = 0;
- }
- else {
- perror("ifspec: ioctl(SIOCGIFADDR)");
- }
-
- if (maskstr != NULL && maskstr[0] != '\0'){
- printf ("NETMASK=%s\n",maskstr);
- solved.mask = ip_cnv (maskstr);
- }else if (ifconfig_ioctl(skfd,ifname,SIOCGIFNETMASK, &ifr) >= 0){
- struct sockaddr_in *sin = (struct sockaddr_in*)&ifr.ifr_addr;
- unsigned long addr = ntohl(sin->sin_addr.s_addr);
- printf ("NETMASK=%lu.%lu.%lu.%lu\n"
- ,(addr>>24)&0xff
- ,(addr>>16)&0xff
- ,(addr>>8)&0xff
- ,addr&0xff);
- solved.mask = addr;
- ret = 0;
- }
- else {
- perror("ifspec: ioctl(SIOCGIFNETMASK)");
- }
-
- if (bcaststr != NULL && bcaststr[0] != '\0'){
- printf ("BCAST=%s\n",bcaststr);
- }else if (ifconfig_ioctl(skfd,ifname,SIOCGIFBRDADDR, &ifr) >= 0){
- struct sockaddr_in *sin = (struct sockaddr_in*)&ifr.ifr_addr;
- unsigned long addr = ntohl(sin->sin_addr.s_addr);
- printf ("BCAST=%lu.%lu.%lu.%lu\n"
- ,(addr>>24)&0xff
- ,(addr>>16)&0xff
- ,(addr>>8)&0xff
- ,addr&0xff);
- ret = 0;
- }else if (solved.addr!=0 && solved.mask!=0) {
- // Can't get it from the kernel, compute it from the IP
- // and the netmask
- unsigned long addr = (solved.addr & solved.mask)
- | ~solved.mask;
- printf ("BCAST=%lu.%lu.%lu.%lu\n"
- ,(addr>>24)&0xff
- ,(addr>>16)&0xff
- ,(addr>>8)&0xff
- ,addr&0xff);
-
- }
- close (skfd);
- }
- return ret;
-}
-
-
-int main (int argc, char *argv[])
-{
- int ret = -1;
- if (argc < 2){
- usage();
- }else{
- const char *addrstr = argc >= 3 ? argv[2] : NULL;
- const char *maskstr = argc >= 4 ? argv[3] : NULL;
- const char *bcaststr = argc >= 5 ? argv[4] : NULL;
- ret = ifconfig_print (argv[1],addrstr,maskstr,bcaststr);
- }
- return ret;
-}
-
-
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-
-#include <lib/vserver.h>
-#include <lib/internal.h>
-
-#include <getopt.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/select.h>
-
-#define ENSC_WRAPPERS_PREFIX "keep-ctx-alive: "
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_SOCKET 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_IOSOCK 1
-#define ENSC_WRAPPERS_IO 1
-#include <wrappers.h>
-
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-#define CMD_SOCKET 0x4000
-#define CMD_TIMEOUT 0x4001
-#define CMD_QUIT 0x4002
-
-int wrapper_exit_code = 1;
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "socket", required_argument, 0, CMD_SOCKET },
- { "timeout", required_argument, 0, CMD_TIMEOUT },
- { "quit", required_argument, 0, CMD_QUIT },
- {0,0,0,0},
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage:\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " --socket <filename> [--timeout <seconds>]\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "keep-ctx-alive " VERSION " -- keeps a context alive\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-printXid(int fd)
-{
- xid_t xid = Evc_get_task_xid(0);
- char buf[sizeof(xid)*3 + 2];
- size_t l;
-
- l = utilvserver_fmt_long(buf, xid);
- EwriteAll(fd, buf, l);
- Eclose(fd);
-}
-
-static void handleMessage(int fd)
-{
- char buf[128];
- size_t len;
- struct sockaddr_un addr;
- socklen_t addr_len = sizeof(addr);
- int new_fd = Eaccept(fd, &addr, &addr_len);
-
- len = Erecv(new_fd, buf, sizeof buf,0);
- if (len==0) exit(1);
-
- // TODO: handle message???
- exit(0);
-}
-
-static int
-sendQuitSignal(char const *filename, char const *msg)
-{
- int fd;
- struct sockaddr_un addr;
-
- ENSC_INIT_UNIX_SOCK(addr, filename);
- fd = Esocket(PF_UNIX, SOCK_STREAM, 0);
- Econnect(fd, &addr, sizeof(addr));
-
- if (msg) EsendAll(fd, msg, strlen(msg));
- Eclose(fd);
-
- return EXIT_SUCCESS;
-}
-
-static int
-doit(char const *filename, struct timeval *timeout)
-{
- int fd;
- struct sockaddr_un sock;
- pid_t pid;
- fd_set fdset;
-
- ENSC_INIT_UNIX_SOCK(sock, filename);
-
- fd = Esocket(PF_UNIX, SOCK_STREAM, 0);
- Ebind(fd, &sock, sizeof sock);
- Elisten(fd, 5);
-
- printXid(1);
-
- FD_ZERO(&fdset);
- FD_SET(fd, &fdset);
-
- pid = Efork();
- if (pid==0) {
- Eselect(fd+1, &fdset, 0,0, timeout);
- if (FD_ISSET(fd, &fdset)) handleMessage(fd);
- exit(1);
- }
-
- return EXIT_SUCCESS;
-}
-
-int main(int argc, char *argv[])
-{
- char const * socket_name = 0;
- struct timeval timeout = { 0,0 };
- struct timeval *timeout_ptr = 0;
- char const * quit_msg = false;
-
- while (1) {
- int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_SOCKET : socket_name = optarg; break;
- case CMD_QUIT : quit_msg = optarg; break;
- case CMD_TIMEOUT :
- timeout.tv_sec = atoi(optarg);
- timeout_ptr = &timeout;
- break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return 255;
- break;
- }
- }
-
- if (socket_name==0)
- WRITE_MSG(2, "reserve-context: No socketname specified\n");
- if (quit_msg)
- return sendQuitSignal(socket_name, quit_msg);
- else
- return doit(socket_name, timeout_ptr);
-
- return EXIT_FAILURE;
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on listdevip.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- Print the list of all network (IP) devices. Print the IP
- in fact, including all aliases.
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "compat.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <net/if.h>
-
-
-static int ifconfig_ioctl(
- int fd,
- const char *ifname,
- int cmd,
- struct ifreq *ifr)
-{
- strcpy(ifr->ifr_name, ifname);
- return ioctl(fd, cmd,ifr);
-}
-
-
-static int devlist_read2_2()
-{
- int ret = -1;
- int skfd = socket (AF_INET,SOCK_DGRAM,0);
- if (skfd < 0) {
- perror ("listdevip: socket()");
- }else{
- struct ifconf ifc;
- int numreqs = 30;
- ifc.ifc_buf = NULL;
- ret = 0;
- while (1) {
- ifc.ifc_len = sizeof(struct ifreq) * numreqs;
- ifc.ifc_buf = (char*)realloc(ifc.ifc_buf, ifc.ifc_len);
-
- if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) {
- perror("listdevip: SIOCGIFCONF");
- ret = -1;
- break;
- }
- if (ifc.ifc_len == (int)sizeof(struct ifreq) * numreqs) {
- /* assume it overflowed and try again */
- numreqs += 10;
- continue;
- }
- break;
- }
- if (ret == 0){
- struct ifreq *ifr = ifc.ifc_req;
- int n;
- for (n = 0; n < ifc.ifc_len; n += sizeof(struct ifreq)) {
- struct sockaddr_in *sin = (struct sockaddr_in*)&ifr->ifr_addr;
- unsigned long addr = ntohl(sin->sin_addr.s_addr);
- unsigned long mask = 0xffffff00;
- struct ifreq ifmask;
- if (ifconfig_ioctl(skfd,ifr->ifr_name,SIOCGIFNETMASK, &ifmask) >= 0){
- struct sockaddr_in *sin = (struct sockaddr_in*)&ifmask.ifr_addr;
- mask = ntohl(sin->sin_addr.s_addr);
- }
-
- printf ("%lu.%lu.%lu.%lu/%lu.%lu.%lu.%lu\n"
- ,(addr>>24)&0xff
- ,(addr>>16)&0xff
- ,(addr>>8)&0xff
- ,addr&0xff
- ,(mask>>24)&0xff
- ,(mask>>16)&0xff
- ,(mask>>8)&0xff
- ,mask&0xff);
- ifr++;
- }
- }
- free(ifc.ifc_buf);
- }
- return ret;
-}
-
-int main (int UNUSED argc, char UNUSED *argv[])
-{
- devlist_read2_2();
- return 0;
-}
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <time.h>
-#include <sys/file.h>
-#include <sys/param.h>
-
-static void
-showHelp(char const *cmd)
-{
- WRITE_MSG(1, "Usage: ");
- WRITE_STR(1, cmd);
- WRITE_MSG(1,
- " [--] <lockfile> <syncpipe> [<timeout>]\n\n"
- "Protocol:\n"
- " 1. parent (shell) creates a named <syncpipe>\n"
- " 2. 'lockfile' will be called\n"
- " 3a. 'lockfile' waits until somebody opens the <syncpipe> for reading\n"
- " 3b. parent (shell) opens the pipe for reading and blocks\n"
- " 4. 'lockfile' calls flock() on the <lockfile>\n"
- " 5. 'lockfile' closes the <syncpipe>\n"
- " 6. parent (shell) unlocks since <syncpipe> is closed\n"
- " 7. 'lockfile' goes into infinite loop\n"
- " 8. parent sends SIGHUP (or other signal) to 'lockfile\n"
- "\n"
- "Sample code:\n"
- " tmp=$(mktemp /tmp/lock.XXXXXX)\n"
- " rm -f $tmp # safe since mknod(2) does not follow symlinks\n"
- " mkfifo -m700 $tmp || exit 1\n"
- " lockfile $lock $tmp &\n"
- " $tmp\n"
- " ... <actions> ...\n"
- " kill -HUP $! # (implicated by shell-exit)\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(0);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "lockfile " VERSION " -- locks a file"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-alarmFunc(int UNUSED sig)
-{
- signal(SIGALRM, alarmFunc);
-}
-
-static void
-quitFunc(int UNUSED sig)
-{
- _exit(0);
-}
-
-int main(int argc, char *argv[])
-{
- int fd, sync_fd = -1;
- int idx = 1;
- time_t end_time;
- pid_t const ppid = getppid();
-
- if (argc>=2) {
- if (strcmp(argv[1], "--help") ==0) showHelp(argv[0]);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (strcmp(argv[1], "--") ==0) ++idx;
- }
-
- if (argc<idx+2) {
- WRITE_MSG(2, "Not enough parameters; use '--help' for more information\n");
- return EXIT_FAILURE;
- }
-
- end_time = time(0);
- if (argc==idx+3) end_time += atoi(argv[idx+2]);
- else end_time += 300;
-
- if ((sync_fd=open(argv[idx+1], O_WRONLY))==-1)
- perror("lockfile: open(<syncpipe>)");
- else if ((fd=open(argv[idx], O_CREAT|O_RDONLY|O_NOFOLLOW|O_NONBLOCK, 0644))==-1)
- perror("lockfile: open(<lockfile>)");
- else if (unlink(argv[idx+1])==-1)
- perror("lockfile: unlink(<syncpipe>)");
- else if (siginterrupt(SIGALRM, 1)==-1)
- perror("lockfile: siginterrupt()");
- else if (signal(SIGALRM, alarmFunc)==SIG_ERR ||
- signal(SIGHUP, quitFunc) ==SIG_ERR)
- perror("lockfile: signal()");
- else while (time(0)<end_time && getppid()==ppid) {
- int duration = end_time-time(0);
- alarm(MIN(10, MAX(duration,1)));
-
- if (flock(fd,LOCK_EX)==-1) {
- if (errno==EINTR) continue;
- perror("lockfile: flock()");
- break;
- }
- signal(SIGALRM, SIG_IGN);
-
- WRITE_MSG(sync_fd, "#!/bin/true\n");
- close(sync_fd);
- while (getppid()==ppid) sleep(10);
-
- return EXIT_SUCCESS;
- }
-
- if (sync_fd!=-1)
- WRITE_MSG(sync_fd, "#!/bin/false\n");
- return EXIT_FAILURE;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "fstool.h"
-#include "util.h"
-
-#include <ensc_vector/vector.h>
-#include <lib/vserver.h>
-#include <lib/vserver-internal.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <assert.h>
-
-#define ENSC_WRAPPERS_STDLIB 1
-#include <wrappers.h>
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { 0,0,0,0 }
-};
-
-char const CMDLINE_OPTIONS_SHORT[] = "Radnx";
-
-struct XidNameMapping {
- xid_t xid;
- char const * name;
-};
-
-static struct Vector xid_name_mapping;
-
-void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [-Radnx] [--] <file>*\n\n"
- " Options:\n"
- " -R ... recurse through directories\n"
- " -a ... display files starting with '.' also\n"
- " -d ... list directories like other files instead of\n"
- " listing their content\n"
- " -n ... do not try to do xid -> vserver-name mapping\n"
- " -x ... do not cross filesystems\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-void
-showVersion()
-{
- WRITE_MSG(1,
- "lsxid " VERSION " -- shows the context which is associated to a file\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-void
-fixupParams(struct Arguments UNUSED * args, int UNUSED argc)
-{
- Vector_init(&xid_name_mapping, sizeof (struct XidNameMapping));
-}
-
-static int
-cmpMap(void const *xid_v, void const *map_v)
-{
- xid_t const * const xid = xid_v;
- struct XidNameMapping const * const map = map_v;
-
- return *xid - map->xid;
-}
-
-static char const *
-lookupContext(xid_t xid)
-{
- struct XidNameMapping *res;
-
- res = Vector_search(&xid_name_mapping, &xid, cmpMap);
-
- if (res==0) {
- vcCfgStyle style = vcCFG_AUTO;
- char const * vcfg = vc_getVserverByCtx(xid, &style, 0);
-
- res = Vector_insert(&xid_name_mapping, &xid, cmpMap);
- if (vcfg) res->name = vc_getVserverName(vcfg, style);
- else res->name = 0;
- res->xid = xid;
-
- free(const_cast(char *)(vcfg));
- }
-
- assert(res!=0);
-
- return res->name;
-}
-
-static xid_t
-getFileContext(char const *name)
-{
- xid_t res;
- uint32_t mask = VC_IATTR_XID;
-
- if (vc_get_iattr(name, &res, 0, &mask)==-1)
- perror("vc_get_iattr()");
-
- return (mask&VC_IATTR_XID) ? res : VC_NOCTX;
-}
-
-bool
-handleFile(char const *name, char const *display_name)
-{
- xid_t ctx = 0;
- char buf[MAX(sizeof(ctx)*3+1, 20)];
- bool need_write = true;
-
- memset(buf, ' ', sizeof buf);
-
-#if 1
- ctx = getFileContext(name);
-#else
-# warning Compiling in debug-code
- ctx = random() % 10 + 49213;
-#endif
-
- if (ctx==VC_NOCTX) {
- memcpy(buf, "!!ERR!!", 7);
- Vwrite(1, buf, sizeof buf);
- need_write = false;
- }
- else if (global_args->do_mapping) {
- char const * vname = lookupContext(ctx);
- if (!vname) buf[0] = '\0';
- else {
- size_t l = strlen(vname);
- if (l<sizeof(buf)) Vwrite(1, buf, sizeof(buf)-l);
- Vwrite(1, vname, l);
-
- need_write = false;
- }
- }
-
- if (need_write) {
- size_t l = utilvserver_fmt_ulong(buf, ctx);
- if (l<sizeof(buf)) Vwrite(1, buf+l, sizeof(buf)-l);
- Vwrite(1, buf, l);
- }
-
- Vwrite(1, " ", 2);
- Vwrite(1, display_name, strlen(display_name));
- Vwrite(1, "\n", 1);
-
- return ctx!=VC_NOCTX;
-}
+++ /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 "util.h"
-#include <stdlib.h>
-
-static inline void
-showHelp(int fd, int exit_code)
-{
- WRITE_MSG(fd,
- "Usage: mask2prefix <mask>\n");
- exit(exit_code);
-}
-
-int main(int argc, char *argv[])
-{
- char *err_ptr, *ptr;
- int len = 0;
- size_t i;
-
- if (argc!=2) showHelp(2,255);
-
- ptr = argv[1];
- for (i=0; i<4; ++i) {
- unsigned int val = strtol(ptr, &err_ptr, 10);
-
- switch (*err_ptr) {
- case '.' :
- case '\0' : break;
- default :
- WRITE_MSG(2, "Invalid mask specified\n");
- return 255;
- }
-
- if (val>=0x100) {
- WRITE_MSG(2, "Invalid mask specified\n");
- return 255;
- }
-
- while (val&0x80) {
- ++len;
- val <<= 1;
- }
-
- if (val!=0xff00) break;
-
- ptr = err_ptr+1;
- }
-
- return len;
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on parserpmdump.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- Litte utility to extract non config file from
- an rpm --dump command.
-*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <alloca.h>
-
-
-int main (int argc, char *argv[])
-{
- int *tblen = alloca(argc * sizeof(int));
- int i;
- char tmp[1000];
-
- for (i=1; i<argc; i++) tblen[i] = strlen(argv[i]);
- while (fgets(tmp,sizeof(tmp)-1,stdin)!=NULL){
- int i;
- // Check if the file is in an excluded directory
- for (i=1; i<argc; i++){
- if (strncmp(argv[i],tmp,tblen[i])==0) break;
- }
- if (i == argc){
- // Ok no match
- int last = strlen(tmp)-1;
- mode_t mode=-1;
- int type=-1;
- char *start = tmp;
- int i;
-
- if (last >= 0 && tmp[last] == '\n') tmp[last] = '\0';
-
- for (i=0; i<8; i++){
- char *pt = start;
- while (*pt > ' ') pt++;
- if (*pt == ' ') *pt++ = '\0';
- if (i == 4){
- sscanf(start,"%o",&mode);
- }else if (i==7){
- type = atoi(start);
- }
- start = pt;
-
- }
- if (S_ISREG(mode) && type == 0) printf ("%s\n",tmp);
- }
- }
- return 0;
-}
-
+++ /dev/null
-// $Id$
-
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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 "util.h"
-
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <unistd.h>
-#include <stdio.h>
-
-static void
-showHelp(char const *cmd)
-{
- WRITE_MSG(1, "Usage: ");
- WRITE_STR(1, cmd);
- WRITE_MSG(1,
- " [--] <filename>\n"
- "\n"
- "Display value of a symbolic link on standard output.\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(0);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "readlink " VERSION " -- display value of symlink\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-
-int main (int argc, char *argv[])
-{
- char buf[PATH_MAX + 2];
- int idx = 1;
- int len;
-
- if (argc>=2) {
- if (strcmp(argv[1], "--help") ==0) showHelp(argv[0]);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (strcmp(argv[1], "--") ==0) ++idx;
- }
- if (argc<idx+1)
- WRITE_MSG(2, "No filename specified; use '--help' for more information\n");
- else if ((len=readlink(argv[idx], buf, sizeof(buf)-2))==-1)
- PERROR_Q("readlink: readlink", argv[idx]);
- else {
- buf[len++] = '\n';
- Vwrite(1, buf, len);
- return EXIT_SUCCESS;
- }
-
- return EXIT_FAILURE;
-}
-
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on rebootmgr.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- The reboot manager allow a virtual server administrator to request
- a complete restart of his vserver. This means that all services
- are terminated, all remaining processes are killed and then
- all services are started.
-
- This is done by issuing
-
- /usr/sbin/vserver vserver restart
-
-
- The rebootmgr installs a unix domain socket in each vservers
- and listen for the reboot messages. All other message are discarded.
-
- The unix domain socket is placed in /vservers/N/dev/reboot and is
- turned immutable.
-
- The vreboot utility is used to send the signal from the vserver
- environment.
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "pathconfig.h"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <limits.h>
-#include <errno.h>
-#include <syslog.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <alloca.h>
-
-static void usage()
-{
- fprintf (stderr,"rebootmgr version %s\n",VERSION);
- fprintf (stderr,"\n");
- fprintf (stderr,"rebootmgr [--pidfile file ] vserver-name [ vserver-name ...]\n");
-}
-
-static int rebootmgr_opensocket (const char *vname)
-{
- int ret = -1;
- char sockn[PATH_MAX];
- int fd = socket (AF_UNIX,SOCK_STREAM,0);
- sprintf (sockn, DEFAULT_VSERVERDIR "/%s/dev/reboot",vname);
- unlink (sockn);
- if (fd == -1){
- fprintf (stderr,"Can't create a unix domain socket (%s)\n"
- ,strerror(errno));
- }else{
- struct sockaddr_un un;
- un.sun_family = AF_UNIX;
- strcpy (un.sun_path,sockn);
- if (bind(fd,(struct sockaddr*)&un,sizeof(un))==-1){
- fprintf (stderr,"Can't bind to file %s (%s)\n",sockn
- ,strerror(errno));
- }else{
- int code;
- chmod (sockn,0600);
- code = listen (fd,10);
- if (code == -1){
- fprintf (stderr,"Can't listen to file %s (%s)\n",sockn
- ,strerror(errno));
- }else{
- ret = fd;
- }
- }
- }
- return ret;
-}
-
-static int rebootmgr_process (int fd, const char *vname)
-{
- int ret = -1;
- char buf[100];
- int len = read (fd,buf,sizeof(buf)-1);
- // fprintf (stderr,"process %d %s len %d\n",fd,vname,len);
- if (len > 0){
- buf[len] = '\0';
- if (strcmp(buf,"reboot\n")==0){
- char cmd[1000];
- syslog (LOG_NOTICE,"reboot vserver %s\n",vname);
- snprintf (cmd,sizeof(cmd)-1, SBINDIR "/vserver %s restart >>/var/log/boot.log 2>&1", vname);
- system (cmd);
- ret = 0;
- }else if (strcmp(buf,"halt\n")==0){
- char cmd[1000];
- syslog (LOG_NOTICE,"halt vserver %s\n",vname);
- snprintf (cmd,sizeof(cmd)-1, SBINDIR "/vserver %s stop >>/var/log/boot.log 2>&1", vname);
- system (cmd);
- ret = 0;
- }else{
- syslog (LOG_ERR,"Invalid request from vserver %s",vname);
- }
- }
- return ret;
-}
-
-
-int main (int argc, char *argv[])
-{
- int ret = -1;
- if (argc < 2){
- usage();
- }else{
- int error = 0;
- int start = 1;
- int i;
- int *sockets = alloca(argc * sizeof(int));
-
- openlog ("rebootmgr",LOG_PID,LOG_DAEMON);
- for (i=0; i<argc; i++){
- const char *arg = argv[i];
- if (strcmp(arg,"--pidfile")==0){
- const char *pidfile = argv[i+1];
- FILE *fout = fopen (pidfile,"w");
- if (fout == NULL){
- fprintf (stderr,"Can't open pidfile %s (%s)\n"
- ,pidfile,strerror(errno));
-
- __extension__
- syslog (LOG_ERR,"Can't open pidfile %s (%m)"
- ,pidfile);
- }else{
- fprintf (fout,"%d\n",getpid());
- fclose (fout);
- }
- start = i+2;
- i++;
- }else if (strcmp(arg,"--")==0){
- start = i+1;
- break;
- }else if (arg[0] == '-'){
- fprintf (stderr,"Invalid argument %s\n",arg);
- syslog (LOG_ERR,"Invalid argument %s",arg);
- }
- }
- for (i=start; i<argc; i++){
- int fd = rebootmgr_opensocket (argv[i]);
- if (fd == -1){
- error = 1;
- }else{
- sockets[i] = fd;
- }
- }
- if (!error){
- int maxhandles = argc*2;
- struct {
- int handle;
- const char *vname;
- } handles[maxhandles];
- int nbhandles=0;
- while (1){
- int maxfd = 0;
- int i;
- int ok;
-
- fd_set fdin;
- FD_ZERO (&fdin);
- for (i=start; i<argc; i++){
- int fd = sockets[i];
- if (fd > maxfd) maxfd = fd;
- FD_SET (fd,&fdin);
- }
- for (i=0; i<nbhandles; i++){
- int fd = handles[i].handle;
- if (fd > maxfd) maxfd = fd;
- FD_SET (fd,&fdin);
- }
- ok = select (maxfd+1,&fdin,NULL,NULL,NULL);
- if (ok <= 0){
- break;
- }else{
- int i;
- int dst = 0;
-
- for (i=start; i<argc; i++){
- int fd = sockets[i];
- if (FD_ISSET(fd,&fdin)){
- struct sockaddr_un unc;
- socklen_t len = sizeof(unc);
- unc.sun_family = AF_UNIX;
- fd = accept (fd,(struct sockaddr*)&unc,&len);
- if (fd != -1){
- if (nbhandles == maxhandles){
- int j;
- // Overloaded, we close every handle
- syslog (LOG_ERR,"%d sockets opened: Overloaded\n",nbhandles);
- for (j=0; j<nbhandles; j++){
- close (handles[j].handle);
- }
- nbhandles = 0;
- }
- handles[nbhandles].handle = fd;
- handles[nbhandles].vname = argv[i];
- nbhandles++;
- // fprintf (stderr,"accept %d\n",nbhandles);
- }
- }
- }
- for (i=0; i<nbhandles; i++){
- int fd = handles[i].handle;
- if (FD_ISSET(fd,&fdin)){
- if (rebootmgr_process (fd,handles[i].vname)==-1){
- close (fd);
- }else{
- handles[dst++] = handles[i];
- }
- }else{
- handles[dst++] = handles[i];
- }
- }
- nbhandles = dst;
- }
- }
- }
- }
- return ret;
-}
-
-
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on reducecap.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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 "util.h"
-#include "vserver.h"
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <getopt.h>
-#include <sys/param.h>
-
-#define ENSC_WRAPPERS_PREFIX "reducecap: "
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-
-#undef _POSIX_SOURCE
-#include "capability-compat.h"
-
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-
-#define CMD_SHOW 0x2000
-#define CMD_PID 0x2001
-
-#define CMD_CAP 0x4000
-#define CMD_FLAG 0x4004
-#define CMD_SECURE 0x4006
-
-#ifdef VC_ENABLE_API_LEGACY
-# define CMD_OBSOLETE_CHOWN 0x8000
-# define CMD_OBSOLETE_DAC_OVERRIDE 0x8001
-# define CMD_OBSOLETE_DAC_READ_SEARCH 0x8002
-# define CMD_OBSOLETE_FOWNER 0x8003
-# define CMD_OBSOLETE_FSETID 0x8004
-# define CMD_OBSOLETE_KILL 0x8005
-# define CMD_OBSOLETE_SETGID 0x8006
-# define CMD_OBSOLETE_SETUID 0x8007
-# define CMD_OBSOLETE_SETPCAP 0x8008
-# define CMD_OBSOLETE_SYS_TTY_CONFIG 0x8009
-# define CMD_OBSOLETE_LEASE 0x800a
-# define CMD_OBSOLETE_SYS_CHROOT 0x800b
-# define CMD_OBSOLETE_X_LINUX_IMMUTABLE 0x800c
-# define CMD_OBSOLETE_X_NET_BIND_SERVICE 0x800d
-# define CMD_OBSOLETE_X_NET_BROADCAST 0x800e
-# define CMD_OBSOLETE_X_NET_ADMIN 0x800f
-# define CMD_OBSOLETE_X_NET_RAW 0x8010
-# define CMD_OBSOLETE_X_IPC_LOCK 0x8011
-# define CMD_OBSOLETE_X_IPC_OWNER 0x8012
-# define CMD_OBSOLETE_X_SYS_MODULE 0x8013
-# define CMD_OBSOLETE_X_SYS_RAWIO 0x8014
-# define CMD_OBSOLETE_X_SYS_PACCT 0x8015
-# define CMD_OBSOLETE_X_SYS_ADMIN 0x8016
-# define CMD_OBSOLETE_X_SYS_BOOT 0x8017
-# define CMD_OBSOLETE_X_SYS_NICE 0x8018
-# define CMD_OBSOLETE_X_SYS_RESOURCE 0x8019
-# define CMD_OBSOLETE_X_SYS_TIME 0x801a
-# define CMD_OBSOLETE_X_MKNOD 0x801b
-# define CMD_OBSOLETE_X_QUOTACTL 0x801c
-
-static char const * const OBSOLETE_MAPPING[] = {
- // 0 1 2 3
- "CHOWN", "DAC_OVERRIDE", "DAC_READ_SEARCH", "FOWNER",
- "FSETID", "KILL", "SETGID", "SETUID",
- "SETPCAP", "SYS_TTY_CONFIG", "LEASE", "SYS_CHROOT",
- "LINUX_IMMUTABLE", "NET_BIND_SERVICE", "NET_BROADCAST", "NET_ADMIN",
- "NET_RAW", "IPC_LOCK", "IPC_OWNER", "SYS_MODULE",
- "SYS_RAWIO", "SYS_PACCT", "SYS_ADMIN", "SYS_BOOT",
- "SYS_NICE", "SYS_RESOURCE", "SYS_TIME", "MKNOD",
- "QUOTACTL" };
-#endif
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "cap", required_argument, 0, CMD_CAP },
- { "flag", required_argument, 0, CMD_FLAG },
- { "secure", no_argument, 0, CMD_SECURE },
- { "show", no_argument, 0, CMD_SHOW },
- { "pid", required_argument, 0, CMD_PID },
-#ifdef VC_ENABLE_API_LEGACY
- { "CAP_CHOWN", no_argument, 0, CMD_OBSOLETE_CHOWN },
- { "CAP_DAC_OVERRIDE", no_argument, 0, CMD_OBSOLETE_DAC_OVERRIDE },
- { "CAP_DAC_READ_SEARCH", no_argument, 0, CMD_OBSOLETE_DAC_READ_SEARCH },
- { "CAP_FOWNER", no_argument, 0, CMD_OBSOLETE_FOWNER },
- { "CAP_FSETID", no_argument, 0, CMD_OBSOLETE_FSETID },
- { "CAP_KILL", no_argument, 0, CMD_OBSOLETE_KILL },
- { "CAP_SETGID", no_argument, 0, CMD_OBSOLETE_SETGID },
- { "CAP_SETUID", no_argument, 0, CMD_OBSOLETE_SETUID },
- { "CAP_SETPCAP", no_argument, 0, CMD_OBSOLETE_SETPCAP },
- { "CAP_SYS_TTY_CONFIG", no_argument, 0, CMD_OBSOLETE_SYS_TTY_CONFIG },
- { "CAP_LEASE", no_argument, 0, CMD_OBSOLETE_LEASE },
- { "CAP_SYS_CHROOT", no_argument, 0, CMD_OBSOLETE_SYS_CHROOT },
- { "--CAP_LINUX_IMMUTABLE", no_argument, 0, CMD_OBSOLETE_X_LINUX_IMMUTABLE },
- { "--CAP_NET_BIND_SERVICE", no_argument, 0, CMD_OBSOLETE_X_NET_BIND_SERVICE },
- { "--CAP_NET_BROADCAST", no_argument, 0, CMD_OBSOLETE_X_NET_BROADCAST },
- { "--CAP_NET_ADMIN", no_argument, 0, CMD_OBSOLETE_X_NET_ADMIN },
- { "--CAP_NET_RAW", no_argument, 0, CMD_OBSOLETE_X_NET_RAW },
- { "--CAP_IPC_LOCK", no_argument, 0, CMD_OBSOLETE_X_IPC_LOCK },
- { "--CAP_IPC_OWNER", no_argument, 0, CMD_OBSOLETE_X_IPC_OWNER },
- { "--CAP_SYS_MODULE", no_argument, 0, CMD_OBSOLETE_X_SYS_MODULE },
- { "--CAP_SYS_RAWIO", no_argument, 0, CMD_OBSOLETE_X_SYS_RAWIO },
- { "--CAP_SYS_PACCT", no_argument, 0, CMD_OBSOLETE_X_SYS_PACCT },
- { "--CAP_SYS_ADMIN", no_argument, 0, CMD_OBSOLETE_X_SYS_ADMIN },
- { "--CAP_SYS_BOOT", no_argument, 0, CMD_OBSOLETE_X_SYS_BOOT },
- { "--CAP_SYS_NICE", no_argument, 0, CMD_OBSOLETE_X_SYS_NICE },
- { "--CAP_SYS_RESOURCE", no_argument, 0, CMD_OBSOLETE_X_SYS_RESOURCE },
- { "--CAP_SYS_TIME", no_argument, 0, CMD_OBSOLETE_X_SYS_TIME },
- { "--CAP_MKNOD", no_argument, 0, CMD_OBSOLETE_X_MKNOD },
- { "--CAP_QUOTACTL", no_argument, 0, CMD_OBSOLETE_X_QUOTACTL },
-#endif
- { 0,0,0,0 }
-};
-
-int wrapper_exit_code = 255;
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage:\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--show] [--secure] [--flag <flag>] [--cap <capability>] [--] <cmd> <args>*\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " --show [--pid <pid>]\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "reducecap " VERSION " -- starts programs with reduced capabilities\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003,2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-printReducecap(struct __user_cap_data_struct *user)
-{
- int i;
- WRITE_MSG(1, " Capability Effective Permitted Inheritable\n");
-
- for (i=0;; ++i) {
- size_t const len = 23 + 10*2 + 4+2;
- char const * text = vc_cap2text(i);
- int bit = 1<<i;
- size_t l;
- char buf[len];
- if (text==0) break;
-
- memset(buf, ' ', sizeof buf);
- buf[len-1] = '\n';
- l = MIN(strlen(text), 22);
- memcpy(buf, text, l);
- buf[23 + 10*0 + 4] = (user->effective & bit) ? 'X' : ' ';
- buf[23 + 10*1 + 4] = (user->permitted & bit) ? 'X' : ' ';
- buf[23 + 10*2 + 4] = (user->inheritable & bit) ? 'X' : ' ';
- Vwrite(1, buf, len);
- }
-}
-
-static void
-show(pid_t pid)
-{
- struct __user_cap_header_struct header;
- struct __user_cap_data_struct user;
- header.version = _LINUX_CAPABILITY_VERSION;
- header.pid = pid;
- if (capget(&header,&user)==-1){
- perror ("reducecap: capget()");
- exit(wrapper_exit_code);
- }
-
- printReducecap(&user);
-}
-
-static uint32_t
-getCap(char const *cap)
-{
- int bit = vc_text2cap(cap);
- if (bit!=0) {
- WRITE_MSG(2, "Unknown capability '");
- WRITE_STR(2, optarg);
- WRITE_MSG(2, "'; try '--help' for more information\n");
- exit(wrapper_exit_code);
- }
-
- return (1<<bit);
-}
-
-int main (int argc, char *argv[])
-{
- uint32_t remove = 0;
- bool do_show = false;
- uint32_t flags = 0;
- pid_t pid = 0;
-#ifdef VC_ENABLE_API_LEGACY
- bool show_obsolete_warning = true;
-#endif
-
- while (1) {
- int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
-#ifdef VC_ENABLE_API_LEGACY
- if (c>=CMD_OBSOLETE_CHOWN && c<=CMD_OBSOLETE_X_QUOTACTL) {
- if (show_obsolete_warning) {
- WRITE_MSG(2, "reducecap: warning, obsolete CLI used\n");
- show_obsolete_warning = false;
- }
-
- remove = getCap(OBSOLETE_MAPPING[c-CMD_OBSOLETE_CHOWN]);
- continue;
- }
-#endif
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_SECURE : remove = vc_get_insecurebcaps(); break;
- case CMD_SHOW : do_show = true; break;
- case CMD_PID : pid = atoi(optarg); break;
- case CMD_CAP : remove = getCap(optarg); break;
- case CMD_FLAG : {
- struct vc_err_listparser err;
-
- flags = vc_list2cflag_compat(optarg, 0, &err);
- if (err.ptr!=0) {
- WRITE_MSG(2, "Unknown flag '");
- Vwrite(2, err.ptr, err.len);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
- break;
- }
- }
- }
-
- if (!do_show && optind==argc) {
- WRITE_MSG(2, "No command given; use '--help' for more information\n");
- exit(wrapper_exit_code);
- }
-
- if (!do_show && pid!=0) {
- WRITE_MSG(2, "A pid can be specified in '--show' mode only; use '--help' for more information\n");
- exit(wrapper_exit_code);
- }
-
- if (do_show && optind==argc)
- show(pid);
- else {
- Evc_new_s_context(VC_SAMECTX, remove, flags);
- if (do_show) show(pid);
-
- WRITE_MSG(2, "Executing\n");
- Eexecvp(argv[optind], argv+optind);
- }
-
- return EXIT_SUCCESS;
-}
+++ /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.
-
-
-// Protocol:
-// 1. startup
-// 2. initialize (setuid, ctx-migrate, chroot, ...)
-// 3. send "." token to fd 3
-// 4. wait one character on fd 1
-// 5. process this character and consume further characters from fd 1 as far
-// as needed
-// 6. go to 3) (or exit)
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "internal.h"
-#include "vserver.h"
-#include "util.h"
-
-#include <getopt.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <grp.h>
-#include <pwd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#define ENSC_WRAPPERS_PREFIX "rpm-fake-resolver: "
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#include <wrappers.h>
-
-#define MAX_RQSIZE 0x1000
-
-int wrapper_exit_code = 1;
-
-struct ArgInfo {
- xid_t ctx;
- uid_t uid;
- gid_t gid;
- bool do_fork;
- bool in_ctx;
- char const * pid_file;
- char const * chroot;
- uint32_t caps;
- int flags;
-};
-
-static struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, 'h' },
- { "version", no_argument, 0, 'v' },
- { 0,0,0,0 }
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [-c <ctx>] [-u <uid>] [-g <gid>] [-r <chroot>] [-s] [-n]\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "rpm-fake-resolver " VERSION " -- NSS resovler for rpm-fake\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-
-inline static void
-parseArgs(struct ArgInfo *args, int argc, char *argv[])
-{
- while (1) {
- int c = getopt_long(argc, argv, "F:C:c:u:g:r:ns", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case 'h' : showHelp(1, argv[0], 0);
- case 'v' : showVersion();
-
- case 'c' : args->ctx = atoi(optarg); break;
- case 'u' : args->uid = atoi(optarg); break;
- case 'g' : args->gid = atoi(optarg); break;
- case 'F' : args->flags = atoi(optarg); break;
- case 'C' : args->caps = atoi(optarg); break;
- case 'r' : args->chroot = optarg; break;
- case 'n' : args->do_fork = false; break;
- case 's' : args->in_ctx = true; break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- exit(1);
- break;
- }
- }
-
- if (optind!=argc) {
- WRITE_MSG(2, "No further options allowed; aborting ...\n");
- exit(1);
- }
-
- if (args->chroot==0) {
- WRITE_MSG(2, "No chroot specified; aborting...\n");
- exit(1);
- }
-}
-
-static void
-sendResult(bool state, uint32_t res)
-{
- if (state) {
- static uint8_t ONE = 1;
- Ewrite(1, &ONE, sizeof ONE);
- }
- else {
- static uint8_t ZERO = 0;
- Ewrite(1, &ZERO, sizeof ZERO);
- }
-
- Ewrite(1, &res, sizeof res);
-}
-
-static void
-do_getpwnam()
-{
- uint32_t len;
- Eread(0, &len, sizeof len);
-
- if (len<MAX_RQSIZE) {
- char buf[len+1];
- struct passwd * res;
-
- Eread(0, buf, len);
- buf[len] = '\0';
- res = getpwnam(buf);
- if (res!=0) sendResult(true, res->pw_uid);
- else sendResult(false, -1);
- }
- // TODO: logging
-}
-
-static void
-do_getgrnam()
-{
- uint32_t len;
- Eread(0, &len, sizeof len);
-
- if (len<MAX_RQSIZE) {
- char buf[len+1];
- struct group * res;
-
- Eread(0, buf, len);
- buf[len] = '\0';
- res = getgrnam(buf);
- if (res!=0) sendResult(true, res->gr_gid);
- else sendResult(false, -1);
- }
- // TODO: logging
-}
-
-static void
-do_closenss()
-{
- uint8_t what;
- Eread(0, &what, sizeof what);
- switch (what) {
- case 'p' : endpwent(); break;
- case 'g' : endgrent(); break;
- default : break;
- }
-}
-
-static void
-run()
-{
- uint8_t c;
-
- while (true) {
- Ewrite(3, ".", 1);
- Eread (0, &c, sizeof c);
- switch (c) {
- case 'P' : do_getpwnam(); break;
- case 'G' : do_getgrnam(); break;
- case 'Q' : exit(0);
- case 'C' : do_closenss(); break;
- case '.' : Ewrite(1, ".", 1); break;
- default : Ewrite(1, "?", 1); break;
- }
- }
-}
-
-static void
-daemonize(struct ArgInfo const UNUSED * args, int pid_fd)
-{
- int p[2];
- pid_t pid;
- char c;
-
- Epipe(p);
- pid = Efork();
-
- if (pid!=0) {
- if (pid_fd!=-1) {
- char buf[sizeof(id_t)*3 + 2];
- size_t l;
-
- l = utilvserver_fmt_uint(buf, pid);
- Ewrite(pid_fd, buf, l);
- Ewrite(pid_fd, "\n", 1);
- }
- _exit(0);
- }
- Eclose(p[1]);
- read(p[0], &c, 1);
- Eclose(p[0]);
-}
-
-static void
-activateContext(xid_t xid, bool in_ctx,
- uint32_t xid_caps, int xid_flags)
-{
- if (in_ctx) {
- struct vc_ctx_flags flags = {
- .flagword = 0,
- .mask = VC_VXF_STATE_SETUP,
- };
-
- Evc_set_cflags(xid, &flags);
- }
- else if (vc_isSupported(vcFEATURE_MIGRATE))
- Evc_ctx_migrate(xid);
- else {
-#ifdef VC_ENABLE_API_COMPAT
- Evc_new_s_context(xid, xid_caps, xid_flags);
-#else
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "can not change context: migrate kernel feature missing and 'compat' API disabled\n");
- exit(wrapper_exit_code);
-#endif
- }
-}
-
-int main(int argc, char * argv[])
-{
- struct ArgInfo args = {
- .ctx = VC_DYNAMIC_XID,
- .uid = 99,
- .gid = 99,
- .do_fork = true,
- .pid_file = 0,
- .chroot = 0,
- .in_ctx = false,
- .flags = S_CTX_INFO_LOCK,
- };
- int pid_fd = -1;
-
-#ifndef __dietlibc__
-# warning *** rpm-fake-resolver is built against glibc; please do not report errors before trying a dietlibc version ***
- WRITE_MSG(2,
- "*** rpm-fake-resolver was built with glibc; please do ***\n"
- "*** not report errors before trying a dietlibc version. ***\n");
-#endif
-
- parseArgs(&args, argc, argv);
- if (args.pid_file && args.do_fork)
- pid_fd = EopenD(args.pid_file, O_CREAT|O_WRONLY, 0644);
-
- if (args.chroot) Echroot(args.chroot);
- Echdir("/");
-
- activateContext(args.ctx, args.in_ctx, args.caps, args.flags);
- Esetgroups(0, &args.gid);
- Esetgid(args.gid);
- Esetuid(args.uid);
-
- if (args.do_fork) daemonize(&args, pid_fd);
- if (pid_fd!=-1) close(pid_fd);
- run();
-}
+++ /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 "pathconfig.h"
-#include "util.h"
-
-#include <lib/vserver.h>
-#include <lib/internal.h>
-#include <lib_internal/sys_clone.h>
-
-#include <sys/socket.h>
-#include <dlfcn.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <asm/unistd.h>
-#include <string.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <sys/mount.h>
-#include <linux/fs.h>
-#include <sched.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/un.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <grp.h>
-
-
- // from selinux.h
- // FIXME: add configure autodetection and include <selinux.h> directly
-int rpm_execcon(unsigned int verified,
- const char *filename,
- char *const argv[], char *const envp[]);
-
-
-#define ENSC_WRAPPERS_PREFIX "rpm-fake.so: "
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-#undef _POSIX_SOURCE
-#include "capability-compat.h"
-
-#ifndef CLONE_NEWNS
-# define CLONE_NEWNS 0x00020000
-#endif
-
-#define LIBNAME "rpm-fake.so"
-#define PLATFORM_FILE "/etc/rpm/platform"
-
-#define INIT(FILE,FUNC) FUNC##_func = ((__typeof__(FUNC) *) (xdlsym(FILE, #FUNC)))
-#define DECLARE(FUNC) static __typeof__(FUNC) * FUNC##_func = 0
-
-#define DEBUG 1
-
-#define DBG_INIT 0x0001
-#define DBG_VARIABLES 0x0002
-#define DBG_RESOLVER 0x0004
-#define DBG_EXECV 0x0008
-#define DBG_ENV 0x0010
-#define DBG_VERBOSE0 0x8000
-#define DBG_VERBOSE1 (0x4000 | DBG_VERBOSE0)
-#define DBG_VERBOSE2 (0x2000 | DBG_VERBOSE1)
-
-int wrapper_exit_code = 255;
-
-static xid_t ctx = VC_NOCTX;
-static uint32_t caps = ~0;
-static int flags = 0;
-static char const * mnts = 0;
-static char const * root = 0;
-static int pw_sock = -1;
-static int sync_sock = -1;
-static unsigned int debug_level = 0;
-
-static bool is_initialized = false;
-
- //DECLARE(rpm_execcon);
- //DECLARE(execv);
-DECLARE(getpwnam);
-DECLARE(getgrnam);
-DECLARE(endpwent);
-DECLARE(endgrent);
-
-static void initRPMFake() __attribute__((__constructor__));
-static void exitRPMFake() __attribute__((__destructor__));
-
-static inline bool
-isDbgLevel(unsigned int level)
-{
- return ((debug_level&level)==level);
-}
-
-static void *
-xdlsym(void *handle, const char *symbol)
-{
- void *res = dlsym(handle, symbol);
- if (res==0) {
- char const *error = dlerror();
- Vwrite(2, symbol, strlen(symbol));
- Vwrite(2, ": ", 2);
- Vwrite(2, error, strlen(error));
- Vwrite(2, "\n", 2);
-
- _exit(255);
- }
-
- return res;
-}
-
-static void
-showHelp()
-{
- WRITE_MSG(1,
- "Usage: LD_PRELOAD=" LIBNAME " <executable> <args>*\n\n"
- LIBNAME " unterstands the following environment variables:\n"
- " $RPM_FAKE_RESOLVER ... program which does the NSS resolving (defaults\n"
- " to " RESOLVER_PROG ")\n"
- " $RPM_FAKE_RESOLVER_UID ... uid of the resolver program\n"
- " $RPM_FAKE_RESOLVER_GID ... gid of the resolver program\n"
- " $RPM_FAKE_CTX ... vserver context which shall be used for resolver\n"
- " and scriptlets\n"
- " $RPM_FAKE_CAP ... linux capability remove-mask for the context\n"
- " $RPM_FAKE_FLAGS ... vserver flags of the context\n"
- " $RPM_FAKE_CHROOT ... directory of the chroot environment\n"
- " $RPM_FAKE_NAMESPACE_MOUNTS\n"
- " ... colon separated list of directories which will\n"
- " umounted before scriptlet execution\n\n"
- " $RPM_FAKE_HELP ... shows this message\n"
- " $RPM_FAKE_VERSION ... shows the version of this program\n\n"
- " $RPM_FAKE_DEBUG ... sets the debuglevel bitmask\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(0);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- LIBNAME " " VERSION " -- wrapper around rpm\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-unsetPreloadEnv()
-{
- char *env = getenv("LD_PRELOAD");
- char *pos;
-
- // the const <-> non-const assignment is not an issue since the following
- // modifying operations will not be executed in the const-case
- env = env ? env : "";
- pos = strstr(env, LIBNAME);
-
- if (pos!=0) {
- char *end_pos = pos + sizeof(LIBNAME);
- bool is_end = (end_pos[-1]=='\0');
- char *start_pos;
-
- end_pos[-1] = '\0';
- start_pos = strrchr(env, ':');
- if (start_pos==0) start_pos = env;
- else if (!is_end) ++start_pos;
-
- if (is_end) *start_pos = '\0';
- else memmove(start_pos, end_pos, strlen(end_pos)+1);
- }
-
-#ifdef DEBUG
- if (isDbgLevel(DBG_VERBOSE1|DBG_VARIABLES)) {
- WRITE_MSG(2, "env='");
- WRITE_STR(2, env);
- WRITE_MSG(2, "'\n");
- }
-#endif
-
- if (*env=='\0') unsetenv("LD_PRELOAD");
-}
-
-static void
-clearEnv()
-{
- if (isDbgLevel(DBG_ENV)) WRITE_MSG(2, "clearEnv()\n");
-
- unsetenv("RPM_FAKE_S_CONTEXT_REV");
- unsetenv("RPM_FAKE_S_CONTEXT_NR");
- unsetenv("RPM_FAKE_CTX");
- unsetenv("RPM_FAKE_FLAGS");
- unsetenv("RPM_FAKE_CHROOT");
- unsetenv("RPM_FAKE_NAMESPACE_MOUNTS");
-
- unsetenv("RPM_FAKE_RESOLVER_GID");
- unsetenv("RPM_FAKE_RESOLVER_UID");
- unsetenv("RPM_FAKE_RESOLVER");
- unsetenv("RPM_FAKE_PWSOCKET");
-
- unsetenv("RPM_FAKE_DEBUG");
-
- unsetPreloadEnv();
-}
-
-static int
-getDefaultEnv(char const *key, int dflt)
-{
- char *env = getenv(key);
- int res;
-
- if (env==0 || env[0]=='\0') res = dflt;
- else res = atoi(env);
-
- return res;
-}
-
- /// \returns true iff we are in ctx after leaving this function
-static bool
-setupContext(xid_t xid, char const **xid_str)
-{
- bool res = false;
-
- if (vc_isSupported(vcFEATURE_MIGRATE)) {
- xid_t rc=VC_NOCTX;
-
- if ((xid==VC_DYNAMIC_XID || !vc_is_dynamic_xid(xid)) &&
- (rc=vc_ctx_create(xid))==VC_NOCTX &&
- errno!=EEXIST) {
- perror(ENSC_WRAPPERS_PREFIX "vc_create_context()");
- exit(255);
- }
-
- if (rc!=VC_NOCTX) {
- char buf[sizeof(xid_t)*3 + 128];
- size_t l;
- struct vc_ctx_caps caps;
-
- strcpy(buf, "rpm-fake.so #");
- l = utilvserver_fmt_uint(buf+sizeof("rpm-fake.so #")-1, getppid());
- Evc_set_vhi_name(rc, vcVHI_CONTEXT, buf, sizeof("rpm-fake.so #")+l-1);
-
- caps.ccaps = 0ull;
- caps.cmask = ~0ull;
- caps.bcaps = ~vc_get_insecurebcaps();
- caps.bmask = ~0ull;
- Evc_set_ccaps(rc, &caps);
-
- // context will be activated later...
-
- xid = rc;
- res = true;
- }
- }
-
- if (xid==VC_DYNAMIC_XID)
- *xid_str = 0;
- else {
- char buf[sizeof(xid_t)*3 + 2];
- size_t l;
-
- l = utilvserver_fmt_uint(buf, xid); buf[l] = '\0';
- *xid_str = strdup(buf);
- }
-
- Ewrite(3, &xid, sizeof xid);
- return res;
-}
-
-#if 0
-static void
-initPwSocket()
-{
- char const * sock_name = getenv("RPM_FAKE_PWSOCKET");
- if (sock_name!=0) {
- int flag;
- struct sockaddr_un addr = {
- .sun_family = AF_UNIX,
- };
-
- strncpy(addr.sun_path, sock_name, sizeof(addr.sun_path)-1);
- addr.sun_path[sizeof(addr.sun_path)-1]='\0';
-
- if ((pw_sock=socket(AF_UNIX, SOCK_STREAM, 0))==-1 ||
- connect(pw_sock, (struct sockaddr *)(&addr), sizeof addr)==-1 ||
- (flag=fcntl(pw_sock, F_GETFD))==-1 ||
- fcntl(pw_sock, F_SETFD, flag | FD_CLOEXEC)==-1) {
- perror(ENSC_WRAPPERS_PREFIX "error while initializing pw-socket");
- exit(255);
- }
- }
-}
-#else
-static void
-initPwSocket()
-{
- char const * resolver = getenv("RPM_FAKE_RESOLVER");
- if (resolver==0) resolver=RESOLVER_PROG;
-
- if (resolver!=0 && *resolver!='\0') {
- int res_sock[2];
- int sync_pipe[2];
- pid_t pid;
- char const * uid=0;
- char const * gid=0;
-
- uid=getenv("RPM_FAKE_RESOLVER_UID");
- gid=getenv("RPM_FAKE_RESOLVER_GID");
-
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, res_sock)==-1 ||
- pipe(sync_pipe)==-1 ||
- fcntl(res_sock[0], F_SETFD, FD_CLOEXEC)==-1 ||
- fcntl(sync_pipe[0], F_SETFD, FD_CLOEXEC)==-1) {
- perror(ENSC_WRAPPERS_PREFIX "failed to create/initialize resolver-socket or pipe");
- exit(255);
- }
-
- pid = fork();
- if (pid==-1) {
- perror(ENSC_WRAPPERS_PREFIX "fork()");
- exit(255);
- }
-
- if (pid==0) {
- char const *args[20];
- char const **ptr = args;
- char const *env[] = { "HOME=/", "PATH=/bin:/usr/bin", 0 };
- char const *xid_str;
- char flag_str[ sizeof(flags)*3 + 2];
- char caps_str[ sizeof(caps)*3 + 2];
-
- clearEnv();
-
- setsid();
- dup2(res_sock[1], 0);
- dup2(res_sock[1], 1);
- if (sync_pipe[1]!=3) {
- close(3);
- dup2(sync_pipe[1], 3);
- close(sync_pipe[1]);
- }
- close(res_sock[1]);
- /* ... *socket[0] are marked as close-on-exec ...*/
-
- flag_str[utilvserver_fmt_uint(flag_str, flags)] = '\0';
- caps_str[utilvserver_fmt_uint(caps_str, caps)] = '\0';
-
- *ptr++ = resolver;
- *ptr++ = "-F"; *ptr++ = flag_str;
- *ptr++ = "-C"; *ptr++ = caps_str;
- if (root) { *ptr++ = "-r"; *ptr++ = "."; }
- if (uid) { *ptr++ = "-u"; *ptr++ = uid; }
- if (gid) { *ptr++ = "-g"; *ptr++ = gid; }
-
- if (root) Echdir(root);
-
- if (setupContext(ctx, &xid_str)) { *ptr++ = "-s"; }
- else if (xid_str) { *ptr++ = "-c"; *ptr++ = xid_str; }
-
- *ptr++ = 0;
- execve(resolver, (char **)args, (char **)env);
- perror(ENSC_WRAPPERS_PREFIX "failed to exec resolver");
- exit(255);
- }
- else {
- uint8_t c;
-
- close(res_sock[1]);
- close(sync_pipe[1]);
- pw_sock = res_sock[0];
- sync_sock = sync_pipe[0];
-
- if (read(sync_sock, &ctx, sizeof ctx)!=sizeof(ctx) ||
- read(sync_sock, &c, 1)!=1 ||
- write(pw_sock, ".", 1)!=1 ||
- read(pw_sock, &c, 1)!=1 ||
- c!='.') {
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "failed to initialize communication with resolver\n");
- exit(255);
- }
-
- if (wait4(pid, 0, WNOHANG,0)==-1) {
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX" unexpected initialization-error of resolver\n");
- exit(255);
- }
- }
- }
-}
-#endif
-
-static void
-reduceCapabilities()
-{
- struct __user_cap_header_struct header;
- struct __user_cap_data_struct user;
-
- header.version = _LINUX_CAPABILITY_VERSION;
- header.pid = 0;
-
- if (capget(&header, &user)==-1) {
- perror("capget()");
- exit(wrapper_exit_code);
- }
-
- user.effective &= ~(1<<CAP_MKNOD);
- user.permitted &= ~(1<<CAP_MKNOD);
- user.inheritable &= ~(1<<CAP_MKNOD);
-
- if (capset(&header, &user)==-1) {
- perror("capset()");
- exit(wrapper_exit_code);
- }
-}
-
-static void
-initEnvironment()
-{
- int syscall_rev;
- int syscall_nr;
-
- if (is_initialized) return;
-
- syscall_rev = getDefaultEnv("RPM_FAKE_S_CONTEXT_REV", 0);
- syscall_nr = getDefaultEnv("RPM_FAKE_S_CONTEXT_NR", 273);
-
-#ifdef VC_ENABLE_API_LEGACY
- {
- extern void vc_init_internal_legacy(int ctx_rev, int ctx_number,
- int ipv4_rev, int ipv4_number);
-
- vc_init_internal_legacy(syscall_rev, syscall_nr, 3, 274);
- }
-#endif
-
- ctx = getDefaultEnv("RPM_FAKE_CTX", VC_DYNAMIC_XID);
- caps = getDefaultEnv("RPM_FAKE_CAP", ~0x3404040f);
- flags = getDefaultEnv("RPM_FAKE_FLAGS", 0);
- root = getenv("RPM_FAKE_CHROOT");
- mnts = getenv("RPM_FAKE_NAMESPACE_MOUNTS");
- if (mnts && *mnts) mnts = strdup(mnts);
- else mnts = 0;
-
-#if DEBUG
- if (isDbgLevel(DBG_VERBOSE1))
- dprintf(2, "ctx=%u, caps=%016x, flags=%016x,\nroot='%s',\nmnts='%s'\n",
- ctx, caps, flags, root, mnts);
-#endif
-
- is_initialized = true;
-}
-
-static void
-initSymbols()
-{
- //INIT(RTLD_NEXT, rpm_execcon);
- //INIT(RTLD_NEXT, execv);
- INIT(RTLD_NEXT, getgrnam);
- INIT(RTLD_NEXT, getpwnam);
- INIT(RTLD_NEXT, endpwent);
- INIT(RTLD_NEXT, endgrent);
-}
-
-void
-initRPMFake()
-{
- if (getenv("RPM_FAKE_VERSION")) showVersion();
- if (getenv("RPM_FAKE_HELP")) showHelp();
-
- debug_level = getDefaultEnv("RPM_FAKE_DEBUG", 0);
-
- if (isDbgLevel(DBG_INIT)) WRITE_MSG(2, ">>>>> initRPMFake <<<<<\n");
-
- reduceCapabilities();
- initSymbols();
- initEnvironment();
- initPwSocket();
-
-#if 0
- if (isDbgLevel(DBG_VARIABLES|DBG_VERBOSE2)) {
-
- }
-#endif
-}
-
-void
-exitRPMFake()
-{
- if (isDbgLevel(DBG_INIT)) WRITE_MSG(2, ">>>>> exitRPMFake <<<<<\n");
- if (pw_sock!=-1) {
- uint8_t c;
- if (read(sync_sock, &c, 1)!=1) { /*...*/ }
- if (write(pw_sock, "Q", 1)!=1) { /*...*/ }
- }
-}
-
-
- //============ the worker part ===========
-
-
-static bool
-doPwStringRequest(uint32_t *result, char style, char const *name)
-{
- size_t len = strlen(name);
- uint8_t code;
- uint8_t c;
-
- return (TEMP_FAILURE_RETRY(read (sync_sock, &c, 1))==1 &&
-
- TEMP_FAILURE_RETRY(write(pw_sock, &style, 1))==1 &&
- TEMP_FAILURE_RETRY(write(pw_sock, &len, sizeof len))==sizeof(len) &&
- TEMP_FAILURE_RETRY(write(pw_sock, name, len))==(ssize_t)(len) &&
- TEMP_FAILURE_RETRY(read (pw_sock, &code, sizeof code))==sizeof(code) &&
- TEMP_FAILURE_RETRY(read (pw_sock, result, sizeof *result))==sizeof(*result) &&
- code!=0);
-}
-
-struct passwd *
-getpwnam(const char * name)
-{
- if (pw_sock==-1) return getpwnam_func(name);
- else {
- static struct passwd res = {
- .pw_passwd = "*",
- .pw_gid = -1,
- .pw_gecos = "",
- .pw_dir = "/",
- .pw_shell = "/bin/false"
- };
-
- res.pw_name = (char *)(name);
- if (!doPwStringRequest(&res.pw_uid, 'P', name)) return 0;
-
- return &res;
- }
-}
-
-struct group *
-getgrnam(const char * name)
-{
- if (pw_sock==-1) return getgrnam_func(name);
- else {
- static struct group res = {
- .gr_passwd = "*",
- .gr_mem = 0
- };
-
- res.gr_name = (char *)(name);
- if (!doPwStringRequest(&res.gr_gid, 'G', name)) return 0;
-
- return &res;
- }
-}
-
-void
-endgrent()
-{
- if (pw_sock==-1) endgrent_func();
-}
-
-void
-endpwent()
-{
- if (pw_sock==-1) endpwent_func();
-}
-
-
-static int
-execvWorker(char const *path, char * const argv[], char * const envp[])
-{
- int res = -1;
-
- if (vc_isSupported(vcFEATURE_MIGRATE))
- res = vc_ctx_migrate(ctx);
- else {
-#ifdef VC_ENABLE_API_COMPAT
- res = vc_new_s_context(ctx,caps,flags);
-#else
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "can not change context: migrate kernel feature missing and 'compat' API disabled\n");
-#endif
- }
-
- clearEnv();
-
- if (res!=-1)
- res=execve(path, argv, envp);
-
- return res;
-}
-
-struct ExecvParams
-{
- char const * path;
- char * const * argv;
- char * const * envp;
- char const * mnts;
-};
-
-static int
-removeNamespaceMountsChild(struct ExecvParams const *params)
-{
- char buf[strlen(params->mnts)+1], *ptr;
-
- strcpy(buf, params->mnts);
- ptr = strtok(buf, ":");
- while (ptr) {
- if (umount2(ptr, 0)==-1) {
- // FIXME: What is the semantic for CLONE_NEWNS? Is it ok that mounts in
- // chroots are visible only, when chroot is on /dev/root?
- //
- // For now, ignore any errors, but future versions should handle them.
-
- //return -1;
- }
- ptr = strtok(0, ":");
- }
-
- return execvWorker(params->path, params->argv, params->envp);
-}
-
-static int
-removeNamespaceMounts(char const *path,
- char * const argv[], char * const envp[])
-{
- if (mnts==0) return execvWorker(path, argv, envp);
-
- {
- int status;
- pid_t p, pid;
- struct ExecvParams params;
-
- params.path = path;
- params.argv = argv;
- params.envp = envp;
- params.mnts = mnts;
-
- // the rpmlib signal-handler is still active; use the default one to
- // make wait4() working...
- signal(SIGCHLD, SIG_DFL);
-
-#ifdef NDEBUG
- pid = sys_clone(CLONE_NEWNS|SIGCHLD|CLONE_VFORK, 0);
-#else
- pid = sys_clone(CLONE_NEWNS|SIGCHLD, 0);
-#endif
-
- switch (pid) {
- case -1 : return -1;
- case 0 : _exit(removeNamespaceMountsChild(¶ms));
- default : break;
- }
-
- while ((p=wait4(pid, &status, 0,0))==-1 &&
- (errno==EINTR || errno==EAGAIN)) ;
-
- if (p==-1) return -1;
-
- if (WIFEXITED(status)) _exit(WEXITSTATUS(status));
- if (WIFSIGNALED(status)) kill(getpid(), WTERMSIG(status));
-
- return -1;
- }
-}
-
-
-int
-execv(char const *path, char * const argv[])
-{
- extern char **environ;
-
- if (isDbgLevel(DBG_EXECV)) {
- WRITE_MSG(2, "execv('");
- WRITE_STR(2, path);
- WRITE_MSG(2, "', ...)\n");
- }
-
- return removeNamespaceMounts(path, argv, environ);
-}
-
-int
-rpm_execcon(unsigned int UNUSED verified,
- const char *filename,
- char *const argv[], char *const envp[])
-{
- if (isDbgLevel(DBG_EXECV)) {
- WRITE_MSG(2, "rpm_execcon(..., '");
- WRITE_STR(2, filename);
- WRITE_MSG(2, "', ...)\n");
- }
-
- return removeNamespaceMounts(filename, argv, envp);
-}
-
-int
-is_selinux_enabled()
-{
- return 0;
-}
+++ /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.
-
-// Saves current ctx + vserver-info into 'argv[1] + /run' which must be a dead
-// symlink
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "pathconfig.h"
-#include "vserver.h"
-#include "internal.h"
-#include "util.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <limits.h>
-#include <errno.h>
-
-#define ENSC_WRAPPERS_PREFIX "save_ctxinfo: "
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 255;
-
-inline static void
-checkParams(int argc, char UNUSED * argv[])
-{
- if (argc<3) {
- WRITE_MSG(2, "Usage: save_ctxinfo <VSERVER_DIR> <cmd> <args>*\n");
- exit(255);
- }
-}
-
-int main(int argc, char *argv[])
-{
- char runfile[(checkParams(argc,argv),strlen(argv[1])) + sizeof(DEFAULT_PKGSTATEREVDIR "/99999")];
- char dstfile[PATH_MAX];
- int fd;
- char buf[sizeof(int)*3+2];
- xid_t ctx;
- ssize_t len;
- ssize_t len1 = strlen(argv[1]);
-
- strcpy(runfile, argv[1]);
- strcpy(runfile+len1, "/run");
-
- ctx=Evc_get_task_xid(0);
-
- if (ctx==0) {
- WRITE_MSG(2, "save_ctxinfo: Can not operate in context 0\n");
- return 255;
- }
-
- if (reinterpret_cast(unsigned int)(ctx)>99999) {
- WRITE_MSG(2, "save_ctxinfo: unexpected context\n");
- return 255;
- }
-
- len = EreadlinkD(runfile, dstfile, sizeof(dstfile)-1);
- dstfile[len] = '\0';
- len = utilvserver_fmt_uint(buf, ctx);
-
- fd = EopenD(dstfile, O_EXCL|O_CREAT|O_WRONLY, 0644);
- if (write(fd, buf, len) !=len ||
- write(fd, "\n", 1) !=1) {
- perror("save_ctxinfo: write()");
- return -1;
- }
- Eclose(fd);
-
- strcpy(runfile, DEFAULT_PKGSTATEREVDIR "/");
- strncat(runfile, buf, len);
- unlink(runfile);
- EsymlinkD(argv[1], runfile);
-
- Eexecv(argv[2], argv+2);
-}
+++ /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.
-
-
- // secure-mount <general mount(8) options> [--chroot]
- // [--mtab <mtabfile>] [--fstab <fstabfile>]
- //
- // Executes mount-operations under the current directory: it assumes sources
- // in the current root-dir while destinations are expected in the chroot
- // environment.
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "util.h"
-#include "pathconfig.h"
-
-#include <lib/internal.h>
-
-#include <getopt.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <linux/fs.h>
-#include <assert.h>
-#include <ctype.h>
-#include <sys/wait.h>
-#include <libgen.h>
-#include <signal.h>
-
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-#define MNTPOINT "/etc"
-
-typedef enum { rfsYES, rfsNO, rfsONLY } RootFsOption;
-
-struct MountInfo {
- char const * src;
- char const * dst;
- char const * type;
- unsigned long flag;
- unsigned long xflag;
- unsigned long mask;
- char * data;
-};
-
-struct Options {
- char const * mtab;
- char const * fstab;
- bool do_chroot;
- bool ignore_mtab;
- bool mount_all;
- RootFsOption rootfs;
-
- int cur_dir_fd;
- int cur_rootdir_fd;
-};
-
-#define OPTION_BIND 1024
-#define OPTION_MOVE 1025
-#define OPTION_MTAB 1026
-#define OPTION_FSTAB 1027
-#define OPTION_CHROOT 1028
-#define OPTION_SECURE 1029
-#define OPTION_RBIND 1030
-#define OPTION_ROOTFS 1031
-
-#define XFLAG_NOAUTO 0x01
-
-static struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, 'h' },
- { "version", no_argument, 0, 'v' },
- { "bind", no_argument, 0, OPTION_BIND },
- { "move", no_argument, 0, OPTION_MOVE },
- { "mtab", required_argument, 0, OPTION_MTAB },
- { "fstab", required_argument, 0, OPTION_FSTAB },
- { "rootfs", required_argument, 0, OPTION_ROOTFS },
- { "chroot", no_argument, 0, OPTION_CHROOT },
- { "secure", no_argument, 0, OPTION_SECURE },
- { "rbind", no_argument, 0, OPTION_RBIND },
- { 0, 0, 0, 0 }
-};
-
-#ifndef MS_REC
-# define MS_REC 0x4000
-#endif
-
-static struct FstabOption {
- char const * const opt;
- unsigned long const flag;
- unsigned long const mask;
- unsigned long const xflag;
- bool const is_dflt;
-} const FSTAB_OPTIONS[] = {
- { "defaults", 0, (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|
- MS_SYNCHRONOUS), 0, false },
- { "rbind", MS_BIND|MS_REC, MS_BIND|MS_REC, 0, false },
- { "bind", MS_BIND, MS_BIND, 0, false },
- { "move", MS_MOVE, MS_MOVE, 0, false },
- { "async", 0, MS_SYNCHRONOUS, 0, false },
- { "sync", MS_SYNCHRONOUS, MS_SYNCHRONOUS, 0, false },
- { "atime", 0, MS_NOATIME, 0, false },
- { "noatime", MS_NOATIME, MS_NOATIME, 0, false },
- { "dev", 0, MS_NODEV, 0, false },
- { "nodev", MS_NODEV, MS_NODEV, 0, false },
- { "exec", 0, MS_NOEXEC, 0, false },
- { "noexec", MS_NOEXEC, MS_NOEXEC, 0, false },
- { "suid", 0, MS_NOSUID, 0, false },
- { "nosuid", MS_NOSUID, MS_NOSUID, 0, false },
- { "ro", MS_RDONLY, MS_RDONLY, 0, false },
- { "rw", 0, MS_RDONLY, 0, false },
-
- { "remount", MS_REMOUNT, MS_REMOUNT, 0, false },
- { "users", MS_NOEXEC|MS_NOSUID|MS_NODEV,
- MS_NOEXEC|MS_NOSUID|MS_NODEV, 0, false },
- { "mandlock", MS_MANDLOCK, MS_MANDLOCK, 0, false },
- { "nodiratime", MS_NODIRATIME, MS_NODIRATIME, 0, false },
-#ifdef MS_DIRSYNC
- { "dirsync", MS_DIRSYNC, MS_DIRSYNC, 0, false },
-#endif
- { "_netdev", 0, 0, 0, false },
- { "auto", 0, 0, 0, false },
- { "noauto", 0, 0, XFLAG_NOAUTO, false },
- { "user", 0, 0, 0, false },
- { "nouser", 0, 0, 0, false },
-};
-
-int wrapper_exit_code = 1;
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- VSERVER_DECLARE_CMD(cmd);
-
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--help] [--version] [--bind] [--move] [--rbind] [-t <type>] [--chroot]\n"
- " [--mtab <filename>] [--fstab <filename>] [--rootfs yes|no|only]\n"
- " [-n] -a|([-o <options>] [--] <src> <dst>)\n\n"
- "Executes mount-operations under the current directory: it assumes sources in\n"
- "the current root-dir while destinations are expected in the chroot environment.\n\n"
- "For non-trivial mount-operations it uses the external 'mount' program which\n"
- "can be overridden by the $MOUNT environment variable.\n\n"
- "Options:\n"
- " --bind|move|rbind ... set the correspond flags; with this options\n"
- " the mount will be executed internally without\n"
- " calling an external mount program.\n"
- " -t <type> ... assume the given filesystem type\n"
- " -o <options> ... set additional options; see mount(2) for details\n"
- " -n ... do not update the mtab-file\n"
- " --mtab <filename> ... use <filename> as an alternative mtab file\n"
- " [default: /etc/mtab]\n"
- " --chroot ... chroot into the current directory before\n"
- " mounting the filesystem\n"
- " --fstab <filename> ... use <filename> as an alternative fstab file;\n"
- " this option has an effect only with the '-a'\n"
- " option [default: /etc/fstab]\n"
- " --rootfs yes|no|only ... specifies how to handle an entry for a rootfs\n"
- " ('/') when processing an fstab file. 'yes' will\n"
- " mount it among the other entries, 'only' will\n"
- " mount only the rootfs entry, and 'no' will ignore\n"
- " it and mount only the other entries [default: yes]\n"
- " -a ... mount everything listed in the fstab-file\n\n"
- " <src> ... the source-filesystem; this path is absolute\n"
- " to the current root-filesystem. Only valid\n"
- " without the '-a' option.\n"
- " <dst> ... the destination mount-point; when used with\n"
- " '--chroot', this path is relative to the current\n"
- " directory. Only valid without the '-a' option\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "secure-mount " VERSION " -- secure mounting of directories\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-inline static bool
-isSameObject(struct stat const *lhs,
- struct stat const *rhs)
-{
- return (lhs->st_dev==rhs->st_dev &&
- lhs->st_ino==rhs->st_ino);
-}
-
-static int
-fchroot(int fd)
-{
- if (fchdir(fd)==-1 || chroot(".")==-1) return -1;
- return 0;
-}
-
-static int
-writeX(int fd, void const *buf, size_t len)
-{
- if ((size_t)(write(fd, buf, len))!=len) return -1;
- return 0;
-}
-
-static int
-writeStrX(int fd, char const *str)
-{
- return writeX(fd, str, strlen(str));
-}
-
-static inline char const *
-getType(struct MountInfo const *mnt)
-{
- if (mnt->type==0) return "none";
- else if (strncmp(mnt->type, "ext", 3)==0) return "ufs";
- else return mnt->type;
-}
-
-inline static void
-restoreRoot(struct Options const *opt)
-{
- if (opt->do_chroot!=0 && fchroot(opt->cur_rootdir_fd)==-1) {
- perror("secure-mount: fchdir(\"/\")");
- WRITE_MSG(2, "Failed to restore root-directory; aborting\n");
- exit(1);
- }
-}
-
-static int
-updateMtab(struct MountInfo const *mnt, struct Options const *opt)
-{
- int res = -1;
- int fd;
- assert(opt->mtab!=0);
-
- if (opt->do_chroot && fchroot(opt->cur_dir_fd)==-1) {
- perror("secure-mount: fchroot(\".\")");
- return -1;
- }
-
- fd=open(opt->mtab, O_CREAT|O_APPEND|O_WRONLY, 0644);
-
- if (fd==-1) {
- perror("secure-mount: open(<mtab>)");
- goto err0;
- }
-
- if (flock(fd, LOCK_EX)==-1) {
- perror("secure-mount: flock()");
- goto err1;
- }
-
- if (writeStrX(fd, mnt->src)==-1 ||
- writeStrX(fd, " ")==-1 ||
- writeStrX(fd, mnt->dst)==-1 ||
- writeStrX(fd, " ")==-1 ||
- writeStrX(fd, getType(mnt))==-1 ||
- writeStrX(fd, " ")==-1 ||
- writeStrX(fd, mnt->data ? mnt->data : "defaults")==-1 ||
- writeStrX(fd, " 0 0\n")==-1) {
- perror("secure-mount: write()");
- goto err1;
- }
-
- res = 0;
-
- err1: close(fd);
- err0:
- restoreRoot(opt);
- return res;
-}
-
-static bool
-callExternalMount(struct MountInfo const *mnt)
-{
- char const * argv[10];
- size_t idx = 0;
- pid_t pid;
- int status;
- char const * mount_prog = getenv("MOUNT");
-
- if (mount_prog==0) mount_prog = MOUNT_PROG;
-
- argv[idx++] = mount_prog;
- argv[idx++] = "-n";
- if (mnt->flag & MS_BIND) argv[idx++] = "--bind";
- else if (mnt->flag & MS_MOVE) argv[idx++] = "--move";
-
- argv[idx++] = "-o";
- if (mnt->data && *mnt->data &&
- strcmp(mnt->data, "defaults")!=0) {
- if (mnt->mask & MS_NODEV)
- argv[idx++] = mnt->data;
- else {
- char * tmp = alloca(strlen(mnt->data) + sizeof("nodev,"));
- strcpy(tmp, "nodev,");
- strcat(tmp, mnt->data);
- argv[idx++] = tmp;
- }
- }
- else
- argv[idx++] = "nodev";
-
- if (mnt->type) {
- argv[idx++] = "-t";
- argv[idx++] = mnt->type;
- }
-
- argv[idx++] = mnt->src;
- argv[idx++] = ".";
- argv[idx] = 0;
-
- pid = fork();
- if (pid==-1) {
- perror("secure-mount: fork()");
- return false;
- }
-
- if (pid==0) {
- execv(mount_prog, const_cast(char **)(argv));
- PERROR_Q("secure-mount: execv", mount_prog);
- exit(1);
- }
-
- if (wait4(pid, &status, 0, 0)==-1) {
- perror("secure-mount: wait4()");
- return false;
- }
-
- return (WIFEXITED(status)) && (WEXITSTATUS(status)==0);
-}
-
-inline static bool
-secureChdir(char const *dir, struct Options const *opt)
-{
- int dir_fd;
- bool res = false;
-
- if (opt->do_chroot!=0 && fchroot(opt->cur_dir_fd)==-1) {
- perror("secure-mount: fchroot(\".\")");
- return false;
- }
-
- if (chdir(dir)==-1) {
- PERROR_Q("secure-mount: chdir", dir);
- goto err;
- }
-
- dir_fd = open(".", O_RDONLY|O_DIRECTORY);
- if (dir_fd==-1) {
- perror("secure-mount: open(\".\")");
- goto err;
- }
-
- restoreRoot(opt);
- if (fchdir(dir_fd)==-1)
- PERROR_Q("secure-mount: fchdir", dir);
- else
- res = true;
-
- close(dir_fd);
- return res;
-
- err:
- restoreRoot(opt);
- return false;
-}
-
-static bool
-mountSingle(struct MountInfo const *mnt, struct Options const *opt)
-{
- assert(mnt->dst!=0);
-
- if (!secureChdir(mnt->dst, opt))
- return false;
-
- if (mnt->flag & (MS_BIND|MS_MOVE)) {
- unsigned long flag = mnt->flag;
- if ((flag & MS_NODEV)==0) flag |= MS_NODEV;
-
- if (mount(mnt->src, ".",
- mnt->type ? mnt->type : "",
- flag, mnt->data)==-1) {
- perror("secure-mount: mount()");
- return false;
- }
- }
- else if (!callExternalMount(mnt))
- return false;
-
- if (!opt->ignore_mtab &&
- updateMtab(mnt, opt)==-1) {
- WRITE_MSG(2, "Failed to update mtab-file\n");
- // no error
- }
-
- return true;
-}
-
-static struct FstabOption const *
-searchOption(char const *opt, size_t len)
-{
- struct FstabOption const * i;
- for (i=FSTAB_OPTIONS+0; i<FSTAB_OPTIONS+DIM_OF(FSTAB_OPTIONS); ++i)
- if (strncmp(i->opt, opt, len)==0) return i;
-
- return 0;
-}
-
-static bool
-transformOptionList(struct MountInfo *info, size_t UNUSED *col)
-{
- char const * ptr = info->data;
-
- do {
- char const * pos = strchr(ptr, ',');
- struct FstabOption const * opt;
-
- if (pos==0) pos = ptr+strlen(ptr);
- opt = searchOption(ptr, pos-ptr);
-
- if (opt!=0) {
- info->flag &= ~opt->mask;
- info->flag |= opt->flag;
- info->mask |= opt->mask;
- info->xflag |= opt->xflag;
- }
-
- if (*pos!='\0')
- ptr = pos+1;
- else
- ptr = pos;
-
- } while (*ptr!='\0');
-
- return true;
-}
-
-#define MOVE_TO_NEXT_FIELD(PTR,ALLOW_EOL) \
- while (!isspace(*PTR) && *PTR!='\0') ++PTR; \
- if (col) *col = buf-start_buf+1; \
- if (!(ALLOW_EOL) && *PTR=='\0') return prFAIL; \
- *PTR++ = '\0'; \
- while (isspace(*PTR)) ++PTR
-
-static enum {prDOIT, prFAIL, prIGNORE}
- parseFstabLine(struct MountInfo *info, char *buf, size_t *col)
-{
- char const * const start_buf = buf;
- size_t err_col;
-
- while (isspace(*buf)) ++buf;
- if (*buf=='#' || *buf=='\0') return prIGNORE;
-
- info->src = buf;
- MOVE_TO_NEXT_FIELD(buf, false);
- info->dst = buf;
- MOVE_TO_NEXT_FIELD(buf, false);
- info->type = buf;
- MOVE_TO_NEXT_FIELD(buf, false);
- err_col = buf-start_buf+1;
- info->data = buf;
- MOVE_TO_NEXT_FIELD(buf, true);
-
- info->flag = MS_NODEV;
- info->mask = 0;
- info->xflag = 0;
-
- if (strcmp(info->type, "swap") ==0) return prIGNORE;
- else if (strcmp(info->type, "none") ==0) info->type = 0;
- else if (strcmp(info->type, "devpts")==0) info->mask |= MS_NODEV;
-
- if (col) *col = err_col;
- if (!transformOptionList(info,col)) return prFAIL;
- if (info->xflag & XFLAG_NOAUTO) return prIGNORE;
-
- return prDOIT;
-}
-
-#undef MOVE_TO_NEXT_FIELD
-
-static void
-showFstabPosition(int fd, char const *fname, size_t line_nr, size_t col_nr)
-{
- char buf[3*sizeof(line_nr)*2 + 4];
- size_t len = utilvserver_fmt_uint(buf+1, line_nr)+1;
-
- buf[0] = ':';
- buf[len++] = ':';
- len += utilvserver_fmt_uint(buf+len, col_nr);
- WRITE_STR(fd, fname);
- Vwrite(fd, buf, len);
-}
-
-
-static bool
-mountFstab(struct Options const *opt)
-{
- bool res = false;
- int fd;
- off_t len;
-
- assert(opt->fstab!=0);
- fd = open(opt->fstab, O_RDONLY);
- if (fd==-1) {
- perror("secure-mount: open(<fstab>)");
- goto err0;
- }
-
- len = lseek(fd, 0, SEEK_END);
- if (len==-1 ||
- lseek(fd, 0, SEEK_SET)==-1) {
- perror("secure-mount: lseek(<fstab>)");
- goto err1;
- }
-
- {
- char buf[len+2];
- char *ptr, *ptrptr;
- size_t line_nr=0, col_nr;
-
- if (read(fd, buf, len+1)!=len) {
- perror("secure-mount: read()");
- goto err1;
- }
- buf[len] = '#'; // workaround for broken dietlibc strtok_r()
- // implementation
- buf[len+1] = '\0';
- ptrptr = buf;
-
- while ((ptr=strsep(&ptrptr, "\n")) != 0) {
- struct MountInfo mnt;
- ++line_nr;
-
- switch (parseFstabLine(&mnt, ptr, &col_nr)) {
- case prFAIL :
- showFstabPosition(2, opt->fstab, line_nr, col_nr);
- WRITE_MSG(2, ": syntax error\n");
- goto err1;
-
- case prIGNORE : break;
- case prDOIT : {
- bool is_rootfs = (strcmp(mnt.dst, "/")==0);
- Echdir("/");
- if (( is_rootfs && opt->rootfs==rfsNO) ||
- (!is_rootfs && opt->rootfs==rfsONLY)) { /* ignore the entry */ }
- else if (!mountSingle(&mnt, opt)) {
- showFstabPosition(2, opt->fstab, line_nr, 1);
- WRITE_MSG(2, ": failed to mount fstab-entry\n");
- }
- break;
- }
- default :
- assert(false);
- }
- }
- }
-
- res = true;
-
- err1: close(fd);
- err0: return res;
-}
-
-static void
-initFDs(struct Options *opt)
-{
- opt->cur_dir_fd = Eopen(".", O_RDONLY|O_DIRECTORY, 0);
- opt->cur_rootdir_fd = Eopen("/", O_RDONLY|O_DIRECTORY, 0);
-
- Efcntl(opt->cur_dir_fd, F_SETFD, FD_CLOEXEC);
- Efcntl(opt->cur_rootdir_fd, F_SETFD, FD_CLOEXEC);
-}
-
-static RootFsOption
-parseRootFS(char const *str)
-{
- if (strcasecmp(str, "yes")==0) return rfsYES;
- else if (strcasecmp(str, "no")==0) return rfsNO;
- else if (strcasecmp(str, "only")==0) return rfsONLY;
- else {
- WRITE_MSG(2, "secure-mount: invalid option for '--rootfs': '");
- WRITE_STR(2, str);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
-}
-
-int main(int argc, char *argv[])
-{
- struct MountInfo mnt = {
- .src = 0,
- .dst = 0,
- .type = 0,
- .flag = 0,
- .xflag = 0,
- .data = 0,
- };
-
- struct Options opt = {
- .mtab = "/etc/mtab",
- .fstab = "/etc/fstab",
- .do_chroot = 0,
- .ignore_mtab = false,
- .mount_all = false,
- .cur_dir_fd = -1,
- .cur_rootdir_fd = -1,
- .rootfs = rfsYES
- };
-
- while (1) {
- int c = getopt_long(argc, argv, "ht:nao:", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case 'h' : showHelp(1, argv[0], 0);
- case 'v' : showVersion();
- case 't' : mnt.type = optarg; break;
- case 'n' : opt.ignore_mtab = true; break;
- case 'a' : opt.mount_all = true; break;
- case 'o' : mnt.data = optarg; break;
- case OPTION_RBIND : mnt.flag |= MS_REC; /*@fallthrough@*/
- case OPTION_BIND : mnt.flag |= MS_BIND; break;
- case OPTION_MOVE : mnt.flag |= MS_MOVE; break;
- case OPTION_MTAB : opt.mtab = optarg; break;
- case OPTION_FSTAB : opt.fstab = optarg; break;
- case OPTION_CHROOT: opt.do_chroot = true; break;
- case OPTION_ROOTFS: opt.rootfs = parseRootFS(optarg); break;
- case OPTION_SECURE:
- WRITE_MSG(2, "secure-mount: The '--secure' option is deprecated...\n");
- break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
-
- if (opt.mount_all && optind<argc) {
- WRITE_MSG(2, "Can not specify <src> and '-a' at the same time\n");
- return EXIT_FAILURE;
- }
-
- initFDs(&opt);
- signal(SIGCHLD, SIG_DFL);
-
- if (opt.mount_all) {
- if (!mountFstab(&opt)) return EXIT_FAILURE;
- else return EXIT_SUCCESS;
- }
-
- if (optind+2!=argc) {
- WRITE_MSG(2, "Invalid <src> <dst> pair specified\n");
- return EXIT_FAILURE;
- }
-
- if (mnt.data) {
- mnt.data = strdup(mnt.data);
- if (!transformOptionList(&mnt, 0)) {
- WRITE_MSG(2, "Invalid options specified\n");
- return EXIT_FAILURE;
- }
- }
-
- mnt.src = argv[optind++];
- mnt.dst = argv[optind++];
-
- if (!mountSingle(&mnt, &opt)) return EXIT_FAILURE;
-
- return EXIT_SUCCESS;
-}
+++ /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 "pathconfig.h"
-
-#include "wrappers.h"
-#include "util.h"
-
-int wrapper_exit_code = 1;
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- "[--help] [--version] <dir>\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "secure-umount " VERSION " -- secure umounting of directories\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int main(int argc, char *argv[])
-{
- char const * dir;
- int root_fd;
- int this_fd;
- char * umount_cmd[] = { UMOUNT_PROG, "-l", "-n", ".", 0 };
-
- if (argc<2) {
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- }
-
- if (strcmp(argv[1], "--help")==0) showHelp(1, argv[0], 0);
- if (strcmp(argv[1], "--version")==0) showVersion();
-
- dir = argv[1];
- if (strcmp(dir, "--")==0 && argc>=3) dir = argv[2];
-
- root_fd = Eopen("/", O_RDONLY, 0);
- Echroot(".");
- Echdir(dir);
- this_fd = Eopen(".", O_RDONLY, 0);
- Efchdir(root_fd);
- Echroot(".");
- Efchdir(this_fd);
-
- Eclose(root_fd);
- Eclose(this_fd);
-
- Eexecv(umount_cmd[0], umount_cmd);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "fstool.h"
-#include "util.h"
-
-#include <lib/fmt.h>
-#include <lib/vserver.h>
-#include <lib/vserver-internal.h>
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "immu", no_argument, 0, CMD_IMMU },
- { "iunlink", no_argument, 0, CMD_IMMU },
- { "admin", no_argument, 0, CMD_ADMIN },
- { "watch", no_argument, 0, CMD_WATCH },
- { "hide", no_argument, 0, CMD_HIDE },
- { "barrier", no_argument, 0, CMD_BARRIER },
- { "~iunlink", no_argument, 0, CMD_UNSET_IMMU },
- { "!iunlink", no_argument, 0, CMD_UNSET_IMMU },
- { "~immu", no_argument, 0, CMD_UNSET_IMMU },
- { "!immu", no_argument, 0, CMD_UNSET_IMMU },
- { "~admin", no_argument, 0, CMD_UNSET_ADMIN },
- { "!admin", no_argument, 0, CMD_UNSET_ADMIN },
- { "~watch", no_argument, 0, CMD_UNSET_WATCH },
- { "!watch", no_argument, 0, CMD_UNSET_WATCH },
- { "~hide", no_argument, 0, CMD_UNSET_HIDE },
- { "!hide", no_argument, 0, CMD_UNSET_HIDE },
- { "~barrier", no_argument, 0, CMD_UNSET_BARRIER },
- { "!barrier", no_argument, 0, CMD_UNSET_BARRIER },
- { "iunlink-but-not-immutable", no_argument, 0, CMD_IMMUX },
- { "~iunlink-but-not-immutable", no_argument, 0, CMD_UNSET_IMMUX },
- { "!iunlink-but-not-immutable", no_argument, 0, CMD_UNSET_IMMUX },
- { 0,0,0,0 }
-};
-
-char const CMDLINE_OPTIONS_SHORT[] = "Rx";
-
-void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [-Rx] [--[~](iunlink|admin|watch|hide|barrier|iunlink-but-not-immutable)]* [--] <file>+\n\n"
- " Options:\n"
- " -R ... recurse through directories\n"
- " -x ... do not cross filesystems\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-void
-showVersion()
-{
- WRITE_MSG(1,
- "setattr " VERSION " -- sets vserver specific file attributes\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-void
-fixupParams(struct Arguments * args, int argc)
-{
- if (optind==argc) {
- WRITE_MSG(2, "No filename given; use '--help' for more information\n");
- exit(1);
- }
-
- args->do_display_dir = !args->do_recurse;
- args->do_display_dot = true;
-}
-
-bool
-handleFile(char const *name, char const * display_name)
-{
- int rc = vc_set_iattr(name,
- 0,
- global_args->set_mask & ~global_args->del_mask,
- global_args->set_mask | global_args->del_mask);
-
- if (rc==-1) {
- perror(display_name);
- return false;
- }
-
- return true;
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on showattr.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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 "fstool.h"
-#include "util.h"
-
-#include <lib/fmt.h>
-#include <lib/vserver.h>
-#include <lib/vserver-internal.h>
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <ctype.h>
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
-#ifdef VC_ENABLE_API_LEGACY
- { "legacy", no_argument, 0, CMD_LEGACY },
-#endif
- { 0,0,0,0 }
-};
-
-char const CMDLINE_OPTIONS_SHORT[] = "Radx";
-
-void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [-Radx] [--] <file>*\n\n"
- " Options:\n"
- " -R ... recurse through directories\n"
- " -a ... display files starting with '.' also\n"
- " -d ... list directories like other files instead of listing\n"
- " their content\n"
- " -x ... do not cross filesystems\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-void
-showVersion()
-{
- WRITE_MSG(1,
- "showattr " VERSION " -- shows vserver specific file attributes\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-void
-fixupParams(struct Arguments UNUSED * args, int UNUSED argc)
-{
-}
-
-static bool
-getFlags(char const *name, uint32_t *flags, uint32_t *mask)
-{
- xid_t xid;
- *mask = ~0;
-
- if (vc_get_iattr(name, &xid, flags, mask)==-1) {
- perror("vc_get_iattr()");
- return false;
- }
-
- return true;
-}
-
-bool
-handleFile(char const *name, char const *display_name)
-{
- bool res = true;
- char buf[40];
- char *ptr = buf;
- uint32_t flags;
- uint32_t mask;
-
- memset(buf, ' ', sizeof buf);
-
- if (getFlags(name, &flags, &mask)) {
- // 1 1 0 0
- // fedcba9876543210fedcba9876543210
- static char const MARKER[33] = ".......x.....iub.............hwa";
- int i;
- uint32_t used_flags = (VC_IATTR_XID|VC_IATTR_ADMIN|
- VC_IATTR_WATCH|VC_IATTR_HIDE|
- VC_IATTR_BARRIER|VC_IATTR_IUNLINK|
- VC_IATTR_IMMUTABLE);
-
- for (i=0; i<32; ++i) {
- if (used_flags & 1) {
- if (! (mask & 1) ) *ptr++ = '-';
- else if (flags & 1) *ptr++ = toupper(MARKER[31-i]);
- else *ptr++ = MARKER[31-i];
- }
-
- used_flags >>= 1;
- flags >>= 1;
- mask >>= 1;
- }
- }
- else {
- memcpy(buf, "ERR ", 7);
- res = false;
- }
-
- Vwrite(1, buf, 8);
- Vwrite(1, display_name, strlen(display_name));
- Vwrite(1, "\n", 1);
-
- return res;
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on showperm.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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 <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-int main (int argc, char *argv[])
-{
- int ret = -1;
- if (argc < 2){
- fprintf (stderr,"showperm version %s\n",VERSION);
- fprintf (stderr,
- "showperm file or directory ...\n"
- "prints permission bits for files\n"
- "A very stripped down stat utility\n"
- );
- }else{
- int i;
- ret = 0;
- for (i=1; i<argc; i++){
- struct stat st;
- if (lstat(argv[i],&st)==-1){
- fprintf (stderr,"can't lstat %s (%s)\n",argv[i]
- ,strerror(errno));
- ret = -1;
- }else{
- printf ("%03o\n",(st.st_mode & 0777));
- }
- }
- }
- return ret;
-}
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-#include <signal.h>
-#include <unistd.h>
-#include <errno.h>
-
-#define ENSC_WRAPPERS_PREFIX "sigexec: "
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 255;
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--] <cmd> <args>*\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "sigexec " VERSION " -- executes commands with defined sigmasks\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-
-int main(int argc, char *argv[])
-{
- int idx = 1;
-
- if (argc>=2) {
- if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0], 0);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (strcmp(argv[1], "--") ==0) ++idx;
- }
-
- if (argc<idx+1) {
- WRITE_MSG(2, "Not enough parameters; use '--help' for more information\n");
- return wrapper_exit_code;
- }
-
- signal(SIGCHLD, SIG_DFL);
-
- Eexecv(argv[idx], argv+idx);
-}
+++ /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_SRC_STACK_START_H
-#define H_UTIL_VSERVER_SRC_STACK_START_H
-
-#ifdef HAVE_GROWING_STACK
-# define STACK_START(PTR) (PTR)
-#else
-# define STACK_START(PTR) ((PTR)+sizeof(PTR)/sizeof(PTR[0])-1)
-#endif
-
-#endif // H_UTIL_VSERVER_SRC_STACK_START_H
+++ /dev/null
-.deps
-.dirstamp
-.libs
-chbind-test
-chcontext-test
-rpm-fake-test
-vunify-functest
+++ /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/chcontext-test \
- src/testsuite/chbind-test
-src_testsuite_check_passive_PRGS = src/testsuite/rpm-fake-test
-
-
-check_PROGRAMS += $(src_testsuite_check_passive_PRGS) \
- $(src_testsuite_check_active_PRGS)
-
-if ENSC_HAVE_C99_COMPILER
-src_testsuite_check_src_C99_SCRPTS = src/testsuite/vunify-test.sh
-else
-src_testsuite_check_src_C99_SCRPTS =
-endif
-
-src_testsuite_check_src_SCRPTS = $(src_testsuite_check_src_C99_SCRPTS)
-src_testsuite_check_gen_SCRPTS =
-
-check_SCRIPTS += $(src_testsuite_check_src_SCRPTS) \
- $(src_testsuite_check_gen_SCRPTS)
-
-TESTS += $(src_testsuite_check_active_PRGS) \
- $(src_testsuite_check_src_SCRPTS) \
- $(src_testsuite_check_gen_SCRPTS)
-
-EXTRA_DIST += $(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_testsuite_vunify_functest_LDADD = $(LIBINTERNAL)
-src_testsuite_vunify_functest_CPPFLAGS= $(AM_CPPFLAGS) $(src_testsuite_CPPFLAGS)
-
-
-src_testsuite_chcontext_test_SOURCES = src/testsuite/chcontext-test.c
-src_testsuite_chcontext_test_LDADD = lib/libvserver.la $(LIBINTERNAL)
-
-
-src_testsuite_chbind_test_SOURCES = src/testsuite/chbind-test.c
-src_testsuite_chbind_test_LDADD = lib/libvserver.la
-
-
-src_testsuite_CPPFLAGS = -I $(top_srcdir)/src -D ENSC_TESTSUITE
-
-
-clean-local: clean-testsuite
-
-clean-testsuite:
- rm -rf src/testsuite/.libs src/testsuite/_libs
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-#define ENSC_TESTSUITE 1
-#define main fake_main
-#include "src/chbind.c"
-#undef main
-
-int main()
-{
- if (0) fake_main(0,0);
- test();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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
-
-#define ENSC_TESTSUITE 1
-#define main fake_main
-#include "src/chcontext.c"
-#undef main
-
-int main()
-{
- if (0) fake_main(0,0);
- test();
-
- return EXIT_SUCCESS;
-}
+++ /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 <grp.h>
-#include <pwd.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.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 * 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=./src/.libs/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 "lib_internal/matchlist.h"
-
-int wrapper_exit_code = 1;
-extern void PathInfo_test();
-
-int main()
-{
- PathInfo_test();
- return 0;
-}
+++ /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 ./src/vunify -n --manually $tmpdir/a '' $tmpdir/b '' >/dev/null
-$D ./src/vunify -n --manually $tmpdir/a '' $tmpdir/c '' >/dev/null
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_UTILVSERVER_SRC_UTIL_H
-#define H_UTILVSERVER_SRC_UTIL_H
-
-#include <lib_internal/util.h>
-
-#endif // H_UTILVSERVER_SRC_UTIL_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-#include <lib/vserver.h>
-
-#include <getopt.h>
-#include <stdint.h>
-#include <errno.h>
-
-#define ENSC_WRAPPERS_PREFIX "vattribute: "
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-#define CMD_XID 0x2000
-#define CMD_SET 0x2001
-#define CMD_CCAP 0x2002
-#define CMD_FLAG 0x2003
-#define CMD_SECURE 0x2004
-#define CMD_BCAP 0x2005
-
-int wrapper_exit_code = 1;
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "xid", required_argument, 0, CMD_XID },
- { "set", no_argument, 0, CMD_SET },
- { "ccap", required_argument, 0, CMD_CCAP },
- { "bcap", required_argument, 0, CMD_BCAP },
- { "flag", required_argument, 0, CMD_FLAG },
- { "secure", no_argument, 0, CMD_SECURE },
- {0,0,0,0}
-};
-
-struct Arguments {
- xid_t xid;
- struct vc_ctx_flags flags;
- struct vc_ctx_caps caps;
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage:\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " --set [--xid <xid>] [--bcap [~!]<cap>] [--ccap [~!]<cap>] [--flag [~!]<flag>] [--secure] -- [<program> <args>*]\n"
- "\n"
- " --bcap <cap> ... system capability to be added\n"
- " --cap <cap> ... context capability to be added\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vattribute " VERSION " -- sets attributes of vservers\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-parseFlags(char const *str, struct vc_ctx_flags *flags)
-{
- struct vc_err_listparser err;
- int rc;
-
- rc = vc_list2cflag(str,0, &err, flags);
-
- if (rc==-1) {
- WRITE_MSG(2, "Unknown flag '");
- Vwrite(2, err.ptr, err.len);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
-}
-
-static void
-parseBCaps(char const *str, struct vc_ctx_caps *caps)
-{
- struct vc_err_listparser err;
- int rc;
-
- rc = vc_list2bcap(str,0, &err, caps);
-
- if (rc==-1) {
- WRITE_MSG(2, "Unknown bcap '");
- Vwrite(2, err.ptr, err.len);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
-}
-
-static void
-parseCCaps(char const *str, struct vc_ctx_caps *caps)
-{
- struct vc_err_listparser err;
- int rc;
-
- rc = vc_list2ccap(str,0, &err, caps);
-
- if (rc==-1) {
- WRITE_MSG(2, "Unknown ccap '");
- Vwrite(2, err.ptr, err.len);
- WRITE_MSG(2, "'\n");
- exit(wrapper_exit_code);
- }
-}
-
-static void
-parseSecure(struct vc_ctx_flags UNUSED * flags,
- struct vc_ctx_caps UNUSED * caps)
-{
- caps->ccaps = ~vc_get_insecureccaps();
- caps->cmask = ~0ull;
- caps->bcaps = ~vc_get_insecurebcaps();
- caps->bmask = ~0ull;
-
- // TODO: generalize this
- flags->flagword = VC_VXF_HIDE_NETIF;
- flags->mask = VC_VXF_HIDE_NETIF;
-}
-
-int main(int argc, char *argv[])
-{
- struct Arguments args = {
- .xid = VC_NOCTX,
- .flags = { .flagword = 0, .mask = 0 },
- .caps = { .bcaps = 0, .bmask = 0,.ccaps = 0, .cmask = 0 },
- };
-
- while (1) {
- int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_SET : break; // default op currently
- case CMD_XID : args.xid = Evc_xidopt2xid(optarg,true); break;
- case CMD_FLAG : parseFlags(optarg, &args.flags); break;
- case CMD_CCAP : parseCCaps(optarg, &args.caps); break;
- case CMD_BCAP : parseBCaps(optarg, &args.caps); break;
- case CMD_SECURE : parseSecure(&args.flags, &args.caps); break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return 255;
- break;
- }
- }
-
- if (args.xid==VC_NOCTX) args.xid = Evc_get_task_xid(0);
-
- if ((args.caps.cmask || args.caps.bmask) &&
- vc_set_ccaps(args.xid, &args.caps)==-1)
- perror(ENSC_WRAPPERS_PREFIX "vc_set_ccaps()");
- else if (args.flags.mask &&
- vc_set_cflags(args.xid, &args.flags)==-1)
- perror(ENSC_WRAPPERS_PREFIX "vc_set_flags()");
- else if (optind<argc)
- EexecvpD(argv[optind], argv+optind);
- else
- return EXIT_SUCCESS;
-
- return EXIT_FAILURE;
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on vbuild.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- This utility is used to build a new vserver using a reference vserver.
- It uses hard link whenever possible instead of duplicating files.
- Once done, it sets the immutable bits.
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <dirent.h>
-
-#include <string>
-#include <vector>
-#include <list>
-#include <set>
-#include <cassert>
-
-#include "vutil.h"
-
-using namespace std;
-
-struct EXCLDIR{
- string prefix;
- int len;
- EXCLDIR(const char *s)
- {
- prefix = s;
- prefix += '/';
- len = prefix.size();
- }
-};
-static vector<EXCLDIR> excldirs;
-
-
-static int ext2flags = EXT2_IMMUTABLE_FILE_FL | EXT2_IMMUTABLE_LINK_FL;
-static struct {
- int nblink;
- int nbcopy;
- long size_copy;
- int nbdir;
- int nbsymlink;
- int nbspc;
-} stats;
-
-
-static void usage()
-{
- cerr <<
- "vbuild version " << VERSION <<
- "\n\n"
- "vbuild [ options ] reference-server new-vservers\n"
- "\n"
- "--test: Show what will be done, do not do it.\n"
- "--debug: Prints some debugging messages.\n"
- "\n"
- "--excldir: None of the files under a given directory will be copied\n"
- "\tThe directory is expressed in absolute/logical form (relative\n"
- "\tto the vserver root (ex: /var/log)\n"
- "\n"
- "\n"
- "--noflags: Do not put any immutable flags on the file\n"
- "--immutable: Set the immutable_file bit on the files.\n"
- "--immutable-mayunlink: Sets the immutable_link flag on files.\n"
- "--stats: Produce statistics on the number of file linked\n"
- " copied and so on.\n"
- "\n"
- "By default, the immutable_file and immutable_link flags are\n"
- "set on the files. So if you want no immutable flags, you must\n"
- "use --noflags. If you want a single flag, you must use\n"
- "--noflags first, then the --immutable or --immutable-mayunlink\n"
- "flag.\n"
- ;
-}
-
-/*
- Return true if a directory lies inside a directory set
-*/
-static bool vbuild_inside (vector<EXCLDIR> &dirs, const char *path)
-{
- bool found = false;
- for (unsigned i=0; i<dirs.size(); i++){
- if (strncmp(dirs[i].prefix.c_str(),path,dirs[i].len)==0){
- found = true;
- break;
- }
- }
- return found;
-}
-
-
-
-static int vbuild_copy (
- string refserv,
- string newserv,
- dev_t dev, // We stay on the same volume
- string logical_dir,
- set<string> &files)
-{
- int ret = -1;
- if (debug > 0) printf ("Copying directory %s\n",logical_dir.c_str());
- DIR *dir = opendir (refserv.c_str());
- if (dir == NULL){
- fprintf (stderr,"Can't open directory %s (%s)\n",refserv.c_str()
- ,strerror(errno));
- }else{
- logical_dir += "/";
- bool copy_files = !vbuild_inside(excldirs,logical_dir.c_str());
- struct dirent *ent;
- ret = 0;
- while (ret == 0 && (ent=readdir(dir))!=NULL){
- if (strcmp(ent->d_name,".")==0 || strcmp(ent->d_name,"..")==0){
- continue;
- }
- string file = refserv + "/" + ent->d_name;
- struct stat st;
- if (vutil_lstat(file.c_str(),st) == -1){
- ret = -1;
- }else if (st.st_dev != dev){
- if (debug > 0) printf ("Ignore sub-directory %s\n",file.c_str());
- }else{
- string newfile = newserv + "/" + ent->d_name;
- if (S_ISDIR(st.st_mode)){
- if (vbuild_mkdir (newfile.c_str(),st.st_mode)==-1){
- fprintf (stderr,"Can't mkdir %s (%s)\n"
- ,newfile.c_str(),strerror(errno));
- ret = -1;
- }else{
- stats.nbdir++;
- if (vbuild_chown(newfile.c_str(),st.st_uid,st.st_gid)==-1){
- fprintf (stderr,"Can't chown %s (%s)\n"
- ,newfile.c_str(),strerror(errno));
- ret = -1;
- }
- ret |= vbuild_copy (file,newfile,dev
- ,logical_dir + ent->d_name,files);
- }
- }else if (S_ISLNK(st.st_mode)){
- char path[PATH_MAX];
- int len = readlink(file.c_str(),path,sizeof(path)-1);
- if (len < 0){
- fprintf (stderr,"Can't readlink %s (%s)\n"
- ,file.c_str(),strerror(errno));
- ret = -1;
- }else{
- path[len] = '\0';
- stats.nbsymlink++;
- if (vbuild_symlink (path,newfile.c_str())==-1){
- fprintf (stderr,"Can't symlink %s to %s (%s)\n",
- newfile.c_str(),path,strerror(errno));
- }
- }
- }else if (S_ISBLK(st.st_mode)
- || S_ISCHR(st.st_mode)
- || S_ISFIFO(st.st_mode)){
- stats.nbspc++;
- if (vbuild_mknod (newfile.c_str(),st.st_mode,st.st_rdev)==-1){
- fprintf (stderr,"Can't mknod %s (%s)\n"
- ,newfile.c_str(),strerror(errno));
- ret = -1;
- }
- }else if (S_ISSOCK(st.st_mode)){
- // Do nothing
- }else if (copy_files){
- // Ok, this is a file. We either copy it or do a link
- string logical_file = logical_dir + ent->d_name;
- if (files.find (logical_file)==files.end()){
- if (debug > 1) printf ("Copying file %s\n",file.c_str());
- if (vbuild_file_copy (file.c_str(),newfile.c_str(),st)==-1){
- fprintf (stderr,"Can't copy %s to %s (%s)\n",
- file.c_str(),newfile.c_str(),strerror(errno));
- ret = -1;
- }else{
- stats.size_copy += st.st_size;
- stats.nbcopy++;
- }
- }else{
- if (debug > 2) printf ("Linking file %s\n",file.c_str());
- setext2flag (file.c_str(),false,ext2flags);
- stats.nblink++;
- if (vbuild_link (file.c_str(),newfile.c_str())==-1){
- fprintf (stderr,"Can't link %s to %s (%s)\n",
- file.c_str(),newfile.c_str(),strerror(errno));
- ret = -1;
- }
- setext2flag (file.c_str(),true,ext2flags);
- }
- }
- }
- }
- closedir(dir);
- }
- return ret;
-}
-
-static void
-prepareVserver(Vserver const UNUSED &src, char const UNUSED *dst)
-{
- assert(false);
-}
-
-int main (int argc, char *argv[])
-{
- int ret = -1;
- bool statistics = false;
- int i;
- for (i=1; i<argc; i++){
- const char *arg = argv[i];
- //const char *opt = argv[i+1];
- if (strcmp(arg,"--test")==0){
- testmode = true;
- }else if (strcmp(arg,"--debug")==0){
- debug++;
- }else if (strcmp(arg,"--stats")==0){
- statistics = true;
- }else if (strcmp(arg,"--noflags")==0){
- ext2flags = 0;
- }else if (strcmp(arg,"--immutable")==0){
- ext2flags |= EXT2_IMMUTABLE_FILE_FL;
- }else if (strcmp(arg,"--immutable-mayunlink")==0){
- ext2flags |= EXT2_IMMUTABLE_LINK_FL;
- }else if (strcmp(arg,"--excldir")==0){
- i++;
- excldirs.push_back (EXCLDIR(argv[i]));
- }else{
- break;
- }
- }
- if (i!=argc-2){
- usage();
- }else{
- Vserver refserv(argv[i++]);
-
- prepareVserver(refserv, argv[i]);
- Vserver newserv(argv[i]);
- list<Package> packages;
- // Load the files which are not configuration files from
- // the packages
- vutil_loadallpkg (refserv,packages);
- set<string> files;
- for (list<Package>::iterator it=packages.begin(); it!=packages.end(); it++){
- (*it).loadfiles(refserv,files);
- }
- // Now, we do a recursive copy of refserv into newserv
- umask (0);
- // Check if it is on the same volume
- struct stat refst,newst;
- if (vutil_lstat(refserv.getVdir().c_str(),refst)!=-1
- && vutil_lstat(newserv.getVdir().c_str(),newst)!=1){
- if (refst.st_dev != newst.st_dev){
- fprintf (stderr,"Can't vbuild %s because it is not on the same volume as %s\n",
- newserv.getVdir().c_str(),refserv.getVdir().c_str());
- }else{
- stats.nbdir = stats.nblink = stats.nbcopy = stats.nbsymlink = 0;
- stats.nbspc = 0;
- stats.size_copy = 0;
- ret = vbuild_copy (refserv.getVdir(),newserv.getVdir(),refst.st_dev,"",files);
- if (statistics){
- printf ("Directory created: %d\n",stats.nbdir);
- printf ("Files copied : %d\n",stats.nbcopy);
- printf ("Bytes copied : %ld\n",stats.size_copy);
- printf ("Files linked : %d\n",stats.nblink);
- printf ("Files symlinked : %d\n",stats.nbsymlink);
- printf ("Special files : %d\n",stats.nbspc);
- }
- }
- }
- }
- return ret;
-}
-
-
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on vcheck.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- This utility is used to compare two vservers. One is known to
- be clean and the other is potentially corrupted (cracked). The
- goal of this program is to run the rpm verify command, but using
- the RPM database of the first vserver.
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <dirent.h>
-
-#include <string>
-#include <vector>
-#include <list>
-#include <set>
-#include "vutil.h"
-
-using namespace std;
-
-
-static void usage()
-{
- cerr <<
- "vcheck version " << VERSION <<
- "\n\n"
- "vcheck [ options ] reference-server chk-vservers\n"
- "\n"
- "--diffpkgs: Shows which package differ.\n"
- " + means the package only exists in chk-server.\n"
- " - means the package does not exist in chk-server.\n"
- " ! means the servers have different version.\n"
- "\n"
- "--verify: Execute an RPM verify on common packages.\n"
- "--debug: Turn on some (useless) debugging messages.\n"
- ;
-}
-
-typedef list<Package> PACKAGES;
-
-/*
- Delete a directory silently
-*/
-static int vcheck_deldir (const string &path)
-{
- int ret = -1;
- struct stat st;
- if (lstat(path.c_str(),&st)==-1){
- ret = 0;
- }else{
- if (!S_ISDIR(st.st_mode)){
- fprintf (stderr,"%s already exist and is not a directory\n"
- ,path.c_str());
- exit (-1);
- }else{
- DIR *d = opendir (path.c_str());
- if (d != NULL){
- struct dirent *ent;
- ret = 0;
- while ((ent=readdir(d))!=NULL){
- if (strcmp(ent->d_name,".")!=0
- && strcmp(ent->d_name,"..")!=0){
- string tmp = path + "/" + ent->d_name;
- if (unlink(tmp.c_str())==-1){
- fprintf (stderr,"Can't delete file %s (%s)\n",tmp.c_str()
- ,strerror(errno));
- ret = -1;
- break;
- }
- }
- }
- closedir (d);
- rmdir (path.c_str());
- }
- }
- }
- return ret;
-}
-
-
-static int vcheck_copydb (const string &refserv, const string &path)
-{
- int ret = -1;
- string refpath = refserv + "/var/lib/rpm";
- DIR *d = opendir (refpath.c_str());
- if (d == NULL){
- fprintf (stderr,"Can't open directory %s (%s)\n",refpath.c_str()
- ,strerror(errno));
- }else{
- ret = 0;
- struct dirent *ent;
- while ((ent=readdir(d))!=NULL){
- if (strcmp(ent->d_name,".")!=0
- && strcmp(ent->d_name,"..")!=0){
- string srcpath = refpath + "/" + ent->d_name;
- const char *spath = srcpath.c_str();
- struct stat st;
- if (stat(spath,&st)!=-1){
- string dstpath = path + "/" + ent->d_name;
- if (file_copy (spath,dstpath.c_str(),st) == -1){
- ret = -1;
- break;
- }
- }else{
- ret = -1;
- fprintf (stderr,"Can't stat %s (%s)\n",spath,strerror(errno));
- break;
- }
- }
- }
- closedir (d);
- }
- return ret;
-}
-
-class cmp_name{
-public:
- int operator()(const Package &p1, const Package &p2){
- return strcmp(p1.name.c_str(),p2.name.c_str());
- }
-};
-
-
-int main (int argc, char *argv[])
-{
- int ret = -1;
- bool diffpkg = false;
- bool verify = false;
- int i;
- for (i=1; i<argc; i++){
- const char *arg = argv[i];
- //const char *opt = argv[i+1];
- if (strcmp(arg,"--diffpkg")==0){
- diffpkg = true;
- }else if (strcmp(arg,"--verify")==0){
- verify = true;
- }else if (strcmp(arg,"--debug")==0){
- debug++;
- }else{
- break;
- }
- }
- if (i!=argc-2){
- usage();
- }else{
- string refserv = argv[i++];
- string chkserv = argv[i];
- PACKAGES refpkgs,chkpkgs;
- // Load the package list from both vservers
- vutil_loadallpkg (refserv,refpkgs);
- vutil_loadallpkg (chkserv,chkpkgs);
- PACKAGES common, differ, added, removed;
- // Find which package are different, missing and added
- // to chkserv
- for (PACKAGES::iterator it=refpkgs.begin(); it!=refpkgs.end(); it++){
- PACKAGES::iterator f = find_if(chkpkgs.begin(),chkpkgs.end(),same_name(*it));
- if (f == chkpkgs.end()){
- removed.push_back (*it);
- }else if (f->version != it->version){
- differ.push_back (*it);
- }else{
- common.push_back (*it);
- }
- }
- for (list<Package>::iterator it=chkpkgs.begin(); it!=chkpkgs.end(); it++){
- list<Package>::iterator f = find_if(refpkgs.begin(),refpkgs.end(),same_name(*it));
- if (f == refpkgs.end()){
- added.push_back (*it);
- }
- }
- differ.sort ();
- added.sort();
- removed.sort();
- common.sort ();
- bool something = false;
- if (diffpkg){
- for (PACKAGES::iterator it=removed.begin(); it!=removed.end(); it++){
- printf ("- %s\n",it->name.c_str());
- }
- for (PACKAGES::iterator it=added.begin(); it!=added.end(); it++){
- printf ("+ %s\n",it->name.c_str());
- }
- for (PACKAGES::iterator it=differ.begin(); it!=differ.end(); it++){
- printf ("! %s\n",it->name.c_str());
- }
- something = true;
- }
- if (verify){
- // We copy the rpm database from the reference vserver to
- // the target vserver
- string dbpath = chkserv + "/tmp/vcheck.db";
- vcheck_deldir (dbpath);
- if (mkdir (dbpath.c_str(),0)==-1){
- fprintf (stderr,"Can't create directory %s (%s)\n"
- ,dbpath.c_str(),strerror(errno));
- }else if (vcheck_copydb (refserv,dbpath) != -1){
- // We only compare the common package
- string cmd = "rpm --dbpath /tmp/vcheck.db --root " + chkserv + " -V";
- for (PACKAGES::iterator it=common.begin(); it!=common.end(); it++){
- //printf ("compare %s\n",it->name.c_str());
- cmd += " " + it->name;
- }
- if (debug) printf ("CMD: %s\n",cmd.c_str());
- system (cmd.c_str());
- }
- vcheck_deldir (dbpath);
- something = true;
- }
- if (!something){
- fprintf (stderr,"Nothing to do !!!\n\n");
- usage();
- }
- }
- return ret;
-}
-
-
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-#include "lib/internal.h"
-#include "lib_internal/jail.h"
-
-#include <vserver.h>
-#include <getopt.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <assert.h>
-#include <signal.h>
-
-#define ENSC_WRAPPERS_PREFIX "vcontext: "
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_SOCKET 1
-#define ENSC_WRAPPERS_IOSOCK 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-#define CMD_XID 0x4000
-#define CMD_CREATE 0x4001
-#define CMD_MIGRATE 0x4003
-#define CMD_INITPID 0x4002
-#define CMD_DISCONNECT 0x4004
-#define CMD_UID 0x4005
-#define CMD_CHROOT 0x4006
-#define CMD_SILENT 0x4007
-#define CMD_SYNCSOCK 0x4008
-#define CMD_SYNCMSG 0x4009
-#define CMD_MIGRATESELF 0x400a
-#define CMD_ENDSETUP 0x400b
-#define CMD_SILENTEXIST 0x400c
-#define CMD_NAMESPACE 0x400d
-
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "ctx", required_argument, 0, CMD_XID },
- { "xid", required_argument, 0, CMD_XID },
- { "create", no_argument, 0, CMD_CREATE },
- { "migrate", no_argument, 0, CMD_MIGRATE },
- { "migrate-self", no_argument, 0, CMD_MIGRATESELF },
- { "initpid", no_argument, 0, CMD_INITPID },
- { "endsetup", no_argument, 0, CMD_ENDSETUP },
- { "disconnect", no_argument, 0, CMD_DISCONNECT },
- { "silent", no_argument, 0, CMD_SILENT },
- { "silentexist", no_argument, 0, CMD_SILENTEXIST },
- { "uid", required_argument, 0, CMD_UID },
- { "chroot", no_argument, 0, CMD_CHROOT },
- { "namespace", no_argument, 0, CMD_NAMESPACE },
- { "syncsock", required_argument, 0, CMD_SYNCSOCK },
- { "syncmsg", required_argument, 0, CMD_SYNCMSG },
-#if 1
- { "fakeinit", no_argument, 0, CMD_INITPID }, // compatibility
-#endif
- { 0,0,0,0 },
-};
-
-struct Arguments {
- bool do_create;
- bool do_migrate;
- bool do_migrateself;
- bool do_disconnect;
- bool do_endsetup;
- bool is_initpid;
- bool is_silentexist;
- bool set_namespace;
- int verbosity;
- bool do_chroot;
- uid_t uid;
- xid_t xid;
- char const * sync_sock;
- char const * sync_msg;
-};
-
-int wrapper_exit_code = 255;
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage:\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " --create [--xid <xid>] <opts>* [--] <program> <args>*\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [(--migrate --xid <xid>)|--migrate-self] <opts>* [--] <program> <args>*\n"
- "\n"
- "<opts> can be:\n"
- " --chroot ... chroot into current directory\n"
- " --namespace ... execute namespace management operations\n"
- " --uid <uid> ... change uid\n"
- " --initpid ... set current process as general process reaper\n"
- " for ctx (possible for --migrate only)\n"
- " --endsetup ... clear the setup flag; usefully for migrate only\n"
- " --disconnect ... start program in background\n"
- " --silent ... be silent\n"
- " --silentexist ... be silent when context exists already; usefully\n"
- " for '--create' only\n"
- " --syncsock <file-name>\n"
- " ... before executing the program, send a message\n"
- " to the socket and wait until it closes.\n"
- " <file-name> must be a SOCK_STREAM unix socket\n"
- " --syncmsg <message>\n"
- " ... use <message> as synchronization message; by\n"
- " default, 'ok' will be used\n"
- "\n"
- "'vcontext --create' exits with code 254 iff the context exists already.\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vcontext " VERSION " -- manages the creation of security contexts\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-#include "context-sync.hc"
-
-static inline ALWAYSINLINE void
-tellContext(xid_t ctx, bool do_it)
-{
- char buf[sizeof(xid_t)*3+2];
- size_t l;
-
- if (!do_it) return;
-
- l = utilvserver_fmt_long(buf,ctx);
-
- WRITE_MSG(1, "New security context is ");
- Vwrite (1, buf, l);
- WRITE_MSG(1, "\n");
-}
-
-static int
-connectExternalSync(char const *filename)
-{
- int fd;
- struct sockaddr_un addr;
-
- if (filename==0) return -1;
-
- ENSC_INIT_UNIX_SOCK(addr, filename);
-
- fd = Esocket(PF_UNIX, SOCK_STREAM, 0);
- Econnect(fd, &addr, sizeof(addr));
-
- return fd;
-}
-
-static void
-setFlags(struct Arguments const *args, xid_t xid)
-{
- struct vc_ctx_flags flags = { 0,0 };
-
- if (args->is_initpid)
- flags.mask |= VC_VXF_STATE_INIT;
-
- if (args->do_endsetup)
- flags.mask |= VC_VXF_STATE_SETUP;
-
- if (flags.mask!=0) {
- DPRINTF("set_flags: mask=%08llx, flag=%08llx\n", flags.mask, flags.flagword);
- Evc_set_cflags(xid, &flags);
- }
-}
-
-static void
-doExternalSync(int fd, char const *msg)
-{
- char c;
-
- if (fd==-1) return;
-
- if (msg) EsendAll(fd, msg, strlen(msg));
- Eshutdown(fd, SHUT_WR);
-
- if (TEMP_FAILURE_RETRY(recv(fd, &c, 1, MSG_NOSIGNAL))!=0) {
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "unexpected external synchronization event\n");
- exit(255);
- }
-
- Eclose(fd);
-}
-
-static inline ALWAYSINLINE int
-doit(struct Arguments const *args, char *argv[])
-{
- int p[2][2];
- pid_t pid = initSync(p, args->do_disconnect);
-
- if (pid==0) {
- xid_t xid;
- int ext_sync_fd = connectExternalSync(args->sync_sock);
-
- doSyncStage0(p, args->do_disconnect);
-
- if (args->do_create) {
- xid = vc_ctx_create(args->xid);
- if (xid==VC_NOCTX) {
- switch (errno) {
- case EEXIST :
- if (!args->is_silentexist)
- perror(ENSC_WRAPPERS_PREFIX "vc_create_context()");
- return 254;
- default :
- perror(ENSC_WRAPPERS_PREFIX "vc_create_context()");
- return wrapper_exit_code;
- }
- }
- tellContext(xid, args->verbosity>=1);
- }
- else
- xid = args->xid;
-
- if (args->do_chroot) {
- Echroot(".");
- if (args->set_namespace) {
- if (args->do_migrateself) Evc_set_namespace();
- else if (args->do_migrate) Evc_enter_namespace(xid);
- }
- }
-
- setFlags(args, xid);
-
- if (args->do_migrate && !args->do_migrateself)
- Evc_ctx_migrate(xid);
-
- if (args->uid!=(uid_t)(-1) && getuid()!=args->uid) {
- Esetuid(args->uid);
- if (getuid()!=args->uid) {
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "Something went wrong while changing the UID\n");
- exit(255);
- }
- }
-
- doExternalSync(ext_sync_fd, args->sync_msg);
- doSyncStage1(p, args->do_disconnect);
- DPRINTF("doit: pid=%u, ppid=%u\n", getpid(), getppid());
- execvp (argv[optind],argv+optind);
- doSyncStage2(p, args->do_disconnect);
-
- PERROR_Q(ENSC_WRAPPERS_PREFIX "execvp", argv[optind]);
- exit(255);
- }
-
- assert(args->do_disconnect);
-
- waitOnSync(pid, p, args->xid!=VC_DYNAMIC_XID && args->do_migrate);
- return EXIT_SUCCESS;
-}
-
-int main (int argc, char *argv[])
-{
- struct Arguments args = {
- .do_create = false,
- .do_migrate = false,
- .do_migrateself = false,
- .do_disconnect = false,
- .do_endsetup = false,
- .is_initpid = false,
- .is_silentexist = false,
- .set_namespace = false,
- .verbosity = 1,
- .uid = -1,
- .xid = VC_DYNAMIC_XID,
- .sync_msg = "ok",
- };
-
- while (1) {
- int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_CREATE : args.do_create = true; break;
- case CMD_MIGRATE : args.do_migrate = true; break;
- case CMD_DISCONNECT : args.do_disconnect = true; break;
- case CMD_ENDSETUP : args.do_endsetup = true; break;
- case CMD_INITPID : args.is_initpid = true; break;
- case CMD_CHROOT : args.do_chroot = true; break;
- case CMD_NAMESPACE : args.set_namespace = true; break;
- case CMD_SILENTEXIST : args.is_silentexist = true; break;
- case CMD_SYNCSOCK : args.sync_sock = optarg; break;
- case CMD_SYNCMSG : args.sync_msg = optarg; break;
- case CMD_UID : args.uid = atol(optarg); break;
- case CMD_XID : args.xid = Evc_xidopt2xid(optarg,true); break;
- case CMD_SILENT : --args.verbosity; break;
- case CMD_MIGRATESELF :
- args.do_migrate = true;
- args.do_migrateself = true;
- break;
-
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return 255;
- break;
- }
- }
-
- signal(SIGCHLD, SIG_DFL);
-
- if (args.do_migrateself)
- args.xid = Evc_get_task_xid(0);
-
- if (!args.do_create && !args.do_migrate)
- WRITE_MSG(2, "Neither '--create' nor '--migrate specified; try '--help' for more information\n");
- else if (args.do_create && args.do_migrate)
- WRITE_MSG(2, "Can not specify '--create' and '--migrate' at the same time; try '--help' for more information\n");
- else if (!args.do_migrate && args.is_initpid)
- WRITE_MSG(2, "'--initpid' is possible in combination with '--migrate' only\n");
- else if (!args.do_create && args.xid==VC_DYNAMIC_XID)
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "Can not migrate to an unknown context\n");
- else if (optind>=argc)
- WRITE_MSG(2, "No command given; use '--help' for more information.\n");
- else
- return doit(&args, argv);
-
- return 255;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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.
-
-
-static void
-createSkeleton(char const *name)
-{
- char const * app_dir;
-
- app_dir = vc_getVserverAppDir(name, vcCFG_AUTO, "vunify");
- if (app_dir==0 &&
- vc_createSkeleton(name, vcCFG_AUTO, vcSKEL_FILESYSTEM|vcSKEL_PKGMGMT)==-1) {
- perror("vc_createSkeleton()");
- exit(1);
- }
-
- if (app_dir==0) {
- app_dir = vc_getVserverAppDir(name, vcCFG_AUTO, "");
-
- PathInfo path = {
- .d = app_dir,
- .l = strlen(app_dir),
- };
- PathInfo rhs_path = {
- .d = "vunify",
- .l = sizeof("vunify")-1
- };
-
- char p_buf[ENSC_PI_APPSZ(path, rhs_path)];
- PathInfo_append(&path, &rhs_path, p_buf);
-
- Emkdir(path.d, 0755);
- }
-
- free(const_cast(char *)(app_dir));
-}
-
-
-static void
-initModeManually(int argc, char *argv[])
-{
- int count=argc/2;
-
- if (count!=2) {
- WRITE_MSG(2, "Bad arguments; try '--help' for more information\n");
- exit(1);
- }
-
- MatchList_initManually(&global_info.dst_list, 0, strdup(argv[0]), argv[1]);
- MatchList_initManually(&global_info.src_list, 0, strdup(argv[2]), argv[3]);
-}
-
-
-static void
-initModeVserver(int argc, char *argv[])
-{
- int count = argc;
- struct MatchVserverInfo src_vserver = {
- .name = argv[1],
- .use_pkgmgmt = true
- };
-
- if (!MatchVserverInfo_init(&src_vserver)) {
- WRITE_MSG(2, "Failed to initialize unification for source-vserver\n");
- exit(1);
- }
-
- if (count!=2) {
- WRITE_MSG(2, "Bad arguments; try '--help' for more information\n");
- exit(1);
- }
-
- if (!MatchList_initByVserver(&global_info.src_list, &src_vserver)) {
- WRITE_MSG(2, "unification not configured for source vserver\n");
- exit(1);
- }
-
- MatchVserverInfo_free(&src_vserver);
-
-
-
- struct MatchVserverInfo dst_vserver = {
- .name = argv[0],
- .use_pkgmgmt = false
- };
-
- if (!global_args->is_strict)
- createSkeleton(dst_vserver.name);
-
- if (!MatchVserverInfo_init(&dst_vserver)) {
- WRITE_MSG(2, "Failed to initialize unification for destination-vserver\n");
- exit(1);
- }
-
- if (!MatchList_initByVserver(&global_info.dst_list, &dst_vserver)) {
- WRITE_MSG(2, "unification not configured for destination vserver\n");
- exit(1);
- }
-
- MatchVserverInfo_free(&dst_vserver);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-#include "vserver.h"
-
-#include "lib_internal/matchlist.h"
-#include "lib_internal/unify.h"
-
-#include <unistd.h>
-#include <getopt.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#include <assert.h>
-#include <utime.h>
-#include <libgen.h>
-#include <sys/param.h>
-
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_DIRENT 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x8000
-#define CMD_VERSION 0x8001
-#define CMD_MANUALLY 0x8002
-#define CMD_STRICT 0x8003
-
-struct WalkdownInfo
-{
- PathInfo state;
- struct MatchList dst_list;
- struct MatchList src_list;
-};
-
-struct Arguments {
- enum {mdMANUALLY, mdVSERVER} mode;
- bool do_dry_run;
- unsigned int verbosity;
- bool local_fs;
- bool is_strict;
-};
-
-static struct WalkdownInfo global_info;
-static struct Arguments const * global_args;
-
-int wrapper_exit_code = 1;
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "manually", no_argument, 0, CMD_MANUALLY },
- { "strict", no_argument, 0, CMD_STRICT },
- { 0,0,0,0 }
-};
-
-typedef enum { opUNIFY, opCOPY, opDIR, opSKIP } Operation;
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- VSERVER_DECLARE_CMD(cmd);
-
- WRITE_MSG(fd, "Usage:\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [-nv] [--strict] <dst-vserver> <src-vserver>\n or\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " --manually [-nvx] [--] <dst-path> <dst-excludelist> <src-path> <src-excludelist>\n\n"
- " --manually ... unify generic paths; excludelists must be generated\n"
- " manually\n"
- " --strict ... require an existing vserver configuration for dst-vserver;\n"
- " by default, a base skeleton will be created but manual\n"
- " configuration wil be still needed to make the new vserver work\n"
- " -n ... do not modify anything; just show what there will be\n"
- " done (in combination with '-v')\n"
- " -v ... verbose mode\n"
- " -x ... do not cross filesystems; this is valid in manual\n"
- " mode only and will be ignored for vserver unification\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vcopy " VERSION " -- copies directories and vserver files\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003,2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int Global_getVerbosity() {
- return global_args->verbosity;
-}
-
-bool Global_doRenew() {
- return true;
-}
-
-#include "vserver-visitdir.hc"
-
-static Operation
-checkDirEntry(PathInfo const *path, struct stat const *st)
-{
- struct WalkdownInfo const * const info = &global_info;
- MatchType res;
-
- // when marked as 'skip' in the first excludelist already, we do not need to
- // visit the second one since it could not change that.
- res=MatchList_compare(&info->dst_list, path->d);
- if (res!=stSKIP) {
- MatchType tmp = MatchList_compare(&info->src_list, path->d);
-
- // stINCLUDE gets overridden by stEXCLUDE+stSKIP, and stEXCLUDE by stSKIP.
- // Using the MAX() macro is a hack but it works
- res=MAX(res,tmp);
- }
-
- // non-skipped directories are marked as opDIR
- if (res!=stSKIP && S_ISDIR(st->st_mode))
- return opDIR;
-
- // non-skipped symlinks will be copied always
- if (res!=stSKIP && S_ISLNK(st->st_mode))
- return opCOPY;
-
- // skipped files or non regular files (character/block devices) will be skipped
- // always
- if (res==stSKIP || !S_ISREG(st->st_mode))
- return opSKIP;
-
- switch (res) {
- case stINCLUDE : return opUNIFY;
- case stEXCLUDE : return opCOPY;
- case stSKIP : assert(false); // already handled above
- default : assert(false); abort();
- }
-}
-
-static bool
-doit(Operation op,
- PathInfo const *dst_path,
- PathInfo const *src_path, struct stat const *exp_stat,
- PathInfo const *show_path)
-{
-#if 0
- struct stat st;
-
- if (lstat(dst_path->d, &st)!=-1) {
- if (global_args->do_keep &&
- (!S_ISDIR(exp_stat->st_mode) || S_ISDIR(st.st_mode))) {
- // when keep-mode is enable and, do nothing
- if (global_args->do_dry_run || global_args->verbosity>1) {
- WRITE_MSG(1, "keeping '");
- write(1, show_path->d, show_path->l);
- WRITE_MSG(1, "'\n");
- }
- return true;
- }
-
- }
-#endif
-
- if (global_args->do_dry_run || global_args->verbosity>1) {
- if (op==opUNIFY) WRITE_MSG(1, "linking '");
- else if (op==opCOPY) WRITE_MSG(1, "copying '");
- else if (op==opDIR) WRITE_MSG(1, "creating '");
- else if (op==opSKIP) WRITE_MSG(1, "skipping '");
- else { assert(false); abort(); }
-
- Vwrite(1, show_path->d, show_path->l);
- WRITE_MSG(1, "'\n");
- }
-
- return (global_args->do_dry_run ||
- ( op==opSKIP) ||
- ( op==opUNIFY && Unify_unify(src_path->d, exp_stat, dst_path->d, false)) ||
- ((op==opCOPY ||
- op==opDIR) && Unify_copy (src_path->d, exp_stat, dst_path->d)));
-}
-
-static uint64_t
-visitDirEntry(struct dirent const *ent)
-{
- char const * dirname = ent->d_name;
- if (isDotfile(dirname)) return 0;
-
- uint64_t res = 1;
- PathInfo src_path = global_info.state;
- PathInfo src_d_path = {
- .d = dirname,
- .l = strlen(dirname)
- };
- char path_buf[ENSC_PI_APPSZ(src_path, src_d_path)];
- struct stat f_stat = { .st_dev = 0 };
-
- PathInfo_append(&src_path, &src_d_path, path_buf);
-
-
- if (lstat(dirname, &f_stat)==-1)
- perror("lstat()");
- else {
- Operation op = checkDirEntry(&src_path, &f_stat);
- PathInfo dst_path = global_info.dst_list.root;
- char dst_path_buf[ENSC_PI_APPSZ(dst_path, src_path)];
-
- PathInfo_append(&dst_path, &src_path, dst_path_buf);
- if (!doit(op, &dst_path, &src_d_path, &f_stat, &src_path))
- perror(src_path.d);
- else if (op==opDIR) {
- res = visitDir(dirname, &f_stat);
- if (!global_args->do_dry_run &&
- !Unify_setTime(dst_path.d, &f_stat))
- perror("utime()");
- }
- else
- res = 0;
- }
-
- return res;
-}
-
-#include "vcopy-init.hc"
-
-int main(int argc, char *argv[])
-{
- struct Arguments args = {
- .mode = mdVSERVER,
- .do_dry_run = false,
- .verbosity = 0,
- .local_fs = false,
- };
- uint64_t res;
-
- global_args = &args;
- while (1) {
- int c = getopt_long(argc, argv, "nvcx",
- CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_MANUALLY : args.mode = mdMANUALLY; break;
- case CMD_STRICT : args.is_strict = true; break;
- case 'n' : args.do_dry_run = true; break;
- case 'x' : args.local_fs = true; break;
- case 'v' : ++args.verbosity; break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- if (argc==optind) {
- WRITE_MSG(2, "No directory/vserver given\n");
- return EXIT_FAILURE;
- }
-
- switch (args.mode) {
- case mdMANUALLY : initModeManually(argc-optind, argv+optind); break;
- case mdVSERVER : initModeVserver (argc-optind, argv+optind); break;
- default : assert(false); return EXIT_FAILURE;
- }
-
- if (global_args->verbosity>3)
- WRITE_MSG(1, "Starting to traverse directories...\n");
-
- Echdir(global_info.src_list.root.d);
- res = visitDir("/", 0);
-
-#ifndef NDEBUG
- {
- MatchList_destroy(&global_info.dst_list);
- MatchList_destroy(&global_info.src_list);
- }
-#endif
-
- return res>0 ? 1 : 0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "util.h"
-#include <lib_internal/sys_clone.h>
-#include <lib/internal.h>
-
-#include <vserver.h>
-
-#include <getopt.h>
-#include <libgen.h>
-#include <errno.h>
-#include <signal.h>
-#include <sched.h>
-
-#define ENSC_WRAPPERS_PREFIX "vdlimit: "
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_VSERVER 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-
-int wrapper_exit_code = 1;
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "xid", required_argument, 0, 'x' },
- { "set", required_argument, 0, 's' },
- { "remove", no_argument, 0, 'd' },
- { "flags", required_argument, 0, 'f' },
- {0,0,0,0}
-};
-
-static void
-showHelp(int fd, char const *cmd)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " --xid <xid> [--flags <flags>] (--set <limit>=<value>|--remove) <mount point>\n"
- "\n"
- " --set|-s <limit>=<value> ... set <limit> to <value>, where limit is \n"
- " one of: space_used, space_total, inodes_used,\n"
- " inodes_total, reserved\n"
- " --remove|-d ... removes the disk limit for <xid> from <mount point>\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(0);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vdlimit " VERSION " -- manages disk limits\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2005 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-setDlimit(char const *filename, xid_t xid, uint32_t flags, struct vc_ctx_dlimit const *limit)
-{
- if (vc_get_dlimit(filename, xid, flags, 0) == -1) {
- if (vc_add_dlimit(filename, xid, flags) == -1) {
- perror(ENSC_WRAPPERS_PREFIX "vc_add_dlimit()");
- exit(wrapper_exit_code);
- }
- }
- if (vc_set_dlimit(filename, xid, flags, limit) == -1) {
- perror(ENSC_WRAPPERS_PREFIX "vc_set_dlimit()");
- exit(wrapper_exit_code);
- }
-}
-
-static void
-remDlimit(char const *filename, xid_t xid, uint32_t flags)
-{
- if (vc_rem_dlimit(filename, xid, flags) == -1) {
- perror(ENSC_WRAPPERS_PREFIX "vc_rem_dlimit()");
- exit(wrapper_exit_code);
- }
-}
-
-static void
-writeInt(int fd, char const *prefix, int val)
-{
- char buf[sizeof(val)*3 + 2];
- size_t len = utilvserver_fmt_int(buf, val);
-
- if (prefix)
- WRITE_STR(fd, prefix);
- Vwrite(fd, buf, len);
-}
-
-static void
-printDlimit(char const *filename, xid_t xid, uint32_t flags, bool formatted)
-{
- struct vc_ctx_dlimit limit;
-
- if (vc_get_dlimit(filename, xid, flags, &limit) == -1) {
- perror(ENSC_WRAPPERS_PREFIX "vc_get_dlimit()");
- exit(wrapper_exit_code);
- }
-
- if (formatted) {
- writeInt (1, 0, xid);
- WRITE_MSG(1, " ");
- WRITE_STR(1, filename);
- writeInt (1, "\nspace_used=", limit.space_used);
- writeInt (1, "\nspace_total=", limit.space_total);
- writeInt (1, "\ninodes_used=", limit.inodes_used);
- writeInt (1, "\ninodes_total=", limit.inodes_total);
- writeInt (1, "\nreserved=", limit.reserved);
- WRITE_MSG(1, "\n");
- }
- else {
- writeInt (1, 0, xid);
- writeInt (1, " ", limit.space_used);
- writeInt (1, " ", limit.space_total);
- writeInt (1, " ", limit.inodes_used);
- writeInt (1, " ", limit.inodes_total);
- writeInt (1, " ", limit.reserved);
- WRITE_MSG(1, " ");
- WRITE_STR(1, filename);
- WRITE_MSG(1, "\n");
- }
-}
-
-
-static bool
-setDLimitField(struct vc_ctx_dlimit *dst, char const *opt)
-{
- uint_least32_t *ptr;
- char const * const orig_opt = opt;
-
-#define GET_VAL_PTR(CMP, VAL) \
- (strncmp(opt, CMP "=", sizeof(CMP))==0) ? \
- (opt+=sizeof(CMP), &VAL) : 0
-
- if ((ptr=GET_VAL_PTR("space_used", dst->space_used))!=0) {}
- else if ((ptr=GET_VAL_PTR("space_total", dst->space_total))!=0) {}
- else if ((ptr=GET_VAL_PTR("inodes_used", dst->inodes_used))!=0) {}
- else if ((ptr=GET_VAL_PTR("inodes_total", dst->inodes_total))!=0) {}
- else if ((ptr=GET_VAL_PTR("reserved", dst->reserved))!=0) {}
- else ptr=0;
-
-#undef GET_VAL_PTR
-
- if (ptr!=0 && *ptr==VC_CDLIM_KEEP) {
- char *endptr;
- long val = strtol(opt, &endptr, 0);
-
- if (*opt==0 || *endptr!='\0') {
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "can not parse number in '");
- WRITE_STR(2, orig_opt);
- WRITE_MSG(2, "'\n");
- return false;
- }
-
- *ptr = val;
- }
- else if (ptr!=0) {
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "value already set in '");
- WRITE_STR(2, orig_opt);
- WRITE_MSG(2, "'\n");
- return false;
- }
- else {
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "unknown limit in '");
- WRITE_STR(2, orig_opt);
- WRITE_MSG(2, "'\n");
- return false;
- }
-
- return true;
-}
-
-int main(int argc, char *argv[])
-{
- bool do_set = false;
- bool do_remove = false;
- xid_t xid = VC_NOCTX;
- uint32_t flags = 0;
- char *endptr;
- int sum = 0;
-
- struct vc_ctx_dlimit limit = {
- .space_used = VC_CDLIM_KEEP,
- .space_total = VC_CDLIM_KEEP,
- .inodes_used = VC_CDLIM_KEEP,
- .inodes_total = VC_CDLIM_KEEP,
- .reserved = VC_CDLIM_KEEP
- };
-
- while (1) {
- int c = getopt_long(argc, argv, "+x:s:df:", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0]);
- case CMD_VERSION : showVersion();
- case 'x' : xid = Evc_xidopt2xid(optarg, true); break;
- case 's' :
- if (!setDLimitField(&limit, optarg))
- return EXIT_FAILURE;
- else
- do_set = true;
- break;
- case 'd' : do_remove = true; break;
- case 'f' :
- {
- flags = strtol(optarg, &endptr, 0);
- if ((flags == 0 && errno != 0) || *endptr != '\0') {
- WRITE_MSG(2, "Invalid flags argument: '");
- WRITE_STR(2, optarg);
- WRITE_MSG(2, "'; try '--help' for more information\n");
- return EXIT_FAILURE;
- }
- }
- break;
-
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help' for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- sum = ((do_set ? 1 : 0) + (do_remove ? 1 : 0));
-
- if (sum>1)
- WRITE_MSG(2, "Can not specify multiple operations; try '--help' for more information\n");
- else if (optind==argc)
- WRITE_MSG(2, "No mount point specified; try '--help' for more information\n");
- else if (xid==VC_NOCTX)
- WRITE_MSG(2, "No xid specified; try '--help' for more information\n");
- else {
- for (; optind < argc; ++optind) {
- if (do_set) setDlimit(argv[optind], xid, flags, &limit);
- else if (do_remove) remDlimit(argv[optind], xid, flags);
- else printDlimit(argv[optind], xid, flags, true);
- }
-
- return EXIT_SUCCESS;
- }
-
- return EXIT_FAILURE;
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on vdu.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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 <stdlib.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <errno.h>
-#include <string.h>
-
-__extension__ typedef long long longlong;
-
-static int vdu_onedir (char const *path, longlong *size)
-{
- int ret = -1;
- int dirfd = open (path,O_RDONLY); // A handle to speed up
- // chdir
- if (dirfd == -1){
- fprintf (stderr,"Can't open directory %s (%s)\n",path
- ,strerror(errno));
- }else{
- DIR *dir;
-
- fchdir (dirfd);
- dir = opendir (".");
- if (dir == NULL){
- fprintf (stderr,"Can't open (opendir) directory %s (%s)\n",path
- ,strerror(errno));
- }else{
- struct stat dirst;
- struct dirent *ent;
- longlong dirsize = 0;
-
- ret = 0;
- lstat (".",&dirst);
- while ((ent=readdir(dir))!=NULL){
- struct stat st;
- if (lstat(ent->d_name,&st)==-1){
- fprintf (stderr,"Can't stat %s/%s (%s)\n",path
- ,ent->d_name,strerror(errno));
- ret = -1;
- break;
- }else if (S_ISREG(st.st_mode)){
- if (st.st_nlink == 1){
- dirsize += st.st_size;
- }
- }else if (S_ISDIR(st.st_mode) && st.st_dev == dirst.st_dev){
- if (strcmp(ent->d_name,".")!=0
- && strcmp(ent->d_name,"..")!=0){
- char *tmp = malloc(strlen(path) + strlen(ent->d_name) + 2);
- if (tmp==0) ret=-1;
- else {
- strcpy(tmp, path);
- strcat(tmp, "/");
- strcat(tmp, ent->d_name);
- ret = vdu_onedir(tmp,&dirsize);
- free(tmp);
- fchdir (dirfd);
- }
- }
- }
- }
- closedir (dir);
- *size += dirsize;
- }
- close (dirfd);
- }
- return ret;
-}
-
-int main (int argc, char *argv[])
-{
- int ret = -1;
- if (argc < 2){
- fprintf (stderr,"vdu version %s\n",VERSION);
- fprintf (stderr,"vdu directory ...\n\n");
- fprintf (stderr
- ,"Compute the size of a directory tree, ignoring files\n"
- "with more than one link.\n");
- }else{
- int i;
-
- ret = 0;
- for (i=1; i<argc && ret != -1; i++){
- longlong size = 0;
- long ksize;
-
- ret = vdu_onedir (argv[i],&size);
- ksize = size >> 10;
- printf ("%s\t%ldK\n",argv[i],ksize);
- }
- }
- return ret;
-}
-
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on vfiles.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- This utility is used to extract the list of non unified files in
- a vserver.
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <dirent.h>
-
-#include <string>
-#include <list>
-#include <set>
-#include "vutil.h"
-
-using namespace std;
-
-static bool ignorelink = false;
-
-
-static void usage()
-{
- cerr <<
- "vfiles version " << VERSION <<
- "\n\n"
- "vfiles [ options ] reference-server vserver\n"
- "\n"
- "--debug: Prints some debugging messages.\n"
- "--ignorelink: Do not print symbolic links (they are never unified)\n"
- "\n"
- ;
-}
-
-
-static int vfiles_walk (
- string absdir,
- dev_t dev, // We stay on the same volume
- string logical_dir,
- set<string> &files)
-{
- int ret = -1;
- if (debug > 0) printf ("Entering directory %s\n",logical_dir.c_str());
- DIR *dir = opendir (absdir.c_str());
- if (dir == NULL){
- fprintf (stderr,"Can't open directory %s (%s)\n",absdir.c_str()
- ,strerror(errno));
- }else{
- struct dirent *ent;
- ret = 0;
- while (ret == 0 && (ent=readdir(dir))!=NULL){
- if (strcmp(ent->d_name,".")==0 || strcmp(ent->d_name,"..")==0){
- continue;
- }
- string file = absdir + "/" + ent->d_name;
- struct stat st;
- if (vutil_lstat(file,st) == -1){
- ret = -1;
- }else if (st.st_dev != dev){
- if (debug > 0) printf ("Ignore sub-directory %s\n",file.c_str());
- }else{
- if (S_ISDIR(st.st_mode)){
- ret |= vfiles_walk (file,dev
- ,logical_dir + "/" + ent->d_name,files);
- }else if (S_ISLNK(st.st_mode)){
- if (!ignorelink) printf ("%s\n",file.c_str());
- }else if (S_ISBLK(st.st_mode)
- || S_ISCHR(st.st_mode)
- || S_ISFIFO(st.st_mode)){
- printf ("%s\n",file.c_str());
- }else if (S_ISSOCK(st.st_mode)){
- // Do nothing
- }else{
- // Ok, this is a file. We either copy it or do a link
- string logical_file = logical_dir + "/" + ent->d_name;
- if (files.find (logical_file)==files.end()){
- printf ("%s\n",file.c_str());
- }
- }
- }
- }
- closedir(dir);
- }
- return ret;
-}
-
-int main (int argc, char *argv[])
-{
- int ret = -1;
- int i;
- for (i=1; i<argc; i++){
- const char *arg = argv[i];
- //const char *opt = argv[i+1];
- if (strcmp(arg,"--debug")==0){
- debug++;
- }else if (strcmp(arg,"--ignorelink")==0){
- ignorelink=true;
- }else{
- break;
- }
- }
- if (i!=argc-2){
- usage();
- }else{
- string refserv = argv[i++];
- string newserv = argv[i];
- list<Package> packages;
- // Load the files which are not configuration files from
- // the packages
- vutil_loadallpkg (refserv,packages);
- set<string> files;
- for (list<Package>::iterator it=packages.begin(); it!=packages.end(); it++){
- (*it).loadfiles(refserv,files);
- }
- struct stat st;
- if (vutil_lstat(newserv,st)!=-1){
- // Now, we do a recursive walk of newserv and prints
- // all files not unifiable
- ret = vfiles_walk (newserv,st.st_dev,"",files);
- }
- }
- return ret;
-}
-
-
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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.
-
-#include "pathconfig.h"
-#include "lib_internal/util-dotfile.h"
-
-#include <sys/param.h>
-
-static UNUSED void
-freeHashList(HashDirCollection *hash_vec)
-{
- for (struct HashDirInfo *itm = Vector_begin(hash_vec);
- itm!=Vector_end(hash_vec);
- ++itm) {
- free(const_cast(char *)(itm->path.d));
- }
-
- Vector_free(hash_vec);
-}
-
-static size_t
-initHashList(HashDirCollection *hash_vec, char const *hashdir)
-{
- int cur_dir = Eopen(".", O_RDONLY|O_DIRECTORY, 0);
- Echdir(hashdir);
-
- DIR *d = Eopendir(".");
- struct dirent *ep;
- size_t l = strlen(hashdir);
- size_t res = 0;
-
- while ((ep=readdir(d)) != 0) {
- struct stat st;
-
- if (isDotfile(ep->d_name) ||
- stat(ep->d_name, &st)==-1 || !S_ISDIR(st.st_mode))
- continue;
-
- if (HashDirInfo_findDevice(hash_vec, st.st_dev)!=0) {
- WRITE_MSG(2, "Duplicate hash-dir entry '");
- WRITE_STR(2, ep->d_name);
- WRITE_MSG(2, "' found\n");
- continue;
- }
-
- char *full_path = Emalloc(l + strlen(ep->d_name) + 3);
- char *ptr = full_path + l;
-
- memcpy(full_path, hashdir, l);
- while (ptr>full_path && ptr[-1]=='/') --ptr;
- *ptr++ = '/';
- strcpy(ptr, ep->d_name);
- strcat(ptr, "/"); // append a trailing '/'
-
-
- struct HashDirInfo tmp = {
- .device = st.st_dev,
- .path = { full_path, strlen(full_path) },
- };
-
- res = MAX(res, tmp.path.l);
-
- memcpy(Vector_pushback(hash_vec), &tmp, sizeof tmp);
- }
-
- if (Vector_count(hash_vec)==0) {
- WRITE_MSG(2, "Could not find a place for the hashified files at '");
- WRITE_STR(2, hashdir);
- WRITE_MSG(2, "'.\n");
- exit(wrapper_exit_code);
- }
-
- Eclosedir(d);
- Efchdir(cur_dir);
- Eclose(cur_dir);
-
- return res;
-}
-
-static bool
-initHashMethod(struct HashDirConfiguration *conf, char const *filename)
-{
- int fd = open(filename, O_RDONLY);
- if (fd==-1 && conf->method==0)
- conf->method = hashFunctionDefault();
-
- if (fd==-1) {
- assert(conf->method!=0);
- if (conf->method==0) return false;
- if (global_args->dry_run) return true; // do not create the file
-
- fd = Eopen(filename, O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, 0644);
- TEMP_FAILURE_RETRY(write(fd, conf->method->name, strlen(conf->method->name)));
- TEMP_FAILURE_RETRY(write(fd, "\n", 1));
- }
- else {
- off_t s = Elseek(fd, 0, SEEK_END);
- char buf[s + 1];
- Elseek(fd, 0, SEEK_SET);
-
- conf->method=0;
-
- if (s>0 && read(fd, buf, s+1)==s) {
- while (s>0 && (buf[s-1]=='\0' || buf[s-1]=='\n'))
- --s;
- buf[s] = '\0';
-
- conf->method = hashFunctionFind(buf);
- if (conf->method==0) {
- WRITE_MSG(2, "Can not find hash-function '");
- WRITE_STR(2, buf);
- WRITE_MSG(2, "'\n");
- }
- }
- else
- WRITE_MSG(2, "Can not read configuration file for hash-method\n");
- }
-
- if (conf->method!=0 && conf->method->digestsize*8>HASH_MAXBITS) {
- WRITE_MSG(2, "Wow... what an huge hash-function. I can not handle so much bits; giving up...\n");
- conf->method=0;
- }
-
- Eclose(fd);
- return conf->method!=0;
-}
-
-static bool
-initHashBlocks(struct HashDirConfiguration *conf, char const *filename)
-{
- int fd = open(filename, O_RDONLY);
-
- if (fd==-1) {
- char str[sizeof("all,start,middle,end,")] = { [0] = '\0' };
-
- if (global_args->dry_run) return true; // do not create the file
-
- fd = Eopen(filename, O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, 0644);
-
- if (conf->blocks== hshALL) strcat(str, "all\n");
- if (conf->blocks & hshSTART) strcat(str, "start\n");
- if (conf->blocks & hshMIDDLE) strcat(str, "middle\n");
- if (conf->blocks & hshEND) strcat(str, "end\n");
-
- EwriteAll(fd, str, strlen(str));
- }
- else {
- off_t s = Elseek(fd, 0, SEEK_END);
- char buf[s + 1];
- Elseek(fd, 0, SEEK_SET);
-
- conf->blocks = hshINVALID;
-
- if (s>0 && read(fd, buf, s+1)==s) {
- char *tok = buf;
- char *sep = "\n,\t ";
-
- buf[s] = '\0';
- conf->blocks = hshALL;
-
- do {
- char *ptr = strsep(&tok, sep);
-
- if (*ptr=='#') { sep = "\n"; continue; }
- sep = "\n,\t ";
- if (*ptr=='\0') continue;
-
- if (strcasecmp(ptr, "all") ==0) conf->blocks = hshALL;
- else {
- if (conf->blocks==hshINVALID) conf->blocks = 0;
-
- else if (strcasecmp(ptr, "start") ==0) conf->blocks |= hshSTART;
- else if (strcasecmp(ptr, "middle")==0) conf->blocks |= hshMIDDLE;
- else if (strcasecmp(ptr, "end") ==0) conf->blocks |= hshEND;
- else {
- WRITE_MSG(2, "Invalid block descriptor '");
- WRITE_STR(2, ptr);
- WRITE_MSG(2, "'\n");
- conf->blocks = hshINVALID;
- tok = 0;
- }
- }
- } while (tok!=0);
- }
- else
- WRITE_MSG(2, "Can not read configuration file for hash-blocks\n");
- }
-
- Eclose(fd);
- return conf->blocks!=hshINVALID;
-}
-
-static bool
-initHashBlockSize(struct HashDirConfiguration *conf, char const *filename)
-{
- if (conf->blocks==hshALL) return true;
-
- int fd = open(filename, O_RDONLY);
- if (fd==-1) {
- char str[sizeof("0x") + sizeof(size_t)*3+2] = {
- [0] = '0', [1] = 'x'
- };
- size_t len = utilvserver_fmt_xuint(str+2, conf->blocksize);
-
- if (global_args->dry_run) return true; // do not create the file
-
- fd = Eopen(filename, O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, 0644);
- EwriteAll(fd, str, len+2);
- }
- else {
- off_t s = Elseek(fd, 0, SEEK_END);
- char buf[s + 1];
- Elseek(fd, 0, SEEK_SET);
-
- conf->blocksize = (size_t)(-1);
-
- if (s>0 && read(fd, buf, s+1)==s) {
- char *errptr;
-
- while (s>0 && (buf[s-1]=='\0' || buf[s-1]=='\n'))
- --s;
- buf[s] = '\0';
-
- conf->blocksize = strtol(buf, &errptr, 0);
- if (errptr==buf || (*errptr!='\0' && *errptr!='\n')) {
- WRITE_MSG(2, "Failed to parse blocksize '");
- WRITE_STR(2, buf);
- WRITE_MSG(2, "'\n");
- conf->blocksize = (size_t)(-1);
- }
- }
- else
- WRITE_MSG(2, "Can not read configuration file for hash-blocksize\n");
- }
-
- Eclose(fd);
- return conf->blocksize!=(size_t)(-1);
-}
-
-static bool
-initHashConf(struct HashDirConfiguration *conf, char const *hashdir)
-{
- size_t l = strlen(hashdir);
- char tmp[l + MAX(MAX(sizeof("/method"), sizeof("/blocks")),
- sizeof("/blocksize"))];
-
- memcpy(tmp, hashdir, l);
-
- return ((strcpy(tmp+l, "/method"), initHashMethod (conf, tmp)) &&
- (strcpy(tmp+l, "/blocks"), initHashBlocks (conf, tmp)) &&
- (strcpy(tmp+l, "/blocksize"), initHashBlockSize(conf, tmp)));
-}
-
-static char *
-searchHashdir(char const *lhs, char const *rhs)
-{
- size_t l1 = strlen(lhs);
- size_t l2 = rhs ? strlen(rhs) : 0;
- char * res = Emalloc(l1 + l2 + 1);
- struct stat st;
-
- strcpy(res, lhs);
- if (rhs) strcat(res, rhs);
-
- if (stat(res, &st)==-1 || !S_ISDIR(st.st_mode)) {
- free(res);
- res = 0;
- }
-
- return res;
-}
-
-static void
-initModeManually(struct Arguments const UNUSED *args, int argc, char *argv[])
-{
- assert(args->hash_dir!=0);
-
- if (argc<2) {
- WRITE_MSG(2, "No exclude list specified\n");
- exit(1);
- }
-
- if (!initHashConf(&global_info.hash_conf, args->hash_dir)) {
- WRITE_MSG(2, "failed to initialize hash-configuration\n");
- exit(1);
- }
-
- global_info.hash_dirs_max_size = initHashList(&global_info.hash_dirs,
- args->hash_dir);
- MatchList_initManually(&global_info.dst_list, 0, strdup(argv[0]), argv[1]);
-}
-
-static void
-initModeVserver(struct Arguments const UNUSED *args, int argc, char *argv[])
-{
- char const *hashdir = args->hash_dir;
- struct MatchVserverInfo vserver = {
- .name = argv[0],
- .use_pkgmgmt = true
- };
-
- if (!MatchVserverInfo_init(&vserver)) {
- WRITE_MSG(2, "Failed to initialize unification for vserver\n");
- exit(1);
- }
-
- if (argc!=1) {
- WRITE_MSG(2, "More than one vserver is not supported\n");
- exit(1);
- }
-
- if (!MatchList_initByVserver(&global_info.dst_list, &vserver)) {
- WRITE_MSG(2, "unification not configured for this vserver\n");
- exit(1);
- }
-
- if (hashdir==0) hashdir = searchHashdir(vserver.appdir.d, "/hash");
- if (hashdir==0) hashdir = searchHashdir(CONFDIR "/.defaults/apps/vunify/hash", 0);
-
- if (hashdir==0) {
- WRITE_MSG(2, "no hash-directory configured for this vserver.\n");
- exit(1);
- }
-
- if (!initHashConf(&global_info.hash_conf, hashdir)) {
- WRITE_MSG(2, "failed to initialize hash-configuration\n");
- exit(1);
- }
-
- global_info.hash_dirs_max_size = initHashList(&global_info.hash_dirs, hashdir);
-
- free(const_cast(char *)(hashdir));
- MatchVserverInfo_free(&vserver);
-}
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2005 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 "vhashify.h"
-#include "util.h"
-
-#include "lib/internal.h"
-#include "lib_internal/matchlist.h"
-#include "lib_internal/unify.h"
-#include "ensc_vector/vector.h"
-
-#include <beecrypt/beecrypt.h>
-
-#include <setjmp.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <string.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#include <signal.h>
-#include <limits.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-
-#define ENSC_WRAPPERS_STDLIB 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_DIRENT 1
-#define ENSC_WRAPPERS_IO 1
-#include <wrappers.h>
-
-
-#define HASH_BLOCKSIZE 0x10000000u
-#define HASH_MINSIZE 0x10
-#define HASH_MAXBITS 256 // we have to take care about
- // max filename-length...
-
-#if HASH_MINSIZE<=0
-# error HASH_MINSIZE must be not '0'
-#endif
-
-
-#define CMD_HELP 0x8000
-#define CMD_VERSION 0x8001
-
-#define CMD_DESTINATION 0x1000
-#define CMD_INSECURE 0x1001
-#define CMD_SLEDGE 0x1002
-#define CMD_MANUALLY 0x1003
-#define CMD_REFRESH 0x1004
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "destination", required_argument, 0, CMD_DESTINATION },
- { "insecure", no_argument, 0, CMD_INSECURE },
- { "sledgehammer", no_argument, 0, CMD_SLEDGE },
- { "manually", no_argument, 0, CMD_MANUALLY },
- { "refresh", no_argument, 0, CMD_REFRESH },
- { "dry-run", no_argument, 0, 'n' },
- { "verbose", no_argument, 0, 'v' },
- { 0,0,0,0 }
-};
-
- // hash digest grouped by 2 digits + hash-collision counter + 2* '/' + NULL
-typedef char HashPath[HASH_MAXBITS/4 + (HASH_MAXBITS/4/2) +
- sizeof(unsigned int)*2 + 3];
-
-struct HashDirConfiguration
-{
- hashFunction const *method;
- enum { hshALL=0, hshSTART = 1, hshMIDDLE=2,
- hshEND = 4, hshINVALID = -1 } blocks;
- size_t blocksize;
-};
-
-struct WalkdownInfo
-{
- PathInfo state;
- struct MatchList dst_list;
- struct HashDirConfiguration hash_conf;
- HashDirCollection hash_dirs;
- size_t hash_dirs_max_size;
-
- hashFunctionContext hash_context;
-};
-
-int wrapper_exit_code = 1;
-struct Arguments const *global_args;
-static struct SkipReason skip_reason;
-
-struct WalkdownInfo global_info = {
- .hash_conf = { .method = 0,
- .blocks = hshALL,
- .blocksize = 0x10000 }
-};
-
-#include "vhashify-init.hc"
-
-int Global_getVerbosity() {
- return global_args->verbosity;
-}
-
-int Global_doRenew() {
- return true;
-}
-
-int Global_isVserverRunning() {
- // TODO
- return global_args->insecure<2;
-}
-
-static void
-showHelp(char const *cmd)
-{
- WRITE_MSG(1, "Usage:\n ");
- WRITE_STR(1, cmd);
- WRITE_MSG(1,
- " [-nv] [--refresh] <vserver>\n or\n ");
- WRITE_STR(1, cmd);
- WRITE_MSG(1,
- " --manually [-nv] [--] <hashdir> <path> <excludelist>\n\n"
- " --manually ... hashify generic paths; excludelists must be generated\n"
- " manually\n"
- " --refresh ... hashify already hashified files also\n"
- " -n ... do not modify anything; just show what there will be\n"
- " done (in combination with '-v')\n"
- " -v ... verbose mode\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(0);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vhashify " VERSION " -- hashifies vservers and/or directories\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2005 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int
-HashDirInfo_compareDevice(void const *lhs_v, void const *rhs_v)
-{
- struct HashDirInfo const * const lhs = lhs_v;
- dev_t const * const rhs = rhs_v;
-
- assert(lhs!=0 && rhs!=0);
- return lhs->device - *rhs;
-}
-
-PathInfo const *
-HashDirInfo_findDevice(HashDirCollection const *coll, dev_t dev)
-{
- struct HashDirInfo const *res;
-
- res = Vector_searchSelfOrg_const(coll, &dev,
- HashDirInfo_compareDevice, vecSHIFT_ONCE);
-
- if (res!=0) return &res->path;
- else return 0;
-}
-
-#include "vserver-visitdir.hc"
-
-static bool
-checkFstat(PathInfo const * const basename,
- struct stat * const st)
-{
- assert(basename->d[0] != '/');
-
- // local file does not exist... strange
- // TODO: message
- skip_reason.r = rsFSTAT;
- if (lstat(basename->d, st)==-1) return false;
-
- // this is a directory and succeeds everytime
- if (S_ISDIR(st->st_mode))
- return true;
-
- // ignore symlinks
- skip_reason.r = rsSYMLINK;
- if (S_ISLNK(st->st_mode)) return false;
-
- // ignore special files
- skip_reason.r = rsSPECIAL;
- if (!S_ISREG(st->st_mode) &&
- !S_ISDIR(st->st_mode)) return false;
-
- // ignore small files
- skip_reason.r = rsTOOSMALL;
- if (st->st_size < HASH_MINSIZE) return false;
-
- switch (Unify_isIUnlinkable(basename->d)) {
- case unifyUNSUPPORTED : skip_reason.r = rsUNSUPPORTED; return false;
- case unifyBUSY :
- // do an implicit refresh on busy files when there are no active links
- if (st->st_nlink>1 && !global_args->do_refresh) {
- // TODO: message
- skip_reason.r = rsUNIFIED;
- return false;
- }
- break;
- default : break;
- }
-
- return true;
-}
-
-static sigjmp_buf bus_error_restore;
-static volatile sig_atomic_t bus_error;
-
-static void
-handlerSIGBUS(int UNUSED num)
-{
- bus_error = 1;
- siglongjmp(bus_error_restore, 1);
-}
-
-static bool
-convertDigest(HashPath d_path)
-{
- static char const HEX_DIGIT[] = "0123456789abcdef";
- hashFunctionContext * const h_ctx = &global_info.hash_context;
- size_t d_size = h_ctx->algo->digestsize;
-
- unsigned char digest[d_size];
- size_t out = 0;
-
- if (hashFunctionContextDigest(h_ctx, digest)==-1)
- return false;
-
- for (size_t in=0;
- out+1<sizeof(HashPath)-(sizeof(unsigned int)*2 + 2) && in<d_size;
- ++in) {
- if ((in+254)%(in<=2 ? 1 : 256) == 0 && in>0)
- d_path[out++]='/';
- d_path[out++] = HEX_DIGIT[digest[in] >> 4];
- d_path[out++] = HEX_DIGIT[digest[in] & 0x0f];
- }
- d_path[out++] = '\0';
-
- return true;
-}
-
-static bool
-addStatHash(hashFunctionContext *h_ctx, struct stat const * const st)
-{
-#define DECL_ATTR(X) __typeof__(st->st_##X) X
-#define SET_ATTR(X) .X = st->st_##X
-
- struct __attribute__((__packed__)) {
- DECL_ATTR(mode);
- DECL_ATTR(uid);
- DECL_ATTR(gid);
- DECL_ATTR(rdev);
- DECL_ATTR(size);
- DECL_ATTR(mtime);
- } tmp = {
- SET_ATTR(mode),
- SET_ATTR(uid),
- SET_ATTR(gid),
- SET_ATTR(rdev),
- SET_ATTR(size),
- SET_ATTR(mtime)
- };
-
- return hashFunctionContextUpdate(h_ctx, (void *)&tmp, sizeof tmp)!=-1;
-}
-
-static bool
-calculateHashFromFD(int fd, HashPath d_path, struct stat const * const st)
-{
- hashFunctionContext * const h_ctx = &global_info.hash_context;
- void const * volatile buf = 0;
- loff_t volatile buf_size = 0;
- bool volatile res = false;
-
-
- if (hashFunctionContextReset(h_ctx)==-1 ||
- !addStatHash(h_ctx, st))
- return false;
-
- bus_error = 0;
- if (sigsetjmp(bus_error_restore,1)==0) {
- loff_t offset = 0;
- off_t size = st->st_size;
-
- while (offset < size) {
- buf_size = size-offset;
- if (buf_size>HASH_BLOCKSIZE) buf_size = HASH_BLOCKSIZE;
-
- if ((buf=mmap(0, buf_size, PROT_READ, MAP_SHARED, fd, offset))==0) {
- perror("mmap(<hash>)");
- goto out;
- }
-
- offset += buf_size;
- madvise(const_cast(void *)(buf), buf_size, MADV_SEQUENTIAL); // ignore error...
-
- if (hashFunctionContextUpdate(h_ctx, buf, buf_size)==-1) goto out;
-
- munmap(const_cast(void *)(buf), buf_size);
- buf = 0;
- }
-
- res = convertDigest(d_path);
- }
-
- out:
- if (buf!=0) munmap(const_cast(void *)(buf), buf_size);
- return res;
-}
-
-static bool
-calculateHash(PathInfo const *filename, HashPath d_path, struct stat const * const st)
-{
- int fd = open(filename->d, O_NOFOLLOW|O_NONBLOCK|O_RDONLY|O_NOCTTY);
- struct stat fst;
- bool res = false;
-
- do {
- if (fd==-1) {
- int old_errno = errno;
- WRITE_MSG(2, "Failed to open '");
- WRITE_STR(2, filename->d);
- errno = old_errno;
- perror("'");
- break;;
- }
-
- if (fstat(fd, &fst)==-1 ||
- fst.st_dev!=st->st_dev || fst.st_ino!=st->st_ino) {
- WRITE_MSG(2, "An unexpected event occured while stating '");
- WRITE_STR(2, filename->d);
- WRITE_MSG(2, "'.\n");
- break;
- }
-
- if (!calculateHashFromFD(fd, d_path, st)) {
- WRITE_MSG(2, "Failed to calculate hash for '");
- WRITE_STR(2, filename->d);
- WRITE_MSG(2, "'.\n");
- break;
- }
-
- res = true;
- } while (false);
-
- if (fd!=-1) close(fd);
- return res;
-}
-
-static enum { mkdirFAIL, mkdirSUCCESS, mkdirSKIP }
-mkdirSingle(char const *path, char *end_ptr, int good_err)
-{
- *end_ptr = '\0';
- if (mkdir(path, 0700)!=-1 || errno==EEXIST) {
- *end_ptr = '/';
- return mkdirSUCCESS;
- }
- else if (errno==good_err) {
- *end_ptr = '/';
- return mkdirSKIP;
- }
- else {
- int old_errno = errno;
- WRITE_MSG(2, "mkdir('");
- WRITE_STR(2, path);
- errno = old_errno;
- perror("')");
- return mkdirFAIL;
- }
-}
-
-static char *
-rstrchr(char *str, char c)
-{
- while (*str!=c) --str;
- return str;
-}
-
-static bool
-mkdirRecursive(char const *path)
-{
- if (path[0]!='/') return false; // only absolute paths
-
- char buf[strlen(path)+1];
- char * ptr = buf + sizeof(buf) - 2;
-
- strcpy(buf, path);
-
- while (ptr>buf && (ptr = rstrchr(ptr, '/'))!=0) {
- switch (mkdirSingle(buf, ptr, ENOENT)) {
- case mkdirSUCCESS : break;
- case mkdirSKIP : --ptr; continue;
- case mkdirFAIL : return false;
- }
-
- break; // implied by mkdirSUCCESS
- }
-
- assert(ptr!=0);
- ++ptr;
-
- while ((ptr=strchr(ptr, '/'))!=0) {
- switch (mkdirSingle(buf, ptr, 0)) {
- case mkdirSKIP :
- case mkdirFAIL : return false;
- case mkdirSUCCESS : ++ptr; continue;
- }
- }
-
- return true;
-}
-
-static bool
-resolveCollisions(char *result, PathInfo const *root, HashPath d_path,
- struct stat *st, struct stat *hash_st)
-{
- strcpy(result, root->d); // 'root' ends on '/' already (see initHashList())
- strcat(result, d_path);
-
- char *ptr = result + strlen(result);
- unsigned int idx = 0;
- char buf[sizeof(int)*2 + 1];
- size_t len;
-
- *ptr = '-';
- ptr[sizeof(int)*2+1] = '\0';
-
- for (;; ++idx) {
- len = utilvserver_fmt_xuint(buf, idx);
- memset(ptr+1, '0', sizeof(int)*2 - len);
- memcpy(ptr+1 + sizeof(int)*2 - len, buf, len);
-
- if (lstat(result, hash_st)==-1) {
- if (global_args->dry_run && errno!=ENOENT) {
- int old_errno = errno;
- WRITE_MSG(2, "lstat('");
- WRITE_STR(2, buf);
- errno = old_errno;
- perror("')");
- return false;
- }
- }
- else if (Unify_isUnified(st, hash_st)) {
- skip_reason.r = rsUNIFIED;
- return false;
- }
- else if (!Unify_isUnifyable(st, hash_st))
- continue; // continue with next number*****
- else
- break; // ok, we finish here
-
- if (!global_args->dry_run) {
- *ptr = '\0';
- if (!mkdirRecursive(result))
- return false;
- *ptr = '-';
-
- int fd = open(result, O_NOFOLLOW|O_EXCL|O_CREAT|O_WRONLY, 0200);
-
- if (fd==-1) {
- int old_errno = errno;
- WRITE_MSG(2, "open('");
- WRITE_STR(2, buf);
- errno = old_errno;
- perror("')");
- return false;
- }
-
- close(fd);
- }
-
- // HACK: avoid an additional lstat on the resulting hash-file
- hash_st->st_size = 0;
- break;
- }
-
- return true;
-}
-
-static char const *
-checkDirEntry(PathInfo const *path, PathInfo const *basename,
- bool *is_dir,
- struct stat *st, struct stat *hash_st,
- char *result_buf)
-{
- //printf("checkDirEntry(%s, %s, %u)\n", path->d, d_path, is_dir);
-
- struct WalkdownInfo const * const info = &global_info;
-
- // Check if it is in the exclude/include list of the destination vserver and
- // abort when it is not matching an allowed entry
- skip_reason.r = rsEXCL;
- if (MatchList_compare(&info->dst_list, path->d)!=stINCLUDE) return 0;
-
- if (checkFstat(basename, st)) {
- PathInfo const *hash_root_path;
- HashPath d_path;
-
- *is_dir = S_ISDIR(st->st_mode);
-
- if (!*is_dir &&
- !((skip_reason.r = rsWRONGDEV,
- (hash_root_path = HashDirInfo_findDevice(&info->hash_dirs, st->st_dev))!=0) &&
- (skip_reason.r = rsGENERAL,
- calculateHash(basename, d_path, st)) &&
- resolveCollisions(result_buf, hash_root_path, d_path, st, hash_st)))
- return 0;
-
- return result_buf;
- }
-
- return 0;
-}
-
-static void
-printSkipReason()
-{
- WRITE_MSG(1, " (");
- switch (skip_reason.r) {
- case rsDOTFILE : WRITE_MSG(1, "dotfile"); break;
- case rsEXCL : WRITE_MSG(1, "excluded"); break;
- case rsTOOSMALL : WRITE_MSG(1, "too small"); break;
- case rsUNSUPPORTED : WRITE_MSG(1, "operation not supported"); break;
- case rsFSTAT : WRITE_MSG(1, "fstat error"); break;
- case rsSYMLINK : WRITE_MSG(1, "symlink"); break;
- case rsUNIFIED : WRITE_MSG(1, "already unified"); break;
- case rsSPECIAL : WRITE_MSG(1, "non regular file"); break;
- case rsWRONGDEV : WRITE_MSG(1, "no matching device"); break;
- case rsGENERAL : WRITE_MSG(1, "general error"); break;
- default : assert(false); abort();
- }
- WRITE_MSG(1, ")");
-}
-
-static bool
-doit(char const *src, char const *dst,
- struct stat const *src_st, struct stat const *dst_st,
- PathInfo const *path)
-{
- if (global_args->dry_run || Global_getVerbosity()>=2) {
- WRITE_MSG(1, "unifying '");
- Vwrite(1, path->d, path->l);
- WRITE_MSG(1, "'");
-
- if (Global_getVerbosity()>=4) {
- WRITE_MSG(1, " (to '");
- WRITE_STR(1, dst);
- WRITE_MSG(1, "')");
- }
-
- WRITE_MSG(1, "\n");
- }
-
- // abort here in dry-run mode
- if (global_args->dry_run) return true;
-
- if (dst_st->st_size==0) {
- // file was not unified yet
-
- if (Global_isVserverRunning()) {
- (void)unlink(dst);
- if (Unify_copy (src, src_st, dst) &&
- // the mixed 'dst' and 'src_st' params are intentionally...
- Unify_unify(dst, src_st, src, false))
- return true;
- }
- else if (Unify_unify(src, src_st, dst, true))
- return true;
-
- (void)unlink(dst); // cleanup in error-case
- }
- // there exists already a reference-file
- else if (Unify_unify(dst, dst_st, src, false))
- return true;
-
- return false;
-}
-
-static uint64_t
-visitDirEntry(struct dirent const *ent)
-{
- uint64_t res = 0;
- char const * dirname = ent->d_name;
- PathInfo path = global_info.state;
- PathInfo tmp_path = {
- .d = dirname,
- .l = strlen(dirname)
- };
- char path_buf[ENSC_PI_APPSZ(path, tmp_path)];
- char const *match = 0;
-
-
- PathInfo_append(&path, &tmp_path, path_buf);
-
- bool is_dotfile = isDotfile(dirname);
- bool is_dir;
- struct stat src_stat = { .st_mode=0 };
- struct stat hash_stat;
- char tmpbuf[global_info.hash_dirs_max_size +
- sizeof(HashPath) + 2];
-
- skip_reason.r = rsDOTFILE;
-
- if (is_dotfile ||
- (match=checkDirEntry(&path, &tmp_path,
- &is_dir, &src_stat, &hash_stat,
- tmpbuf))==0) {
-
- bool is_link = !is_dotfile && S_ISLNK(src_stat.st_mode);
-
- if (Global_getVerbosity()>=1 &&
- (Global_getVerbosity()>=3 || skip_reason.r!=rsUNIFIED) &&
- ((!is_dotfile && !is_link) ||
- (Global_getVerbosity()>=6 && is_dotfile) ||
- (Global_getVerbosity()>=6 && is_link)) ) {
- WRITE_MSG(1, " skipping '");
- Vwrite(1, path.d, path.l);
- WRITE_MSG(1, "'");
- if (Global_getVerbosity()>=2) printSkipReason();
- WRITE_MSG(1, "\n");
- }
-
- return 0;
- }
-
- if (is_dir) {
- res = visitDir(dirname, &src_stat);
- }
- else if (doit(dirname, match, &src_stat, &hash_stat, &path))
- res = 1;
- else {
- // TODO: message
- res = 0;
- }
-
- return res;
-
-}
-
-int main(int argc, char *argv[])
-{
- struct Arguments args = {
- .mode = mdVSERVER,
- .hash_dir = 0,
- .verbosity = 0,
- .insecure = 0,
- .dry_run = false,
- .do_refresh = false,
- };
-
- Vector_init(&global_info.hash_dirs, sizeof(struct HashDirInfo));
-
- global_args = &args;
- while (1) {
- int c = getopt_long(argc, argv, "+nv",
- CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(argv[0]);
- case CMD_VERSION : showVersion();
- case CMD_DESTINATION : args.hash_dir = optarg; break;
- case CMD_MANUALLY : args.mode = mdMANUALLY; break;
- case CMD_INSECURE : args.insecure = 1; break;
- case CMD_SLEDGE : args.insecure = 2; break;
- case CMD_REFRESH : args.do_refresh = true; break;
- case 'n' : args.dry_run = true; break;
- case 'v' : ++args.verbosity; break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- if (argc==optind) {
- WRITE_MSG(2, "No directory/vserver given\n");
- return EXIT_FAILURE;
- }
-
- if (args.hash_dir==0 && args.mode==mdMANUALLY) {
- WRITE_MSG(2, "'--manually' requires '--destination'\n");
- return EXIT_FAILURE;
- }
-
- switch (args.mode) {
- case mdMANUALLY : initModeManually(&args, argc-optind, argv+optind); break;
- case mdVSERVER : initModeVserver (&args, argc-optind, argv+optind); break;
- default : assert(false); return EXIT_FAILURE;
- };
-
- if (hashFunctionContextInit(&global_info.hash_context,
- global_info.hash_conf.method)==-1) {
- WRITE_MSG(2, "Failed to initialize hash-context\n");
- return EXIT_FAILURE;
- }
-
- if (Global_getVerbosity()>=1)
- WRITE_MSG(1, "Starting to traverse directories...\n");
-
- signal(SIGBUS, handlerSIGBUS);
-
- Echdir(global_info.dst_list.root.d);
- visitDir("/", 0);
-
-#ifndef NDEBUG
- MatchList_destroy(&global_info.dst_list);
- freeHashList(&global_info.hash_dirs);
- hashFunctionContextFree(&global_info.hash_context);
-#endif
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_SRC_VHASHIFY_H
-#define H_UTIL_VSERVER_SRC_VHASHIFY_H
-
-#include "ensc_vector/list.h"
-#include "lib_internal/pathinfo.h"
-
-#include <sys/types.h>
-#include <stdbool.h>
-
-struct Arguments {
- enum {mdMANUALLY, mdVSERVER} mode;
- unsigned int verbosity;
- unsigned int insecure;
- char const * hash_dir;
- bool dry_run;
- bool do_refresh;
-};
-
-struct HashDirInfo {
- PathInfo const path;
- dev_t device;
-};
-
-struct SkipReason {
- enum { rsDOTFILE, rsEXCL, rsTOOSMALL, rsUNSUPPORTED,
- rsFSTAT, rsSYMLINK, rsUNIFIED, rsWRONGDEV,
- rsSPECIAL, rsGENERAL } r;
-};
-
-typedef struct Vector HashDirCollection;
-
-int HashDirInfo_compareDevice(void const *lhs, void const *rhs);
-PathInfo const * HashDirInfo_findDevice(HashDirCollection const *, dev_t dev);
-
-#endif // H_UTIL_VSERVER_SRC_VHASHIFY_H
+++ /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 "vserver.h"
-#include "linuxvirtual.h"
-#include "util.h"
-
-#include <getopt.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x8000
-#define CMD_VERSION 0x8001
-
-int wrapper_exit_code = 1;
-
-static struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "xid", required_argument, 0, 'c' },
- { 0,0,0,0 }
-};
-
-struct Arguments
-{
- xid_t xid;
- int sig;
-};
-
-static char const * const SIGNALS[] = {
- // 0 1 2 3 4 5 6 7
- "UNUSED", "HUP", "INT", "QUIT", "ILL", "TRAP", "ABRT", "UNUSED",
- "FPE", "KILL", "USR1", "SEGV", "USR2", "PIPE", "ALRM", "TERM",
- "STKFLT", "CHLD", "CONT", "STOP", "TSTP", "TTIN", "TTOU", "IO",
- "XCPU", "XFSZ", "VTALRM", "PROF", "WINCH",
- 0,
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--xid|-c <xid>] [-s <signal>] [--] <pid>*\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vkill " VERSION " -- sends signals to processes within other contexts\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static int
-str2sig(char const *str)
-{
- char *errptr;
- int res = strtol(str, &errptr, 10);
-
- if (*errptr!='\0') res=-1;
- if (res==-1 && strncmp(str,"SIG",3)==0) str+=3;
- if (res==-1) {
- char const * const *ptr = SIGNALS;
- for (;*ptr!=0; ++ptr) {
- if (strcmp(*ptr,str)!=0) continue;
- res = ptr-SIGNALS;
- break;
- }
- }
-
- return res;
-}
-
-#if defined(VC_ENABLE_API_LEGACY)
-inline static ALWAYSINLINE int
-kill_wrapper_legacy(xid_t UNUSED xid, char const *proc, int UNUSED sig)
-{
- pid_t pid;
-
- signal(SIGCHLD, SIG_DFL);
- pid = Efork();
-
- if (pid==0) {
- int status;
- int res;
- while ((res=wait4(pid, &status, 0,0))==-1 &&
- (errno==EAGAIN || errno==EINTR)) {}
-
- return (res==0 && WIFEXITED(status) && WEXITSTATUS(status)) ? 0 : 1;
- }
-
- execl(LEGACYDIR "/vkill", "legacy/vkill", proc, (void *)(0));
- perror("vkill: execl()");
- exit(1);
-}
-
-static int
-kill_wrapper(xid_t xid, char const *pid, int sig)
-{
- //printf("kill_wrapper(%u, %s, %i)\n", xid, pid, sig);
- if (vc_ctx_kill(xid,atoi(pid),sig)==-1) {
- int err = errno;
- if (vc_get_version(VC_CAT_COMPAT)==-1)
- return kill_wrapper_legacy(xid, pid, sig);
- else {
- errno = err;
- perror("vkill: vc_ctx_kill()");
- return 1;
- }
- }
-
- return 0;
-}
-#else // VC_ENABLE_API_LEGACY
-inline static int
-kill_wrapper(xid_t xid, char const *pid, int sig)
-{
- if (vc_ctx_kill(xid,atoi(pid),sig)==-1) {
- perror("vkill: vc_ctx_kill()");
- return 1;
- }
- return 0;
-}
-#endif
-
-
-int main(int argc, char *argv[])
-{
- int fail = 0;
- struct Arguments args = {
- .xid = VC_NOCTX,
- .sig = SIGTERM,
- };
-
- while (1) {
- int c = getopt_long(argc, argv, "c:s:", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case 'c' : args.xid = Evc_xidopt2xid(optarg,true); break;
- case 's' : args.sig = str2sig(optarg); break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- if (args.sig==-1) {
- WRITE_MSG(2, "Invalid signal specified\n");
- return EXIT_FAILURE;
- }
-
- if (args.xid==VC_NOCTX && optind==argc) {
- WRITE_MSG(2, "No pid specified\n");
- return EXIT_FAILURE;
- }
-
- if (optind==argc)
- fail += kill_wrapper(args.xid, "0", args.sig);
- else for (;optind<argc;++optind)
- fail += kill_wrapper(args.xid, argv[optind], args.sig);
-
- return fail==0 ? EXIT_SUCCESS : EXIT_FAILURE;
-}
-
-#ifdef TESTSUITE
-void
-vkill_test()
-{
- assert(str2sig("0") ==0 );
- assert(str2sig("1") ==1 );
- assert(str2sig("10")==10);
- assert(str2sig("SIGHUP")==1);
- assert(str2sig("HUP") ==1);
- assert(str2sig("SIGCHLD")==17);
- assert(str2sig("CHLD") ==17);
- assert(str2sig("x")==-1);
- assert(str2sig("1 0")==-1);
-
- return 0;
-}
-#endif
+++ /dev/null
-// $Id$
-
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- Set the global per context limit of a resource (memory, file handle).
- This utility can do it either for the current context or a selected
- one.
-
- It uses the same options as ulimit, when possible
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "compat.h"
-
-#include "vserver.h"
-#include "internal.h"
-#include "util.h"
-
-#include <getopt.h>
-#include <string.h>
-#include <unistd.h>
-#include <assert.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <libgen.h>
-#include <sys/resource.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <ctype.h>
-
-#define ENSC_WRAPPERS_PREFIX "vlimit: "
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_VSERVER 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-#define CMD_XID 0x4000
-#define CMD_DIR 0x8000
-#define CMD_MISSINGOK 0x8001
-
-int wrapper_exit_code = 255;
-
-#define NUMLIM(X) \
-{ #X, required_argument, 0, 2048|X }
-#define OPT_RESLIM(RES,V) \
- { #RES, required_argument, 0, 2048|RLIMIT_##V }
-
-static struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "all", no_argument, 0, 'a' },
- { "xid", required_argument, 0, CMD_XID },
- { "dir", required_argument, 0, CMD_DIR },
- { "missingok", no_argument, 0, CMD_MISSINGOK },
- NUMLIM( 0), NUMLIM( 1), NUMLIM( 2), NUMLIM( 3),
- NUMLIM( 4), NUMLIM( 5), NUMLIM( 6), NUMLIM( 7),
- NUMLIM( 8), NUMLIM( 9), NUMLIM(10), NUMLIM(11),
- NUMLIM(12), NUMLIM(13), NUMLIM(14), NUMLIM(15),
- NUMLIM(16), NUMLIM(17), NUMLIM(18), NUMLIM(19),
- NUMLIM(20), NUMLIM(21), NUMLIM(22), NUMLIM(23),
- NUMLIM(24), NUMLIM(25), NUMLIM(26), NUMLIM(27),
- NUMLIM(28), NUMLIM(29), NUMLIM(30), NUMLIM(31),
- OPT_RESLIM(cpu, CPU),
- OPT_RESLIM(fsize, FSIZE),
- OPT_RESLIM(data, DATA),
- OPT_RESLIM(stack, STACK),
- OPT_RESLIM(core, CORE),
- OPT_RESLIM(rss, RSS),
- OPT_RESLIM(nproc, NPROC),
- OPT_RESLIM(nofile, NOFILE),
- OPT_RESLIM(memlock, MEMLOCK),
- OPT_RESLIM(as, AS),
- OPT_RESLIM(locks, LOCKS),
- { 0,0,0,0 }
-};
-
-#define REV_RESLIM(X) [RLIMIT_##X] = #X
-static char const * const LIMIT_STR[] = {
- REV_RESLIM(CPU), REV_RESLIM(FSIZE), REV_RESLIM(DATA), REV_RESLIM(STACK),
- REV_RESLIM(CORE), REV_RESLIM(RSS), REV_RESLIM(NPROC), REV_RESLIM(NOFILE),
- REV_RESLIM(MEMLOCK), REV_RESLIM(AS), REV_RESLIM(LOCKS)
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- VSERVER_DECLARE_CMD(cmd);
-
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--xid|-c <xid>] [-nd] [-a|--all] [[-MSH] --(<resource>|<nr>) <value>]*\n"
- " [--dir <pathname> [--missingok]] [--] [<program> <args>*]\n\n"
- "Options:\n"
- " -c|--xid <xid>\n"
- " ... operate on context <xid>\n"
- " -a|--all ... show all available limits\n"
- " -n ... do not resolve limit-names\n"
- " -d ... show limits in decimal\n"
- " -M ... set Minimum limit\n"
- " -S ... set Soft limit\n"
- " -H ... set Hard limit (assumed by default, when neither\n"
- " M nor S was requested)\n"
- " --dir <pathname>\n"
- " ... read limits from <pathname>/; allowed filenames are\n"
- " <resource> and <resource>.{min,soft,hard}. When a limit\n"
- " was set by the CLI already, the corresponding file\n"
- " will be ignored\n"
- " --missingok ... do not fail when <pathname> does not exist\n"
- " --<resource>|<nr> <value>\n"
- " ... set specified (MSH) limit for <resource> to <value>\n\n"
- "Valid values for resource are cpu, fsize, data, stack, core, rss, nproc,\n"
- "nofile, memlock, as and locks.\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vlimit " VERSION " -- limits context-resources\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static size_t
-fmtHex(char *ptr, vc_limit_t lim)
-{
- memcpy(ptr, "0x", 2);
- return utilvserver_fmt_xuint64(ptr+2, lim) + 2;
-}
-
-static bool do_resolve = true;
-static size_t (*fmt_func)(char *, vc_limit_t) = fmtHex;
-
-static void *
-appendLimit(char *ptr, bool do_it, vc_limit_t lim)
-{
- memcpy(ptr, " ", 2);
- ptr += 2;
- if (do_it) {
- if (lim==VC_LIM_INFINITY) {
- strcpy(ptr, "inf");
- ptr += 3;
- }
- else {
- ptr += (*fmt_func)(ptr, lim);
- *ptr = ' ';
- }
- }
- else {
- memcpy(ptr, "N/A", 3);
- ptr += 3;
- }
-
- return ptr;
-}
-
-static void
-showAll(int ctx)
-{
- struct vc_rlimit_mask mask;
- size_t i;
-
- if (vc_get_rlimit_mask(ctx, &mask)==-1) {
- perror("vc_get_rlimit_mask()");
- exit(wrapper_exit_code);
- }
-
- for (i=0; i<32; ++i) {
- uint32_t bitmask = (1<<i);
- struct vc_rlimit limit;
- char buf[128], *ptr=buf;
-
- if (((mask.min|mask.soft|mask.hard) & bitmask)==0) continue;
- if (vc_get_rlimit(ctx, i, &limit)==-1) {
- perror("vc_get_rlimit()");
- //continue;
- }
-
- memset(buf, ' ', sizeof buf);
- if (do_resolve && i<DIM_OF(LIMIT_STR)) {
- size_t l = strlen(LIMIT_STR[i]);
- memcpy(ptr, LIMIT_STR[i], l);
- ptr += l;
- }
- else {
- ptr += utilvserver_fmt_uint(ptr, i);
- *ptr = ' ';
- }
-
- ptr = appendLimit(buf+10, mask.min &bitmask, limit.min);
- ptr = appendLimit(buf+30, mask.soft&bitmask, limit.soft);
- ptr = appendLimit(buf+50, mask.hard&bitmask, limit.hard);
-
- *ptr++ = '\n';
- Vwrite(1, buf, ptr-buf);
- }
-}
-
-static void
-setLimits(int ctx, struct vc_rlimit const limits[], uint32_t mask)
-{
- size_t i;
- for (i=0; i<32; ++i) {
- if ((mask & (1<<i))==0) continue;
- if (vc_set_rlimit(ctx, i, limits+i)) {
- perror("vc_set_rlimit()");
- }
- }
-}
-
-static vc_limit_t
-readValue(int fd, char const *filename)
-{
- char buf[128];
- size_t len = Eread(fd, buf, sizeof(buf)-1);
- vc_limit_t res;
-
- buf[len] = '\0';
-
- if (!vc_parseLimit(buf, &res)) {
- WRITE_MSG(2, "Invalid limit in '");
- WRITE_STR(2, filename);
- WRITE_STR(2, "'\n");
- exit(wrapper_exit_code);
- }
-
- return res;
-}
-
-static bool
-readFile(char const *file, char *base, char const *suffix,
- vc_limit_t *limit)
-{
- int fd;
-
- strcpy(base, suffix);
- fd = open(file, O_RDONLY);
- if (fd!=-1) {
- *limit = readValue(fd, file);
- Eclose(fd);
- }
-
- return fd!=-1;
-}
-
-static void
-readFromDir(struct vc_rlimit limits[32], uint_least32_t *mask,
- char const *pathname, bool missing_ok)
-{
- struct stat st;
- size_t i;
- size_t l_pathname = strlen(pathname);
- char buf[l_pathname + sizeof("/memlock.hard") + 32];
-
- if (stat(pathname, &st)==-1) {
- if (errno==ENOENT && missing_ok) return;
- PERROR_Q("vlimit: fstat", pathname);
- exit(wrapper_exit_code);
- }
-
- memcpy(buf, pathname, l_pathname);
- if (l_pathname>0 && pathname[l_pathname-1]!='/')
- buf[l_pathname++] = '/';
-
- for (i=0; i<DIM_OF(LIMIT_STR); ++i) {
- size_t l_res;
- char * ptr = buf+l_pathname;
-
- // ignore unimplemented limits
- if (LIMIT_STR[i]==0) continue;
-
- // ignore limits set on cli already
- if (*mask & (1<<i)) continue;
-
- l_res = strlen(LIMIT_STR[i]);
- memcpy(ptr, LIMIT_STR[i], l_res+1);
- while (*ptr) {
- *ptr = tolower(*ptr);
- ++ptr;
- }
-
- if (readFile(buf, ptr, "", &limits[i].min)) {
- limits[i].soft = limits[i].hard = limits[i].min;
- *mask |= (1<<i);
- }
-
- if (readFile(buf, ptr, ".min", &limits[i].min))
- *mask |= (1<<i);
-
- if (readFile(buf, ptr, ".soft", &limits[i].soft))
- *mask |= (1<<i);
-
- if (readFile(buf, ptr, ".hard", &limits[i].hard))
- *mask |= (1<<i);
- }
-}
-
-int main (int argc, char *argv[])
-{
- // overall used limits
- uint32_t lim_mask = 0;
- int set_mask = 0;
- struct vc_rlimit limits[32];
- bool show_all = false;
- xid_t ctx = VC_NOCTX;
- char const * dir = 0;
- bool missing_ok = false;
-
- {
- size_t i;
- for (i=0; i<32; ++i) {
- limits[i].min = VC_LIM_KEEP;
- limits[i].soft = VC_LIM_KEEP;
- limits[i].hard = VC_LIM_KEEP;
- }
- }
-
- while (1) {
- int c = getopt_long(argc, argv, "+MSHndac:", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- if (2048<=c && c<2048+32) {
- int id = c-2048;
- vc_limit_t val;
-
- if (!vc_parseLimit(optarg, &val)) {
- WRITE_MSG(2, "Can not parse limit '");
- WRITE_STR(2, optarg);
- WRITE_STR(2, "'\n");
- exit(wrapper_exit_code);
- }
-
- if (set_mask==0) set_mask=4;
-
- if (set_mask & 1) limits[id].min = val;
- if (set_mask & 2) limits[id].soft = val;
- if (set_mask & 4) limits[id].hard = val;
-
- lim_mask |= (1<<id);
- set_mask = 0;
- }
- else switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case 'a' : show_all = true; break;
- case 'n' : do_resolve = false; break;
- case CMD_DIR : dir = optarg; break;
- case CMD_MISSINGOK: missing_ok = true; break;
- case CMD_XID : /*@fallthrough@*/
- case 'c' : ctx = Evc_xidopt2xid(optarg,true); break;
- case 'd' : fmt_func = utilvserver_fmt_uint64; break;
- case 'M' :
- case 'S' :
- case 'H' :
- switch (c) {
- case 'M' : set_mask |= 1; break;
- case 'S' : set_mask |= 2; break;
- case 'H' : set_mask |= 4; break;
- default : assert(false);
- }
- break;
-
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- exit(wrapper_exit_code) ;
- break;
- }
- }
-
- if (ctx==VC_NOCTX)
- ctx = Evc_get_task_xid(0);
-
- if (dir)
- readFromDir(limits, &lim_mask, dir, missing_ok);
-
- setLimits(ctx, limits, lim_mask);
- if (show_all) showAll(ctx);
-
- if (optind<argc)
- EexecvpD(argv[optind], argv+optind);
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-#include <lib_internal/sys_clone.h>
-
-#include <vserver.h>
-
-#include <getopt.h>
-#include <libgen.h>
-#include <errno.h>
-#include <signal.h>
-#include <sched.h>
-
-#define ENSC_WRAPPERS_PREFIX "vnamespace: "
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_VSERVER 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-
-int wrapper_exit_code = 255;
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "new", no_argument, 0, 'n' },
- { "enter", required_argument, 0, 'e' },
- { "set", no_argument, 0, 's' },
- { "cleanup", no_argument, 0, 'c' },
- {0,0,0,0}
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " <operation> [--] [<program> <args>*]\n"
- "\n"
- "<operation> can be one of:\n"
- " --new|-n ... create new namespace and execute <program> there;\n"
- " <program> is mandatory in this case\n"
- " --enter|-e <xid> ... enter the namespace of context <xid> and execute\n"
- " <program> there; <program> is mandatory in this\n"
- " case\n"
- " --set|-s ... make current namespace the namespace of the\n"
- " current context\n"
- " --cleanup|-c ... remove all mounts from the namespace of the\n"
- " current context\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vnamespace " VERSION " -- manages filesystem-namespace\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-newNamespace(char const *cmd)
-{
- pid_t pid;
-
- signal(SIGCHLD, SIG_DFL);
-
-#ifdef NDEBUG
- pid = sys_clone(CLONE_NEWNS|CLONE_VFORK|SIGCHLD, 0);
-#else
- pid = sys_clone(CLONE_NEWNS|SIGCHLD, 0);
-#endif
-
- switch (pid) {
- case -1 :
- perror("vnamespace: clone()");
- exit(wrapper_exit_code);
- case 0 :
- break;
- default :
- exitLikeProcess(pid, cmd, wrapper_exit_code);
- }
-}
-
-static void
-enterNamespace(xid_t xid)
-{
- if (vc_enter_namespace(xid)==-1) {
- perror("vnamespace: vc_enter_namespace()");
- exit(255);
- }
-}
-
-static void
-setNamespace()
-{
- if (vc_set_namespace()==-1) {
- perror("vnamespace: vc_set_namespace()");
- exit(255);
- }
-}
-
-static void
-cleanupNamespace()
-{
- if (vc_cleanup_namespace()==-1) {
- perror("vnamespace: vc_cleanup_namespace()");
- exit(255);
- }
-}
-
-int main(int argc, char *argv[])
-{
- bool do_new = false;
- bool do_enter = false;
- bool do_set = false;
- bool do_cleanup = false;
- xid_t xid = VC_NOCTX;
- int sum = 0;
-
- while (1) {
- int c = getopt_long(argc, argv, "+nsce:", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case 'n' : do_new = true; break;
- case 's' : do_set = true; break;
- case 'c' : do_cleanup = true; break;
- case 'e' :
- do_enter = true;
- xid = Evc_xidopt2xid(optarg,true);
- break;
-
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return 255;
- break;
- }
- }
-
- sum = ((do_new ? 1 : 0) + (do_enter ? 1 : 0) +
- (do_set ? 1 : 0) + (do_cleanup ? 1 : 0));
-
- if (sum==0)
- WRITE_MSG(2, "No operation was specified; try '--help' for more information\n");
- else if (sum>1)
- WRITE_MSG(2, "Can not specify multiple operations; try '--help' for more information\n");
- else if (optind==argc && (do_new || do_enter))
- WRITE_MSG(2, "No command specified; try '--help' for more information\n");
- else {
- if (do_new) newNamespace(argv[optind]);
- else if (do_set) setNamespace();
- else if (do_cleanup) cleanupNamespace();
- else if (do_enter) enterNamespace(xid);
-
- if (optind<argc)
- EexecvpD(argv[optind], argv+optind);
-
- return EXIT_SUCCESS;
- }
-
- return 255;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-#include "pathconfig.h"
-
-#include <lib/vserver.h>
-#include <lib/fmt.h>
-#include <assert.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_STDLIB 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#include <wrappers.h>
-
-#define CTXNR_WIDTH 5
-#define HUNK_SIZE 0x4000
-#define CONTEXT_WIDTH 20
-#define CONTEXT_PLACE " "
-
-int wrapper_exit_code = 254;
-
-struct ContextMapping {
- xid_t ctx;
- char const * id;
-};
-
-static struct ContextMapping *mapping = 0;
-static size_t mapping_len = 0;
-
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " <ps-opts>*\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vps " VERSION " -- shows processes in vserver-contexts\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-
-static size_t
-writeContextInfo(xid_t ctx, char const *name)
-{
- size_t l1 = name==0 ? 0 : strlen(name);
- size_t res = CTXNR_WIDTH + 1;
-
- if (ctx==VC_NOCTX) {
- if (3<CTXNR_WIDTH) Vwrite(1, CONTEXT_PLACE, CTXNR_WIDTH-3);
- Vwrite(1, "ERR ", 4);
- }
- else {
- char buf[sizeof(ctx)*3+1];
- size_t l = utilvserver_fmt_ulong(buf, ctx);
-
- if (l<CTXNR_WIDTH) Vwrite(1, CONTEXT_PLACE, CTXNR_WIDTH-l);
- Vwrite(1, buf, l);
- Vwrite(1, " ", 1);
- }
-
- if (l1!=0) {
- assert(name!=0);
- Vwrite(1, name, l1);
- }
-
- return res+l1;
-}
-
-static xid_t
-extractCtx(char *pid_str)
-{
- pid_t pid;
-
- while (*pid_str==' ') ++pid_str;
- pid = atoi(pid_str);
-
- return vc_get_task_xid(pid);
-}
-
-static char const *
-resolveCtx(xid_t ctx)
-{
- char const * res;
- size_t i;
-
- for (i=0; i<mapping_len; ++i)
- if (mapping[i].ctx==ctx) return mapping[i].id;
-
- ++mapping_len;
- mapping = Erealloc(mapping, mapping_len * sizeof(mapping[0]));
-
- if (ctx==0) res = strdup("MAIN");
- else if (ctx==1) res = strdup("ALL_PROC");
- else {
- vcCfgStyle style = vcCFG_AUTO;
- char *tmp = vc_getVserverByCtx(ctx, &style,0);
- if (tmp) res = vc_getVserverName(tmp, style);
- else res = 0;
- free(tmp);
- }
-
- mapping[mapping_len-1].ctx = ctx;
- mapping[mapping_len-1].id = res;
- return res;
-}
-
-static char *
-readOutput(int fd, size_t *total_len)
-{
- size_t len = 2*HUNK_SIZE;
- char *buf = Emalloc(len+1);
- size_t offset = 0;
-
- for (;;) {
- size_t l;
-
- while (offset >= len) {
- len += HUNK_SIZE;
- buf = Erealloc(buf, len+1);
- }
-
- l = Eread(fd, buf+offset, len - offset);
- if (l==0) break;
-
- offset += l;
- }
-
- buf[offset] = '\0';
-
- if (total_len)
- *total_len = offset;
-
- return buf;
-}
-
-static void
-processOutput(char *data, size_t len)
-{
- size_t pid_end;
- char * eol_pos = strchr(data, '\n');
- char * pos;
-
- if (eol_pos==0) eol_pos = data + len;
- else *eol_pos = '\0';
-
- pos = strstr(data, "PID");
- if (pos==0) {
- WRITE_MSG(2, "Failed to parse ps-output\n");
- exit(wrapper_exit_code);
- }
-
- pid_end = pos-data + 4;
-
- Vwrite(1, data, pid_end);
- Vwrite(1, "CONTEXT" CONTEXT_PLACE, CONTEXT_WIDTH);
- Vwrite(1, data+pid_end, eol_pos-(data+pid_end));
- Vwrite(1, "\n", 1);
-
- len -= eol_pos-data;
- data = eol_pos+1;
-
- while (len > 1) {
- char const *vserver_name = 0;
- xid_t ctx;
- size_t l;
-
- --len;
- eol_pos = strchr(data, '\n');
-
- if (eol_pos==0) eol_pos = data + len;
-
- ctx = extractCtx(data + pid_end - 6);
- vserver_name = resolveCtx(ctx);
-
- Vwrite(1, data, pid_end);
- l = writeContextInfo(ctx, vserver_name);
- if (l<CONTEXT_WIDTH) Vwrite(1, CONTEXT_PLACE, CONTEXT_WIDTH-l);
- else Vwrite(1, " ", 1);
- Vwrite(1, data+pid_end, eol_pos-(data+pid_end));
- Vwrite(1, "\n", 1);
-
- len -= eol_pos-data;
- data = eol_pos+1;
- }
-}
-
-int main(int argc, char *argv[])
-{
- int p[2];
- pid_t pid;
- char * data;
- size_t len;
- char const * errptr;
-
- if (argc>1) {
- if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0], 0);
- if (strcmp(argv[1], "--version")==0) showVersion();
- }
-
- signal(SIGCHLD, SIG_DFL);
-
- if (!switchToWatchXid(&errptr)) {
- perror(errptr);
- exit(wrapper_exit_code);
- }
-
- if (access("/proc/uptime",R_OK)==-1 && errno==ENOENT)
- WRITE_MSG(2,
- "WARNING: can not access /proc/uptime. Usually, this is caused by\n"
- " procfs-security. Please read the FAQ for more details\n"
- " http://www.linux-vserver.org/index.php?page=Linux-Vserver+FAQ\n");
-
- Epipe(p);
- pid = Efork();
-
- if (pid==0) {
- int fd = Eopen("/dev/null", O_RDONLY, 0);
- Edup2(fd, 0);
- Edup2(p[1], 1);
- Eclose(p[0]);
- Eclose(p[1]);
- Eclose(fd);
-
- argv[0] = "ps";
-
- Eexecv(PS_PROG, argv);
- }
-
- Eclose(p[1]);
- data = readOutput(p[0], &len);
- Eclose(p[0]);
-
- processOutput(data, len);
- exitLikeProcess(pid, "ps", wrapper_exit_code);
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on vreboot.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- Used to send a reboot message to the reboot manager. It opens /dev/reboot
- and write "reboot\n".
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <stdbool.h>
-
-/*
- Connect to a unix domain socket
-*/
-static int vreboot_connect (const char *sockpath, bool showerror)
-{
- int ret = -1;
- int fd = socket (AF_UNIX,SOCK_STREAM,0);
- if (fd == -1){
- if (showerror) perror("socket client");
- }else{
- struct sockaddr_un un;
- int s;
-
- un.sun_family = AF_UNIX;
- strcpy (un.sun_path,sockpath);
- s = connect(fd,(struct sockaddr*)&un,sizeof(un));
- if (s == -1){
- if (showerror) fprintf (stderr,"connect %s (%s)\n"
- ,sockpath,strerror(errno));
- }else{
- ret = fd;
- }
- }
- return ret;
-}
-
-static void usage()
-{
- fprintf (stderr,"vreboot version %s\n",VERSION);
- fprintf (stderr,"\n");
- fprintf (stderr,"vreboot [ --socket path ]\n");
- fprintf (stderr,"vhalt [ --socket path ]\n");
- fprintf (stderr,"vreboot request a reboot or a halt of a virtual server\n");
-}
-
-int main (int argc, char *argv[])
-{
- int ret = -1;
- int i;
- const char *sockpath = "/dev/reboot";
- for (i=1; i<argc; i++){
- const char *arg = argv[i];
- const char *opt = argv[i+1];
- if (strcmp(arg,"--socket")==0){
- sockpath = opt;
- i++;
- }else if (strcmp(arg,"--help")==0){
- break;
-
- }else{
- fprintf (stderr,"Invalid option %s\n",arg);
- break;
- }
- }
- if (argc != i){
- usage();
- }else{
- int fd = vreboot_connect (sockpath,true);
- if (fd != -1){
- if (strstr(argv[0],"halt")!=NULL){
- write (fd,"halt\n",5);
- }else{
- write (fd,"reboot\n",7);
- }
- close (fd);
- ret = 0;
- }
- }
- return ret;
-}
-
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-
-#include <getopt.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_IOCTL 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 1;
-
-
-#define VROOT_SET_DEV 0x5600
-#define VROOT_CLR_DEV 0x5601
-#define VROOT_INC_USE 0x56FE
-#define VROOT_DEC_USE 0x56FF
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, 'h' },
- { "version", no_argument, 0, 'v' },
- { 0,0,0,0 }
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [-dID] <rootdev>\n"
- " or ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " <rootdev> <real-rootdev>\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vrsetup " VERSION " -- set up and control vroot devices\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-
-int main(int argc, char *argv[])
-{
- bool do_delete = false;
- bool do_decrement = false;
- bool do_increment = false;
- bool do_setup = false;
- char const * root_device = 0;
- char const * real_root_device = 0;
- int fd;
-
- while (1) {
- int c = getopt_long(argc, argv, "dID", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case 'h' : showHelp(1, argv[0], 0);
- case 'v' : showVersion();
- case 'd' : do_delete = true; break;
- case 'D' : do_decrement = true; break;
- case 'I' : do_increment = true; break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- do_setup = !(do_delete || do_decrement || do_increment);
-
- if (optind+1>argc) {
- WRITE_MSG(2, "No vroot-device given\n");
- return EXIT_FAILURE;
- }
-
- if (do_setup && optind+2>argc) {
- WRITE_MSG(2, "No real root-device given\n");
- return EXIT_FAILURE;
- }
-
- root_device = argv[optind];
- if (do_setup) real_root_device = argv[optind+1];
-
- fd = EopenD(root_device, O_RDONLY, 0);
- if (do_increment) Eioctl(fd, VROOT_INC_USE, 0);
- else if (do_decrement) Eioctl(fd, VROOT_DEC_USE, 0);
- else if (do_delete) Eioctl(fd, VROOT_CLR_DEV, 0);
- else {
- int dfd = EopenD(real_root_device, O_RDONLY, 0);
- Eioctl(fd, VROOT_SET_DEV, (void*)dfd);
- Eclose(dfd);
- }
-
- Eclose(fd);
- return EXIT_SUCCESS;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-#include "vserver.h"
-
-#include <errno.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <libgen.h>
-
-#define ENSC_WRAPPERS_PREFIX "vsched: "
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-#define CMD_XID 0x4000
-#define CMD_FRATE 0x4001
-#define CMD_INTERVAL 0x4002
-#define CMD_TOKENS 0x4003
-#define CMD_TOK_MIN 0x4004
-#define CMD_TOK_MAX 0x4005
-#define CMD_CPU_MASK 0x4006
-#define CMD_PRIO_BIAS 0x4007
-
-int wrapper_exit_code = 255;
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "ctx", required_argument, 0, CMD_XID },
- { "xid", required_argument, 0, CMD_XID },
- { "fill-rate", required_argument, 0, CMD_FRATE },
- { "interval", required_argument, 0, CMD_INTERVAL },
- { "tokens", required_argument, 0, CMD_TOKENS },
- { "tokens_min", required_argument, 0, CMD_TOK_MIN },
- { "tokens-min", required_argument, 0, CMD_TOK_MIN },
- { "tokens_max", required_argument, 0, CMD_TOK_MAX },
- { "tokens-max", required_argument, 0, CMD_TOK_MAX },
- { "prio_bias", required_argument, 0, CMD_PRIO_BIAS },
- { "prio-bias", required_argument, 0, CMD_PRIO_BIAS },
- { "priority_bias", required_argument, 0, CMD_PRIO_BIAS },
- { "priority-bias", required_argument, 0, CMD_PRIO_BIAS },
- { "cpu_mask", required_argument, 0, CMD_CPU_MASK },
- {0,0,0,0}
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- VSERVER_DECLARE_CMD(cmd);
-
- WRITE_MSG(fd, "Usage:\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--xid <xid>] [--fill-rate <rate>] [--interval <interval>] [--tokens <tokens>] [--tokens-min <tokens>] [--tokens-max <tokens>] [--prio-bias <bias>] [--] [<command> <args>*]\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vsched " VERSION " -- modifies scheduling parameters\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003,2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-#define SETVAL(ATTR,MASK) \
- sched.ATTR = atoi(optarg); \
- sched.set_mask |= MASK;
-
-int main(int argc, char *argv[])
-{
- xid_t xid = VC_NOCTX;
- struct vc_set_sched sched = {
- .set_mask = 0
- };
-
- while (1) {
- int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_XID : xid = Evc_xidopt2xid(optarg,true); break;
- case CMD_FRATE : SETVAL(fill_rate, VC_VXSM_FILL_RATE); break;
- case CMD_INTERVAL : SETVAL(interval, VC_VXSM_INTERVAL); break;
- case CMD_TOKENS : SETVAL(tokens, VC_VXSM_TOKENS); break;
- case CMD_TOK_MIN : SETVAL(tokens_min, VC_VXSM_TOKENS_MIN); break;
- case CMD_TOK_MAX : SETVAL(tokens_max, VC_VXSM_TOKENS_MAX); break;
- case CMD_PRIO_BIAS: SETVAL(priority_bias, VC_VXSM_PRIO_BIAS); break;
- case CMD_CPU_MASK :
- WRITE_MSG(2, "vsched: WARNING: the '--cpu_mask' parameter is deprecated and will not have any effect\n");
- break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- if (xid==VC_NOCTX && optind==argc) {
- WRITE_MSG(2, "Without a program, '--xid' must be used; try '--help' for more information\n");
- exit(wrapper_exit_code);
- }
-
- if (sched.set_mask==0 && optind==argc) {
- WRITE_MSG(2, "Neither an option nor a program was specified; try '--help' for more information\n");
- exit(wrapper_exit_code);
- }
-
- if (xid==VC_NOCTX)
- xid = Evc_get_task_xid(0);
-
- if (sched.set_mask!=0 && vc_set_sched(xid, &sched)==-1) {
- perror("vc_set_sched()");
- exit(255);
- }
-
- if (optind<argc)
- EexecvpD(argv[optind],argv+optind);
-
- return EXIT_SUCCESS;
-}
+++ /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 "lib/utils-legacy.h"
-#include "pathconfig.h"
-#include "util.h"
-
-#include "internal.h"
-#include "vserver.h"
-
-#include <stdlib.h>
-#include <getopt.h>
-#include <assert.h>
-#include <stdbool.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/utsname.h>
-#include <dirent.h>
-#include <strings.h>
-
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_IO 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_VSERVER 1
-#include <wrappers.h>
-
-#undef _POSIX_SOURCE
-#include "capability-compat.h"
-
-typedef enum { tgNONE,tgCONTEXT, tgID, tgRUNNING,
- tgVDIR, tgNAME, tgCFGDIR, tgAPPDIR,
- tgAPIVER, tgPXID,
- tgINITPID, tgINITPID_PID,
- tgXID, tgUTS, tgSYSINFO,
- tgFEATURE, tgCANONIFY,
- tgVERIFYCAP, tgXIDTYPE,
-} VserverTag;
-
-static struct {
- char const * const tag;
- VserverTag const val;
- char const * const descr;
-} const TAGS[] = {
- { "CONTEXT", tgCONTEXT, ("the current and/or assigned context; when an optinal argument "
- "evaluates to false,only the current context will be printed") },
- { "ID", tgID, "gives out the vserver-id for the context-xid" },
- { "RUNNING", tgRUNNING, "gives out '1' when vserver is running; else, it fails without output" },
- { "VDIR", tgVDIR, "gives out the root-directory of the vserver" },
- { "NAME", tgNAME, "gives out the name of the vserver" },
- { "CFGDIR", tgCFGDIR, "gives out the configuration directory of the vserver" },
- { "APPDIR", tgAPPDIR, "gives out the name of the toplevel application cfgdir" },
- { "INITPID", tgINITPID, "gives out the initpid of the given context" },
- { "INITPID_PID", tgINITPID_PID, "gives out the initpid of the given pid" },
- { "XID", tgXID, "gives out the context-id of the given pid" },
- { "APIVER", tgAPIVER, "gives out the version of the kernel API" },
- { "UTS", tgUTS, ("gives out an uts-entry; possible entries are "
- "context, sysname, nodename, release, version, "
- "machine and domainname") },
- { "SYSINFO", tgSYSINFO, "gives out information about the systen" },
- { "FEATURE", tgFEATURE, "returns 0 iff the queried feature is supported" },
- { "PXID", tgPXID, "returns the xid of the parent context" },
- { "CANONIFY", tgCANONIFY, "canonifies the vserver-name and removes dangerous characters" },
- { "VERIFYCAP", tgVERIFYCAP, "test if the kernel supports linux capabilities" },
- { "XIDTYPE", tgXIDTYPE, "returns the type of the given XID" },
-};
-
-int wrapper_exit_code = 1;
-
-static struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, 'h' },
- { "version", no_argument, 0, 'v' },
- { 0,0,0,0 }
-};
-
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [-ql] <vserver>|<pid>|<context> <tag>\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vserver-info " VERSION " -- returns information about vservers\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-showTags()
-{
- char const * delim = "";
- size_t i;
-
- WRITE_MSG(1, "Valid tags are: ");
- for (i=0; i<DIM_OF(TAGS); ++i) {
- WRITE_STR(1, delim);
- WRITE_STR(1, TAGS[i].tag);
-
- delim = ", ";
- }
- WRITE_MSG(1, "\n");
- exit(0);
-}
-
-static VserverTag
-stringToTag(char const *str)
-{
- size_t i;
- for (i=0; i<DIM_OF(TAGS); ++i)
- if (strcmp(TAGS[i].tag, str)==0) return TAGS[i].val;
-
- return tgNONE;
-}
-
-static vc_uts_type
-utsText2Tag(char const *str)
-{
- if (strcmp(str, "context") ==0) return vcVHI_CONTEXT;
- else if (strcmp(str, "sysname") ==0) return vcVHI_SYSNAME;
- else if (strcmp(str, "nodename") ==0) return vcVHI_NODENAME;
- else if (strcmp(str, "release") ==0) return vcVHI_RELEASE;
- else if (strcmp(str, "version") ==0) return vcVHI_VERSION;
- else if (strcmp(str, "machine") ==0) return vcVHI_MACHINE;
- else if (strcmp(str, "domainname")==0) return vcVHI_DOMAINNAME;
- else {
- WRITE_MSG(2, "Unknown UTS tag\n");
- exit(1);
- }
-}
-
-static bool
-verifyCap()
-{
- struct __user_cap_header_struct header;
- struct __user_cap_data_struct user;
- header.version = _LINUX_CAPABILITY_VERSION;
- header.pid = 0;
-
- if (getuid()!=0) {
- WRITE_MSG(2, "'VERIFYCAP' can be executed as root only\n");
- return false;
- }
-
-// if( prctl( PR_SET_KEEPCAPS, 1,0,0,0 ) < 0 ) {
-// perror( "prctl:" );
-// return false;
-// }
-
- if (capget(&header, &user)==-1) {
- perror("capget()");
- return false;
- }
-
- user.effective = 0;
- user.permitted = 0;
- user.inheritable = 0;
-
- if (capset(&header, &user)==-1) {
- perror("capset()");
- return false;
- }
-
- return chroot("/")==-1;
-}
-
-static char *
-getAPIVer(char *buf)
-{
- int v = vc_get_version();
- size_t l;
-
- if (v==-1) return 0;
-
-
- l = utilvserver_fmt_xulong(0, (unsigned int)v);
- memcpy(buf, "0x00000000", 10);
- utilvserver_fmt_xulong(buf+2+8-l, (unsigned int)v);
-
- return buf;
-}
-
-static char *
-getXid(char *buf, char const *pid_str)
-{
- pid_t pid = atoi(pid_str);
- xid_t xid = vc_get_task_xid(pid);
-
- if (xid==VC_NOCTX) perror("vc_get_task_xid()");
- else {
- utilvserver_fmt_long(buf, xid);
- return buf;
- }
-
- return 0;
-}
-
-static char *
-getPXid(char UNUSED *buf, char const UNUSED *vserver)
-{
- // TODO: implement me when available
- return 0;
-}
-
-static char *
-getInitPid_native(char *buf, xid_t xid)
-{
- struct vc_vx_info info;
-
- if (vc_get_vx_info(xid, &info)==-1) perror("vc_get_vx_info()");
- else {
- utilvserver_fmt_long(buf, info.initpid);
- return buf;
- }
-
- return 0;
-}
-
-#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_V11)
-static int
-selectPid(struct dirent const *ent)
-{
- return atoi(ent->d_name)!=0;
-}
-
-static bool
-getInitPid_internal(pid_t pid, xid_t xid, pid_t *res)
-{
- *res = -1;
-
- for (;*res==-1;) {
- size_t bufsize = utilvserver_getProcEntryBufsize();
- char buf[bufsize+1];
- char *pos = 0;
-
- pos = utilvserver_getProcEntry(pid, "\ns_context: ", buf, bufsize);
- if (pos==0 && errno==EAGAIN) continue;
-
- if (pos==0 || (xid_t)atoi(pos)!=xid) return false;
-
- buf[bufsize] = '\0';
- pos = strstr(buf, "\ninitpid: ");
-
- if (pos!=0) {
- pos += sizeof("\ninitpid: ")-1;
- if (strncmp(pos, "none", 4)==0) *res = -1;
- else *res = atoi(pos);
- }
- }
-
- return true;
-}
-
-static char *
-getInitPid_emulated(char *buf, xid_t xid)
-{
- struct dirent **namelist;
- int n;
-
- switchToWatchXid(0); // ignore errors silently...
- n = scandir("/proc", &namelist, selectPid, alphasort);
- if (n<0) perror("scandir()");
- else while (n--) {
- pid_t pid;
- if (!getInitPid_internal(atoi(namelist[n]->d_name), xid, &pid)) continue;
-
- utilvserver_fmt_long(buf, pid);
- return buf;
- }
-
- return 0;
-}
-#endif // VC_ENABLE_API_COMPAT
-
-static char *
-getInitPid(char *buf, xid_t xid)
-{
- if (vc_isSupported(vcFEATURE_VINFO))
- return getInitPid_native(buf, xid);
- else
- return getInitPid_emulated(buf, xid);
-}
-
-static char *
-getInitPidPid(char *buf, char const *vserver)
-{
- struct vc_vx_info info;
- pid_t pid = atoi(vserver);
- xid_t xid = vc_get_task_xid(pid);
-
- if (xid==VC_NOCTX) perror("vc_get_task_xid()");
- else if (vc_get_vx_info(xid, &info)==-1) perror("vc_get_vx_info()");
- else {
- utilvserver_fmt_long(buf, info.initpid);
- return buf;
- }
-
- return 0;
-}
-
-static char *
-getUTS(char *buf, xid_t xid, size_t argc, char * argv[])
-{
- if (argc>0) {
- vc_uts_type type = utsText2Tag(argv[0]);
- if (vc_get_vhi_name(xid, type, buf, sizeof(buf)-1)==-1)
- perror("vc_get_vhi_name()");
- else
- return buf;
- }
- else {
- bool is_passed = false;
- char tmp[128];
-#define APPEND_UTS(TYPE) \
- (((vc_get_vhi_name(xid, TYPE, tmp, sizeof(tmp)-1)!=-1) && (strcat(buf, tmp), strcat(buf, " "), is_passed=true)) || \
- (strcat(buf, "??? ")))
-
- if (APPEND_UTS(vcVHI_CONTEXT) &&
- APPEND_UTS(vcVHI_SYSNAME) &&
- APPEND_UTS(vcVHI_NODENAME) &&
- APPEND_UTS(vcVHI_RELEASE) &&
- APPEND_UTS(vcVHI_VERSION) &&
- APPEND_UTS(vcVHI_MACHINE) &&
- APPEND_UTS(vcVHI_DOMAINNAME) &&
- is_passed)
- return buf;
-
- perror("vc_get_vhi_name()");
-#undef APPEND_UTS
- }
-
- return 0;
-}
-
-static int
-printSysInfo(char *buf)
-{
- int fd = open(PKGLIBDIR "/FEATURES.txt", O_RDONLY);
- struct utsname uts;
-
- if (uname(&uts)==-1)
- perror("uname()");
- else {
- WRITE_MSG(1,
- "Versions:\n"
- " Kernel: ");
- WRITE_STR(1, uts.release);
- WRITE_MSG(1, "\n"
- " VS-API: ");
-
- memset(buf, 0, 128);
- if (getAPIVer(buf)) WRITE_STR(1, buf);
- else WRITE_MSG(1, "???");
-
- WRITE_MSG(1, "\n"
- " util-vserver: " PACKAGE_VERSION "; " __DATE__ ", " __TIME__"\n"
- "\n");
- }
-
- if (fd==-1)
- WRITE_MSG(1, "FEATURES.txt not found\n");
- else {
- off_t l = Elseek(fd, 0, SEEK_END);
- Elseek(fd, 0, SEEK_SET);
- {
- char buf[l];
- EreadAll(fd, buf, l);
- EwriteAll(1, buf, l);
- }
- Eclose(fd);
- }
-
- return EXIT_SUCCESS;
-}
-
-static char *
-getContext(char *buf, char const *vserver, bool allow_only_static)
-{
- xid_t xid = vc_getVserverCtx(vserver, vcCFG_AUTO,
- allow_only_static, 0);
- if (xid==VC_NOCTX) return 0;
-
- utilvserver_fmt_long(buf, xid);
- return buf;
-}
-
-static char const *
-getXIDType(xid_t xid, int argc, char *argv[])
-{
- char const * tp;
-
- switch (vc_getXIDType(xid)) {
- case vcTYPE_INVALID : tp = "invalid"; break;
- case vcTYPE_MAIN : tp = "main"; break;
- case vcTYPE_WATCH : tp = "watch"; break;
- case vcTYPE_STATIC : tp = "static"; break;
- case vcTYPE_DYNAMIC : tp = "dynamic"; break;
- default : tp = 0; break;
- }
-
- if (argc==0 || tp==0)
- return tp;
-
- while (argc>0) {
- --argc;
- if (strcasecmp(argv[argc], tp)==0) return tp;
- }
-
- return 0;
-}
-
-static int
-testFeature(int argc, char *argv[])
-{
- return (argc>0 && vc_isSupportedString(argv[0])) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
-
-static bool
-str2bool(char const *str)
-{
- return atoi(str)!=0 || strchr("yYtY", str[0])!=0 || strcasecmp("true", str)==0;
-}
-
-static int
-execQuery(char const *vserver, VserverTag tag, int argc, char *argv[])
-{
- char const * res = 0;
- char buf[sizeof(xid_t)*4 + 1024 + strlen(vserver)];
-
- memset(buf, 0, sizeof buf);
- switch (tag) {
- case tgNAME : res = vc_getVserverName(vserver, vcCFG_AUTO); break;
- case tgVDIR :
- res = vc_getVserverVdir(vserver, vcCFG_AUTO, argc>0 && atoi(argv[0]));
- break;
- case tgCFGDIR : res = vc_getVserverCfgDir(vserver, vcCFG_AUTO); break;
- case tgAPPDIR :
- res = vc_getVserverAppDir(vserver, vcCFG_AUTO, argc==0 ? "" : argv[0]);
- break;
-
- case tgRUNNING :
- res = (vc_getVserverCtx(vserver, vcCFG_AUTO, false, 0)==VC_NOCTX) ? 0 : "1";
- break;
-
- case tgCANONIFY :
- strcpy(buf, vserver);
- if (canonifyVserverName(buf)>0) res = buf;
- break;
-
- case tgCONTEXT : res = getContext(buf, vserver,
- argc==0 || str2bool(argv[0])); break;
- case tgINITPID_PID : res = getInitPidPid(buf, vserver); break;
- case tgAPIVER : res = getAPIVer(buf); break;
- case tgXID : res = getXid(buf, vserver); break;
- case tgPXID : res = getPXid(buf, vserver); break;
- case tgSYSINFO : return printSysInfo(buf); break;
- case tgFEATURE : return testFeature(argc,argv); break;
- case tgVERIFYCAP : return verifyCap() ? 0 : 1; break;
-
-
- default : {
- xid_t xid = *vserver!='\0' ? vc_xidopt2xid(vserver,true,0) : VC_SAMECTX;
-
- switch (tag) {
- case tgID : res = vc_getVserverByCtx(xid,0,0); break;
- case tgINITPID : res = getInitPid(buf, xid); break;
- case tgUTS : res = getUTS(buf, xid, argc, argv); break;
- case tgXIDTYPE : res = getXIDType(xid, argc, argv); break;
-
- default : assert(false); abort(); // TODO
- }
- }
- }
-
- if (res==0) return EXIT_FAILURE;
- WRITE_STR(1, res);
- WRITE_MSG(1, "\n");
- return EXIT_SUCCESS;
-}
-
-int main(int argc, char *argv[])
-{
- bool quiet = false;
- char const * vserver;
- VserverTag tag;
-
- while (1) {
- int c = getopt_long(argc, argv, "ql", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case 'h' : showHelp(1, argv[0], 0);
- case 'v' : showVersion();
- case 'l' : showTags();
- case 'q' : quiet = true; break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- exit(1);
- break;
- }
- }
-
- if (optind+2>argc) {
- execQuery("-", tgSYSINFO, 0, 0);
- WRITE_MSG(2, "\nAssumed 'SYSINFO' as no other option given; try '--help' for more information.\n");
- exit(0);
- }
-
- vserver = argv[optind];
- tag = stringToTag(argv[optind+1]);
-
- if (tag==tgNONE) {
- WRITE_MSG(2, "Unknown tag; use '-l' to get list of valid tags\n");
- exit(1);
- }
-
- if (quiet) {
- int fd = Eopen("/dev/null", O_WRONLY, 0644);
- Edup2(fd, 1);
- Eclose(fd);
- }
-
- return execQuery(vserver, tag, argc-(optind+2), argv+optind+2);
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on vserver-stat.cc by Guillaum Dallaire and Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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 "vserver.h"
-#include "util.h"
-#include "internal.h"
-
-#include <ensc_vector/vector.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <string.h>
-#include <errno.h>
-#include <syscall.h>
-#include <time.h>
-#include <stdbool.h>
-#include <sys/param.h>
-
-#define ENSC_WRAPPERS_DIRENT 1
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_UNISTD 1
-#include "wrappers.h"
-
-#define PROC_DIR_NAME "/proc"
-#define CTX_DIR_NAME "/var/run/vservers/"
-#define CTX_NAME_MAX_LEN 50
-
-int wrapper_exit_code = 1;
-
-#ifndef AT_CLKTCK
-#define AT_CLKTCK 17 /* frequency of times() */
-#endif
-
-static unsigned long hertz=0x42;
-
-struct XidData
-{
- xid_t xid;
- int process_count;
- int VmSize_total;
- int VmRSS_total;
- uint64_t start_time_oldest;
- uint64_t stime_total, utime_total;
-};
-
-struct process_info
-{
- long VmSize; // number of pages of virtual memory
- long VmRSS; // resident set size from /proc/#/stat
- uint64_t start_time; // start time of process -- milliseconds since 1-1-70
- uint64_t stime, utime; // kernel & user-mode CPU time accumulated by process
- uint64_t cstime, cutime; // cumulative time of process and reaped children
- xid_t s_context;
-};
-
-struct ArgInfo {
- enum { tpUNSET, tpCTX, tpPID } type;
- xid_t ctx;
- pid_t pid;
- unsigned int interval;
- bool shutdown;
- bool omit_init;
- size_t argc;
- char * const * argv;
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- "\n"
- "Show informations about all the active context.\n\n"
- " CTX# Context number\n"
- " #0 = root context\n"
- " #1 = monitoring context\n"
- " PROC QTY Quantity of processes in each context\n"
- " VSZ Number of pages of virtual memory\n"
- " RSS Resident set size\n"
- " userTIME User-mode CPU time accumulated\n"
- " sysTIME Kernel-mode CPU time accumulated\n"
- " UPTIME Uptime/context\n"
- " NAME Virtual server name\n"
- "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vserver-stat " VERSION " -- show virtual context statistics\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-
-// return uptime (in ms) from /proc/uptime
-static uint64_t
-getUptime()
-{
- int fd;
- char buffer[64];
- char * errptr;
- size_t len;
- uint64_t secs;
- uint32_t msecs=0;
-
- // open the /proc/uptime file
- fd = EopenD("/proc/uptime", O_RDONLY, 0);
- len = Eread(fd, buffer, sizeof buffer);
-
- if (len==sizeof(buffer)) {
- WRITE_MSG(2, "Too much data in /proc/uptime; aborting...\n");
- exit(1);
- }
- Eclose(fd);
-
- while (len>0 && buffer[len-1]=='\n') --len;
- buffer[len] = '\0';
-
- secs = strtol(buffer, &errptr, 10);
- if (*errptr!='.') errptr = buffer;
- else {
- unsigned int mult;
- switch (strlen(errptr+1)) {
- case 0 : mult = 1000; break;
- case 1 : mult = 100; break;
- case 2 : mult = 10; break;
- case 3 : mult = 1; break;
- default : mult = 0; break;
- }
- msecs = strtol(errptr+1, &errptr, 10) * mult;
- }
-
- if ((*errptr!='\0' && *errptr!=' ') || errptr==buffer) {
- WRITE_MSG(2, "Bad data in /proc/uptime\n");
- exit(1);
- }
-
- return secs*1000 + msecs;
-}
-
-static int
-cmpData(void const *xid_v, void const *map_v)
-{
- xid_t const * const xid = xid_v;
- struct XidData const * const map = map_v;
- int res = *xid - map->xid;
-
- return res;
-}
-
-static void
-registerXid(struct Vector *vec, struct process_info *process)
-{
- struct XidData *res;
-
- res = Vector_search(vec, &process->s_context, cmpData);
- if (res==0) {
- res = Vector_insert(vec, &process->s_context, cmpData);
- res->xid = process->s_context;
- res->process_count = 0;
- res->VmSize_total = 0;
- res->VmRSS_total = 0;
- res->utime_total = 0;
- res->stime_total = 0;
- res->start_time_oldest = process->start_time;
- }
-
- ++res->process_count;
- res->VmSize_total += process->VmSize;
- res->VmRSS_total += process->VmRSS;
- res->utime_total += process->utime + process->cutime;
- res->stime_total += process->stime + process->cstime;
-
- res->start_time_oldest = MIN(res->start_time_oldest, process->start_time);
-}
-
-static inline uint64_t
-toMsec(uint64_t v)
-{
- return v*1000llu/hertz;
-}
-
-
-// shamelessly stolen from procps...
-static unsigned long
-find_elf_note(unsigned long findme){
- unsigned long *ep = (unsigned long *)environ;
- while(*ep++);
- while(*ep){
- if(ep[0]==findme) return ep[1];
- ep+=2;
- }
- return (unsigned long)(-1);
-}
-
-static void initHertz() __attribute__((__constructor__));
-
-static void
-initHertz()
-{
- hertz = find_elf_note(AT_CLKTCK);
- if (hertz==(unsigned long)(-1))
- hertz = sysconf(_SC_CLK_TCK);
-}
-
-// open the process's status file to get the ctx number, and other stat
-struct process_info *
-get_process_info(char *pid)
-{
- int fd;
- char buffer[1024];
- char *p;
- size_t idx, l=strlen(pid);
- static struct process_info process;
-
-#if 1
- process.s_context = vc_get_task_xid(atoi(pid));
-#else
-# warning Compiling in debug-code
- process.s_context = random()%6;
-#endif
-
- if (process.s_context==VC_NOCTX) {
- int err=errno;
- WRITE_MSG(2, "vc_get_task_xid(");
- WRITE_STR(2, pid);
- WRITE_MSG(2, "): ");
- WRITE_STR(2, strerror(err));
- WRITE_MSG(2, "\n");
-
- return 0;
- }
-
- memcpy(buffer, "/proc/", 6); idx = 6;
- memcpy(buffer+idx, pid, l); idx += l;
- memcpy(buffer+idx, "/stat", 6);
-
- // open the /proc/#/stat file
- if ((fd = open(buffer, O_RDONLY, 0)) == -1)
- return NULL;
- // put the file in a buffer
- if (read(fd, buffer, sizeof(buffer)) < 1)
- return NULL;
-
- close(fd);
-
- p = strchr(buffer, ')'); // go after the PID (process_name)
- for (idx = 0; idx<12 && *p!='\0'; ++p)
- if ((*p)==' ') ++idx;
-
- process.utime = toMsec(strtol(p, &p, 10));
- process.stime = toMsec(strtol(p+1, &p, 10));
- process.cutime = toMsec(strtol(p+1, &p, 10));
- process.cstime = toMsec(strtol(p+1, &p, 10));
-
- for (idx = 0; idx<5 && *p!='\0'; ++p)
- if ((*p)==' ') ++idx;
-
- process.start_time = toMsec(strtol(p, &p, 10));
- process.VmSize = strtol(p+1, &p, 10);
- process.VmRSS = strtol(p+1, &p, 10);
-
- //printf("pid=%s, start_time=%llu\n", pid, process.start_time);
- return &process;
-}
-
-static size_t
-fillUintZero(char *buf, unsigned long val, size_t cnt)
-{
- size_t l;
-
- l = utilvserver_fmt_ulong(buf, val);
- if (l<cnt) {
- memmove(buf+cnt-l, buf, l);
- memset(buf, '0', cnt-l);
- }
- buf[cnt] = '\0';
-
- return cnt;
-}
-
-static void
-shortenMem(char *buf, unsigned long val)
-{
- char const * SUFFIXES[] = { " ", "K", "M", "G", "T", "+" };
- char tmp[16];
- char const * suffix = "+";
- size_t i, l;
- unsigned int mod = 0;
-
- for (i=0; i<6; ++i) {
- if (val<1000) {
- suffix = SUFFIXES[i];
- break;
- }
- mod = 10*(val & 1023)/1024;
- val >>= 10;
- }
-
- if (val >9999) val=9999;
- if (val>=1000) mod=0;
-
- l = utilvserver_fmt_ulong(tmp, val);
- if (mod!=0) {
- tmp[l++] = '.';
- l += utilvserver_fmt_ulong(tmp+l, mod);
- }
- i = 7-l-strlen(suffix);
-
- memcpy(buf+i, tmp, l);
- memcpy(buf+i+l, suffix, strlen(suffix));
-}
-
-static void
-shortenTime(char *buf, uint64_t t)
-{
- char tmp[32];
- char *ptr = tmp;
-
- unsigned long hh, mm, ss, ms;
-
- ms = t % 1000;
- t /= 1000;
-
- ss = t%60;
- t /= 60;
- mm = t%60;
- t /= 60;
- hh = t%60;
- t /= 24;
-
- if (t>999*999) {
- memcpy(ptr, "INVALID", 7);
- ptr += 7;
- }
- else if (t>999) {
- ptr += utilvserver_fmt_ulong(ptr, t/365);
- *ptr++ = 'y';
- ptr += fillUintZero(ptr, t%365, 2);
- *ptr++ = 'd';
- ptr += fillUintZero(ptr, hh, 2);
- }
- else if (t>0) {
- ptr += utilvserver_fmt_ulong(ptr, t);
- *ptr++ = 'd';
- ptr += fillUintZero(ptr, hh, 2);
- *ptr++ = 'h';
- ptr += fillUintZero(ptr, mm, 2);
- }
- else if (hh>0) {
- ptr += utilvserver_fmt_ulong(ptr, hh);
- *ptr++ = 'h';
- ptr += fillUintZero(ptr, mm, 2);
- *ptr++ = 'm';
- ptr += fillUintZero(ptr, ss, 2);
- }
- else {
- ptr += utilvserver_fmt_ulong(ptr, mm);
- *ptr++ = 'm';
- ptr += fillUintZero(ptr, ss, 2);
- *ptr++ = 's';
- ptr += fillUintZero(ptr, ms, 2);
- }
-
- *ptr = ' ';
- memcpy(buf+10-(ptr-tmp), tmp, ptr-tmp);
-}
-
-static void
-showContexts(struct Vector *vec)
-{
- uint64_t uptime = getUptime();
- struct XidData const * ptr = Vector_begin_const(vec);
- struct XidData const * const end_ptr = Vector_end_const(vec);
-
-
- WRITE_MSG(1, "CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME\n");
- for (; ptr<end_ptr; ++ptr) {
- char buf[sizeof(xid_t)*3 + 512];
- char tmp[sizeof(int)*3 + 2];
- size_t l;
-
- memset(buf, ' ', sizeof(buf));
- l = utilvserver_fmt_long(buf, ptr->xid);
- l = utilvserver_fmt_long(tmp, ptr->process_count);
- memcpy(buf+10-l, tmp, l);
-
- shortenMem (buf+10, ptr->VmSize_total);
- shortenMem (buf+17, ptr->VmRSS_total);
- shortenTime(buf+24, ptr->utime_total);
- shortenTime(buf+34, ptr->stime_total);
- //printf("%llu, %llu\n", uptime, ptr->start_time_oldest);
- shortenTime(buf+44, uptime - ptr->start_time_oldest);
-
- switch (ptr->xid) {
- case 0 : strcpy(buf+55, "root server" ); break;
- case 1 : strcpy(buf+55, "monitoring server"); break;
- default : {
- char * name = 0;
- char * cfgpath = 0;
- vcCfgStyle cfgstyle = vcCFG_AUTO;
-
- if ((cfgpath = vc_getVserverByCtx(ptr->xid, &cfgstyle, 0))==0 ||
- (name = vc_getVserverName(cfgpath, cfgstyle))==0) {
- name = strdup("");
- cfgstyle = vcCFG_NONE;
- }
-
- switch (cfgstyle) {
- case vcCFG_LEGACY : {
- size_t len = MIN(strlen(name), 18);
- buf[55] = '[';
- memcpy(buf+56, name, len);
- memcpy(buf+56+len, "]", 2);
- break;
- }
- default : {
- size_t len = MIN(strlen(name), 20);
- memcpy(buf+55, name, len);
- buf[55+len] = '\0';
- break;
- }
- }
-
- free(name);
- free(cfgpath);
- }
- }
-
- Vwrite(1, buf, strlen(buf));
- Vwrite(1, "\n", 1);
- }
-}
-
-int main(int argc, char **argv)
-{
- DIR * proc_dir;
- struct dirent* dir_entry;
- pid_t my_pid;
- struct Vector xid_data;
- char const * errptr;
-
- if (argc==2) {
- if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0], 0);
- if (strcmp(argv[1], "--version")==0) showVersion();
- }
- if (argc!=1) {
- WRITE_MSG(2, "Unknown parameter, use '--help' for more information\n");
- return EXIT_FAILURE;
- }
-
- if (hertz==0x42) initHertz();
-
- //printf("hertz=%lu\n", hertz);
- // do not include own stat
- my_pid = getpid();
-
- if (!switchToWatchXid(&errptr)) {
- perror(errptr);
- exit(1);
- }
-
- if (access("/proc/uptime",R_OK)==-1 && errno==ENOENT)
- WRITE_MSG(2,
- "WARNING: can not access /proc/uptime. Usually, this is caused by\n"
- " procfs-security. Please read the FAQ for more details\n"
- " http://www.linux-vserver.org/index.php?page=Linux-Vserver+FAQ\n");
-
- Vector_init(&xid_data, sizeof(struct XidData));
-
- Echdir(PROC_DIR_NAME);
- proc_dir = Eopendir(".");
- while ((dir_entry = readdir(proc_dir)) != NULL)
- {
- // select only process file
- if (!isdigit(*dir_entry->d_name))
- continue;
-
- if (atoi(dir_entry->d_name) != my_pid) {
- struct process_info * info = get_process_info(dir_entry->d_name);
- if (info)
- registerXid(&xid_data, info);
- }
- }
- closedir(proc_dir);
-
- // output the ctx_list
- showContexts(&xid_data);
-
-#ifndef NDEBUG
- Vector_free(&xid_data);
-#endif
-
- return 0;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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.
-
-
-static uint64_t
-visitDirEntry(struct dirent const *ent);
-
-static uint64_t
-visitDir(char const *name, struct stat const *expected_stat)
-{
- int fd = Eopen(".", O_RDONLY, 0);
- PathInfo old_state = global_info.state;
- PathInfo rhs_path = {
- .d = name,
- .l = strlen(name)
- };
- char new_path[ENSC_PI_APPSZ(global_info.state, rhs_path)];
- DIR * dir;
- uint64_t res = 0;
-
- PathInfo_append(&global_info.state, &rhs_path, new_path);
-
- if (expected_stat!=0)
- EsafeChdir(name, expected_stat);
-
- dir = Eopendir(".");
-
- for (;;) {
- struct dirent *ent = Ereaddir(dir);
- if (ent==0) break;
-
- res += visitDirEntry(ent);
- }
-
- Eclosedir(dir);
-
- Efchdir(fd);
- Eclose(fd);
-
- global_info.state = old_state;
- return res;
-}
+++ /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 "vserver.hh"
-#include "pathconfig.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fstream>
-#include <iostream>
-
-static bool
-dirExists(std::string const &path)
-{
- struct stat st;
- return (stat(path.c_str(), &st)!=-1 &&
- S_ISDIR(st.st_mode));
-}
-
-Vserver::Vserver(std::string const &str) :
- conf_dir_(str), vdir_(str), name_(str)
-{
- vdir_ += "/.vdir";
-
- if (!dirExists(vdir_)) {
- conf_dir_ = CONFDIR;
- conf_dir_ += str;
- }
-
- rpmdb_path_ = conf_dir_;
- rpmdb_path_ += "/apps/pkgmgmt/rpmstate";
-
- if (!dirExists(rpmdb_path_)) {
- rpmdb_path_ = conf_dir_;
- rpmdb_path_ += "/apps/pkgmgmt/base/rpm/state";
- }
-
- if (!dirExists(rpmdb_path_)) {
- rpmdb_path_ = vdir_;
- rpmdb_path_ += "/var/lib/rpm";
- }
-
- std::string tmp = conf_dir_;
- tmp += ".name";
-
- std::ifstream name_file(tmp.c_str());
-
- if (name_file.good()) getline(name_file, name_);
-}
-
-std::ostream &
-operator << (std::ostream &lhs, Vserver const &rhs)
-{
- return lhs << rhs.getName();
-}
+++ /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 HH_UTIL_VSERVER_SRC_VSERVSER_HH
-#define HH_UTIL_VSERVER_SRC_VSERVSER_HH
-
-#include <string>
-#include <ostream>
-
-class Vserver
-{
- public:
- Vserver(std::string const &name);
-
- std::string const & getConfDir() const { return conf_dir_; }
- std::string const & getVdir() const { return vdir_; }
- std::string const & getRPMDbPath() const { return rpmdb_path_; }
- std::string const & getName() const { return name_; }
-
- private:
- std::string conf_dir_;
- std::string vdir_;
- std::string rpmdb_path_;
- std::string name_;
-};
-
-std::ostream & operator << (std::ostream &lhs, Vserver const &rhs);
-
-
-#endif // HH_UTIL_VSERVER_SRC_VSERVSER_HH
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "util.h"
-
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <assert.h>
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [--] <pipe> <timeout>\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vshelper-sync " VERSION " -- waits for data from a pipe"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-int main(int argc, char *argv[])
-{
- int fd;
- int idx = 1;
- struct timeval timeout;
-
- if (argc>=2) {
- if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0], 0);
- if (strcmp(argv[1], "--version")==0) showVersion();
- if (strcmp(argv[1], "--") ==0) ++idx;
- }
-
- if (argc<idx+2) {
- WRITE_MSG(2, "Not enough parameters; use '--help' for more information\n");
- return EXIT_FAILURE;
- }
-
- fd = open(argv[idx], O_RDONLY|O_NONBLOCK, 0);
- if (fd==-1) {
- perror("vshelper-sync: open()");
- return EXIT_FAILURE;
- }
-
- timeout.tv_sec = atoi(argv[idx+1]);
- timeout.tv_usec = 0;
-
- for (;;) {
- char buf[512];
- ssize_t len;
- fd_set fds;
-
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
-
-#ifndef __linux
-# error vshelper relies on the Linux select() behavior (timeout holds remaining time)
-#endif
-
- switch (select(fd+1, &fds, 0,0, &timeout)) {
- case 0 : return EXIT_FAILURE; // timeout
- case -1 :
- perror("vshelper: select()");
- return EXIT_FAILURE;
- default : break;
- }
-
- assert(FD_ISSET(fd, &fds));
-
- len = read(fd,buf,sizeof buf);
- if (len==0) break;
- if (len==-1) {
- perror("vshelper-sync: read()");
- return EXIT_FAILURE;
- }
- }
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver.h"
-#include "util.h"
-
-#include <getopt.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-#include <libgen.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <strings.h>
-
-#define ENSC_WRAPPERS_PREFIX "vuname: "
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_IO 1
-#define ENSC_WRAPPERS_VSERVER 1
-#include <wrappers.h>
-
-#define CMD_HELP 0x1000
-#define CMD_VERSION 0x1001
-#define CMD_DIR 0x4007
-#define CMD_MISSINGOK 0x4008
-
-int wrapper_exit_code = 255;
-
-static vc_uts_type const UTS_MAPPING[7] = {
- vcVHI_CONTEXT, vcVHI_SYSNAME, vcVHI_NODENAME,
- vcVHI_RELEASE, vcVHI_VERSION, vcVHI_MACHINE,
- vcVHI_DOMAINNAME };
-
-#define DECL(UTS) [vcVHI_ ## UTS] = #UTS
-static char const * const UTS_STRINGS[] = {
- DECL(CONTEXT), DECL(SYSNAME), DECL(NODENAME),
- DECL(RELEASE), DECL(VERSION), DECL(MACHINE),
- DECL(DOMAINNAME)
-};
-
-struct Tag {
- bool is_set;
- char const * value;
-};
-
-struct Arguments {
- struct Tag tags[DIM_OF(UTS_MAPPING)];
- xid_t xid;
- bool do_set;
- char const * dir;
- bool is_missingok;
-};
-
-static struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "xid", required_argument, 0, 'x' },
- { "set", no_argument, 0, 's' },
- { "get", no_argument, 0, 'g' },
- { "dir", required_argument, 0, CMD_DIR },
- { "missingok", no_argument, 0, CMD_MISSINGOK },
- { 0,0,0,0 }
-};
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- VSERVER_DECLARE_CMD(cmd);
-
- WRITE_MSG(fd, "Usage: ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [-g] --xid <xid> <TAG>*\n"
- " or ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " -s --xid <xid> -t <TAG>=<VALUE> [--] [<command> <args>*]\n"
- " or ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " --dir <dir> --xid <xid> [--missingok] [--] [<command> <args>*]\n\n"
- " Options:\n"
- " -g ... get and print the value\n"
- " -s ... set the value\n\n"
- " --xid <xid> ... operate on this context; 'self' means the current one\n"
- " -t <TAG>=<VALUE>\n"
- " ... set <TAG> to <VALUE>; this option can be repeated multiple time\n"
- " --dir <dir> ... read values from files in <dir>. These files must\n"
- " have a valid TAG as their name\n"
- " --missingok ... do not fail when the <DIR> from '--dir' does not exist.\n"
- "\n"
- " Possible values for TAG are:\n"
- " context, sysname, nodename, release, version, machine, domainname\n"
- "\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vuname " VERSION " -- modifies and shows uname entries of vserver contexts\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-static void
-setFromDir(char const *pathname, bool is_missingok, xid_t xid)
-{
- struct stat st;
- size_t i;
- size_t l_pathname = strlen(pathname);
- char buf[l_pathname + sizeof("/domainname") + 32];
-
- if (stat(pathname, &st)==-1) {
- if (errno==ENOENT && is_missingok) return;
- PERROR_Q(ENSC_WRAPPERS_PREFIX "fstat", pathname);
- exit(wrapper_exit_code);
- }
-
- memcpy(buf, pathname, l_pathname);
- if (l_pathname>0 && pathname[l_pathname-1]!='/')
- buf[l_pathname++] = '/';
-
- for (i=0; i<DIM_OF(UTS_STRINGS); ++i) {
- char * ptr = buf+l_pathname;
- int fd;
-
- // ignore unimplemented uts-names
- if (UTS_STRINGS[i]==0) continue;
- strcpy(ptr, UTS_STRINGS[i]);
- for (;*ptr;++ptr) *ptr = tolower(*ptr);
- fd = open(buf, O_RDONLY);
- if (fd!=-1) {
- size_t l = Elseek(fd, 0, SEEK_END);
- char name[l+1];
- Elseek(fd,0,SEEK_SET);
- EreadAll(fd, name, l);
- while (l>0 && name[l-1]=='\n') --l;
- name[l] = '\0';
- Eclose(fd);
-
- if (vc_set_vhi_name(xid, (vc_uts_type)(i), name, l)==-1) {
- PERROR_U(ENSC_WRAPPERS_PREFIX "vc_set_vhi_name", UTS_STRINGS[i]);
- exit(wrapper_exit_code);
- }
- }
- }
-}
-
-static size_t
-findUtsIdx(char const *str, size_t len)
-{
- size_t i;
- for (i=0; i<DIM_OF(UTS_STRINGS); ++i)
- if (UTS_STRINGS[i]!=0 && strncasecmp(UTS_STRINGS[i], str, len)==0)
- return i;
-
- WRITE_MSG(2, "Tag '");
- Vwrite (2, str, len);
- WRITE_STR(2, "' not recognized\n");
- exit(wrapper_exit_code);
-}
-
-static void
-registerValue(char const *str, struct Tag tags[DIM_OF(UTS_MAPPING)])
-{
- char const * ptr = strchr(str, '=');
- size_t idx;
-
- if (ptr==0) ptr = str + strlen(str);
- assert(*ptr=='=' || *ptr=='\0');
-
- idx = findUtsIdx(str, ptr-str);
-
- if (*ptr=='=') ++ptr;
- tags[idx].is_set = true;
- tags[idx].value = ptr;
-}
-
-static void
-printUtsValue(xid_t xid, int val)
-{
- char buf[128];
- if (vc_get_vhi_name(xid, val, buf, sizeof(buf)-1)==-1)
- WRITE_MSG(1, "???");
- else
- WRITE_STR(1, buf);
-
-}
-
-int main(int argc, char *argv[])
-{
- struct Arguments args = {
- .tags = { [0] = {false,0} },
- .do_set = false,
- .dir = 0,
- .is_missingok= false,
- .xid = VC_NOCTX,
- };
- size_t i;
-
- assert(DIM_OF(UTS_MAPPING) == DIM_OF(args.tags));
-
- while (1) {
- int c = getopt_long(argc, argv, "+gst:", CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_DIR : args.dir = optarg; break;
- case CMD_MISSINGOK: args.is_missingok = true; break;
- case 'g' : args.do_set = false; break;
- case 's' : args.do_set = true; break;
- case 'x' : args.xid = Evc_xidopt2xid(optarg,true); break;
- case 't' : registerValue(optarg, args.tags); break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- if (args.xid==VC_NOCTX) {
- WRITE_MSG(2, "No context specified; try '--help' for more information\n");
- exit(wrapper_exit_code);
- }
-
- if (args.dir)
- setFromDir(args.dir, args.is_missingok, args.xid);
- else if (args.do_set) {
- for (i=0; i<DIM_OF(args.tags); ++i) {
- if (!args.tags[i].is_set) continue;
- Evc_set_vhi_name(args.xid, i, args.tags[i].value, strlen(args.tags[i].value));
- }
- }
- else if (optind==argc) {
- char const * delim = "";
- for (i=0; i<DIM_OF(UTS_MAPPING); ++i) {
- WRITE_STR(1, delim);
- printUtsValue(args.xid, i);
- delim = " ";
- }
- WRITE_MSG(1, "\n");
-
- return EXIT_SUCCESS;
- }
- else {
- char const * delim = "";
- while (optind <argc) {
- int idx = findUtsIdx(argv[optind], strlen(argv[optind]));
- WRITE_STR(1, delim);
- printUtsValue(args.xid, idx);
- delim = " ";
-
- ++optind;
- }
- WRITE_MSG(1, "\n");
-
- return EXIT_SUCCESS;
- }
-
- if (optind<argc)
- EexecvpD(argv[optind], argv+optind);
-
- return wrapper_exit_code;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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.
-
-#include "pathconfig.h"
-
-static void
-initModeManually(struct Arguments const UNUSED *args, int argc, char *argv[])
-{
- int i, count=argc/2;
-
- if (argc%2) {
- WRITE_MSG(2, "Odd number of (path,excludelist) arguments\n");
- exit(1);
- }
-
- if (count<2) {
- WRITE_MSG(2, "No reference path(s) given\n");
- exit(1);
- }
-
- MatchList_initManually(&global_info.dst_list, 0, strdup(argv[0]), argv[1]);
-
- --count;
- global_info.src_lists.v = Emalloc(sizeof(struct MatchList) * count);
- global_info.src_lists.l = count;
-
- for (i=0; i<count; ++i)
- MatchList_initManually(global_info.src_lists.v+i, 0,
- strdup(argv[2 + i*2]), argv[3 + i*2]);
-}
-
-
-static void
-initModeVserver(struct Arguments const UNUSED *args, int argc, char *argv[])
-{
- struct MatchVserverInfo vserver = {
- .name = argv[0],
- .use_pkgmgmt = true
- };
-
- if (!MatchVserverInfo_init(&vserver)) {
- WRITE_MSG(2, "Failed to initialize unification for this vserver\n");
- exit(1);
- }
-
- if (argc!=1) {
- WRITE_MSG(2, "More than one vserver is not supported\n");
- exit(1);
- }
-
- if (!MatchList_initByVserver(&global_info.dst_list, &vserver)) {
- WRITE_MSG(2, "unification not configured for this vserver\n");
- exit(1);
- }
-
- MatchList_initRefserverList(&global_info.src_lists.v,
- &global_info.src_lists.l,
- vserver.appdir.d);
-
- MatchVserverInfo_free(&vserver);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2003,2004 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.h"
-#include "util.h"
-
-#include "lib_internal/unify.h"
-#include "lib_internal/matchlist.h"
-#include "lib_internal/util-dotfile.h"
-#include "lib_internal/util-safechdir.h"
-#include <lib/vserver.h>
-
-#include <getopt.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <wait.h>
-#include <fcntl.h>
-#include <assert.h>
-
-#define ENSC_WRAPPERS_IO 1
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_DIRENT 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_STDLIB 1
-#include <wrappers.h>
-
-int wrapper_exit_code = 1;
-
-
-#define CMD_HELP 0x8000
-#define CMD_VERSION 0x8001
-#define CMD_MANUALLY 0x8002
-
-struct option const
-CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
- { "manually", no_argument, 0, CMD_MANUALLY },
- { 0,0,0,0 }
-};
-
-static struct WalkdownInfo global_info;
-static struct SkipReason skip_reason;
-static struct Arguments const * global_args;
-
-int Global_getVerbosity() {
- return global_args->verbosity;
-}
-
-bool Global_doRenew() {
- return global_args->do_renew;
-}
-
-static void
-showHelp(int fd, char const *cmd, int res)
-{
- WRITE_MSG(fd, "Usage:\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " [-Rnv] <vserver>\n or\n ");
- WRITE_STR(fd, cmd);
- WRITE_MSG(fd,
- " --manually [-Rnvx] [--] <path> <excludelist> [<path> <excludelist>]+\n\n"
- " --manually ... unify generic paths; excludelists must be generated\n"
- " manually\n"
- " -R ... revert operation; deunify files\n"
- " -n ... do not modify anything; just show what there will be\n"
- " done (in combination with '-v')\n"
- " -v ... verbose mode\n"
- " -x ... do not cross filesystems; this is valid in manual\n"
- " mode only and will be ignored for vserver unification\n\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
-#if 0
- " -C ... use cached excludelists; usually they will be\n"
- " regenerated after package installation to reflect e.g.\n"
- " added/removed configuration files\n\n"
-#endif
- exit(res);
-}
-
-static void
-showVersion()
-{
- WRITE_MSG(1,
- "vunify " VERSION " -- unifies vservers and/or directories\n"
- "This program is part of " PACKAGE_STRING "\n\n"
- "Copyright (C) 2003,2004 Enrico Scholz\n"
- VERSION_COPYRIGHT_DISCLAIMER);
- exit(0);
-}
-
-// Returns 'false' iff one of the files is not existing, or of the files are different/not unifyable
-static bool
-checkFstat(struct MatchList const * const mlist,
- PathInfo const * const basename,
- PathInfo const * const path,
- struct stat const ** const dst_fstat, struct stat * const dst_fstat_buf,
- struct stat * const src_fstat)
-{
- assert(basename->d[0] != '/');
-
- if (*dst_fstat==0) {
- // local file does not exist... strange
- // TODO: message
- skip_reason.r = rsFSTAT;
- if (lstat(basename->d, dst_fstat_buf)==-1) return false;
- *dst_fstat = dst_fstat_buf;
- }
-
- assert(*dst_fstat!=0);
-
-
- PathInfo src_path = mlist->root;
- char src_path_buf[ENSC_PI_APPSZ(src_path, *path)];
-
- PathInfo_append(&src_path, path, src_path_buf);
-
- // source file does not exist
- skip_reason.r = rsNOEXISTS;
- if (lstat(src_path.d, src_fstat)==-1) return false;
-
- // these are directories; this succeeds everytime
- if (S_ISDIR((*dst_fstat)->st_mode) && S_ISDIR(src_fstat->st_mode)) return true;
-
- // both files are different, so return false
- skip_reason.r = rsDIFFERENT;
- if ((!global_args->do_revert && !Unify_isUnifyable(*dst_fstat, src_fstat)) ||
- ( global_args->do_revert && !Unify_isUnified (*dst_fstat, src_fstat)))
- return false;
-
- // these are the same files
- return true;
-}
-
-static struct MatchList const *
-checkDirEntry(PathInfo const *path,
- PathInfo const *d_path, bool *is_dir,
- struct stat *src_stat, struct stat *dst_stat)
-{
- struct WalkdownInfo const * const info = &global_info;
- struct MatchList const * mlist;
- struct stat const * cache_stat;
-
- // Check if it is in the exclude/include list of the destination vserver and
- // abort when it is not matching an allowed entry
- skip_reason.r = rsEXCL_DST;
- skip_reason.d.list = &info->dst_list;
- if (MatchList_compare(&info->dst_list, path->d)!=stINCLUDE) return 0;
-
- // Now, go through the reference vservers and do the lightweigt list-check
- // first and compare then the fstat's.
- for (mlist=info->src_lists.v; mlist<info->src_lists.v+info->src_lists.l; ++mlist) {
- cache_stat = 0;
- skip_reason.r = rsEXCL_SRC;
- skip_reason.d.list = mlist;
- if (MatchList_compare(mlist, path->d)==stINCLUDE &&
- checkFstat(mlist, d_path, path, &cache_stat, dst_stat, src_stat)) {
-
- // Failed the check or is it a symlink which can not be handled
- if (cache_stat==0) return 0;
-
- skip_reason.r = rsSYMLINK;
- if (S_ISLNK(dst_stat->st_mode)) return 0;
-
- skip_reason.r = rsSPECIAL;
- if (!S_ISREG(dst_stat->st_mode) &&
- !S_ISDIR(dst_stat->st_mode)) return 0;
-
- *is_dir = S_ISDIR(dst_stat->st_mode);
- return mlist;
- }
- else if (cache_stat!=0 && !global_args->do_revert &&
- skip_reason.r == rsDIFFERENT &&
- Unify_isUnified(cache_stat, src_stat)) {
- skip_reason.r = rsUNIFIED;
- skip_reason.d.list = mlist;
- return 0;
- }
- }
-
- // No luck...
- return 0;
-}
-
-static bool
-updateSkipDepth(PathInfo const *path, bool walk_down)
-{
- struct WalkdownInfo const * const info = &global_info;
- struct MatchList * mlist;
- bool result = false;
-
- for (mlist=info->src_lists.v; mlist<info->src_lists.v+info->src_lists.l; ++mlist) {
- // The easy way... this path is being skipped already
- if (mlist->skip_depth>0) {
- if (walk_down) ++mlist->skip_depth;
- else --mlist->skip_depth;
- continue;
- }
- else if (walk_down) {
- PathInfo src_path = mlist->root;
- char src_path_buf[ENSC_PI_APPSZ(src_path, *path)];
- struct stat src_fstat;
-
- PathInfo_append(&src_path, path, src_path_buf);
-
- // when the file/dir exist, we have do go deeper.
- // else skip it in deeper runs for *this* matchlist
- if (lstat(src_path.d, &src_fstat)!=-1) result = true;
- else ++mlist->skip_depth;
- }
- else {
- // TODO: warning
- }
- }
-
- return result;
-}
-
-static bool
-doit(struct MatchList const *mlist,
- PathInfo const *src_path, struct stat const *src_stat,
- char const *dst_path, struct stat const UNUSED *dst_stat)
-{
- PathInfo path = mlist->root;
- char path_buf[ENSC_PI_APPSZ(path, *src_path)];
-
- if (global_args->do_dry_run || Global_getVerbosity()>=2) {
- if (global_args->do_revert) WRITE_MSG(1, "deunifying '");
- else WRITE_MSG(1, "unifying '");
-
- Vwrite(1, src_path->d, src_path->l);
- WRITE_MSG(1, "'");
-
- if (Global_getVerbosity()>=4) {
- WRITE_MSG(1, " (from ");
- if (Global_getVerbosity()==4 && mlist->id.d)
- Vwrite(1, mlist->id.d, mlist->id.l);
- else
- Vwrite(1, mlist->root.d, mlist->root.l);
- WRITE_MSG(1, ")");
- }
- WRITE_MSG(1, "\n");
- }
-
- PathInfo_append(&path, src_path, path_buf);
- return (global_args->do_dry_run ||
- (!global_args->do_revert && Unify_unify (path.d, src_stat, dst_path, false)) ||
- ( global_args->do_revert && Unify_deUnify(dst_path)));
-}
-
-
-static void
-printSkipReason()
-{
- WRITE_MSG(1, " (");
- switch (skip_reason.r) {
- case rsDOTFILE : WRITE_MSG(1, "dotfile"); break;
- case rsEXCL_DST :
- case rsEXCL_SRC :
- WRITE_MSG(1, "excluded by ");
- MatchList_printId(skip_reason.d.list, 1);
- break;
- case rsFSTAT : WRITE_MSG(1, "fstat error"); break;
- case rsNOEXISTS : WRITE_MSG(1, "does not exist in refserver(s)"); break;
- case rsSYMLINK : WRITE_MSG(1, "symlink"); break;
- case rsSPECIAL : WRITE_MSG(1, "non regular file"); break;
- case rsUNIFIED : WRITE_MSG(1, "already unified"); break;
- case rsDIFFERENT : WRITE_MSG(1, "different"); break;
- default : assert(false); abort();
- }
- WRITE_MSG(1, ")");
-}
-
-#include "vserver-visitdir.hc"
-
-static uint64_t
-visitDirEntry(struct dirent const *ent)
-{
- bool is_dir;
- struct MatchList const * match;
- struct stat f_stat = { .st_dev = 0 };
- char const * dirname = ent->d_name;
- PathInfo path = global_info.state;
- PathInfo d_path = {
- .d = dirname,
- .l = strlen(dirname)
- };
- char path_buf[ENSC_PI_APPSZ(path, d_path)];
- bool is_dotfile;
- struct stat src_stat;
- uint64_t res = 1;
-
- PathInfo_append(&path, &d_path, path_buf);
-
- is_dotfile = isDotfile(dirname);
- skip_reason.r = rsDOTFILE;
-
- if (is_dotfile ||
- (match=checkDirEntry(&path, &d_path, &is_dir, &src_stat, &f_stat))==0) {
- bool is_link = is_dotfile ? false : S_ISLNK(f_stat.st_mode);
-
- if (Global_getVerbosity()>=1 &&
- (Global_getVerbosity()>=3 || skip_reason.r!=rsUNIFIED) &&
- ((!is_dotfile && !is_link) ||
- (Global_getVerbosity()>=6 && is_dotfile) ||
- (Global_getVerbosity()>=6 && is_link)) ) {
- WRITE_MSG(1, " skipping '");
- Vwrite(1, path.d, path.l);
- WRITE_MSG(1, "'");
- if (Global_getVerbosity()>=2) printSkipReason();
- WRITE_MSG(1, "\n");
- }
- return 0;
- }
-
- if (is_dir) {
- if (updateSkipDepth(&path, true)) {
- res = visitDir(dirname, &f_stat);
- updateSkipDepth(&path, false);
- }
- else
- res = 0;
- }
- else if (!doit(match, &path, &src_stat, dirname, &f_stat)) {
- // TODO: message
- }
- else
- res = 0;
-
- return res;
-}
-
-#include "vunify-init.hc"
-
-int main(int argc, char *argv[])
-{
- struct Arguments args = {
- .mode = mdVSERVER,
- .do_revert = false,
- .do_dry_run = false,
- .verbosity = 0,
- .local_fs = false,
- .do_renew = true,
- };
-
- global_args = &args;
- while (1) {
- int c = getopt_long(argc, argv, "Rnvcx",
- CMDLINE_OPTIONS, 0);
- if (c==-1) break;
-
- switch (c) {
- case CMD_HELP : showHelp(1, argv[0], 0);
- case CMD_VERSION : showVersion();
- case CMD_MANUALLY : args.mode = mdMANUALLY; break;
- case 'R' : args.do_revert = true; break;
- case 'n' : args.do_dry_run = true; break;
- case 'x' : args.local_fs = true; break;
- //case 'C' : args.do_renew = false; break;
- case 'v' : ++args.verbosity; break;
- default :
- WRITE_MSG(2, "Try '");
- WRITE_STR(2, argv[0]);
- WRITE_MSG(2, " --help\" for more information.\n");
- return EXIT_FAILURE;
- break;
- }
- }
-
- if (argc==optind) {
- WRITE_MSG(2, "No directory/vserver given\n");
- return EXIT_FAILURE;
- }
-
- switch (args.mode) {
- case mdMANUALLY : initModeManually(&args, argc-optind, argv+optind); break;
- case mdVSERVER : initModeVserver (&args, argc-optind, argv+optind); break;
- default : assert(false); return EXIT_FAILURE;
- }
-
- global_info.state.d = "";
- global_info.state.l = 0;
-
-
- if (Global_getVerbosity()>=1) WRITE_MSG(1, "Starting to traverse directories...\n");
- Echdir(global_info.dst_list.root.d);
- visitDir("/", 0);
-
-#ifndef NDEBUG
- {
- size_t i;
- MatchList_destroy(&global_info.dst_list);
- for (i=0; i<global_info.src_lists.l; ++i)
- MatchList_destroy(global_info.src_lists.v+i);
-
- free(global_info.src_lists.v);
- }
-#endif
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_SRC_VUNIFY_H
-#define H_UTIL_VSERVER_SRC_VUNIFY_H
-
-#include "lib_internal/matchlist.h"
-
-#include <sys/stat.h>
-
-struct dirent;
-struct WalkdownInfo
-{
- PathInfo state;
- struct MatchList dst_list;
- struct {
- struct MatchList * v;
- size_t l;
- } src_lists;
-};
-
-struct SkipReason {
- enum { rsDOTFILE, rsEXCL_DST, rsEXCL_SRC,
- rsFSTAT, rsNOEXISTS, rsSYMLINK, rsUNIFIED,
- rsSPECIAL, rsDIFFERENT } r;
-
- union {
- struct MatchList const * list;
- } d;
-};
-
-struct Arguments {
- enum {mdMANUALLY, mdVSERVER} mode;
- bool do_revert;
- bool do_dry_run;
- unsigned int verbosity;
- bool local_fs;
- bool do_renew;
-};
-
-static bool checkFstat(struct MatchList const * const,
- PathInfo const * const,
- PathInfo const * const,
- struct stat const ** const, struct stat * const,
- struct stat *) NONNULL((1,2,3,4,5,6));
-
-static struct MatchList const *
-checkDirEntry(PathInfo const *,
- PathInfo const *,
- bool *, struct stat *, struct stat *) NONNULL((1,2,3,4,5));
-
-static bool updateSkipDepth(PathInfo const *, bool) NONNULL((1));
-static bool doit(struct MatchList const *,
- PathInfo const *, struct stat const *,
- char const *dst_path, struct stat const *) NONNULL((1,2,3));
-
-#endif // H_UTIL_VSERVER_SRC_VUNIFY_H
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on vutil.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-#pragma implementation
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <utime.h>
-#include "vutil.h"
-#include <sys/ioctl.h>
-#include "ext2fs.h"
-
-#include <pathconfig.h>
-
-bool testmode;
-int debug;
-
-int file_copy (const char *src, const char *dst, struct stat &st)
-{
- int ret = -1;
- FILE *fin = fopen (src,"r");
- if (fin == NULL){
- fprintf (stderr,"Can't open file %s (%s)\n",src,strerror(errno));
- }else{
- FILE *fout = fopen (dst,"w");
- if (fout == NULL){
- fprintf (stderr,"Can't open file %s (%s)\n",dst,strerror(errno));
- }else{
- char buf[8192];
- int len;
- while ((len=fread(buf,1,sizeof(buf),fin))>0){
- fwrite (buf,1,len,fout);
- }
- fflush (fout);
- ret = 0;
- if (fchown (fileno(fout),st.st_uid,st.st_gid)==-1){
- fprintf (stderr,"Can't chown file %s (%s)\n"
- ,dst,strerror(errno));
- ret = -1;
- }else if (fchmod (fileno(fout),st.st_mode)==-1){
- fprintf (stderr,"Can't chmod file %s (%s)\n"
- ,dst,strerror(errno));
- ret = -1;
- }
- fclose(fout);
- struct utimbuf timbuf;
- timbuf.modtime = st.st_mtime;
- timbuf.actime = st.st_atime;
- if (utime (dst,&timbuf)==-1){
- fprintf (stderr,"Can't set time stamp on file %s (%s)\n"
- ,dst,strerror(errno));
- }
- }
- fclose (fin);
- }
- return ret;
-}
-
-/*
- Set the immutable flag on a file
-*/
-int setext2flag (const char *fname, bool set, int ext2flags)
-{
- int ret = -1;
- if (testmode){
- ret = 0;
- }else{
- int fd = open (fname,O_RDONLY);
- if (fd == -1){
- fprintf (stderr,"Can't open file %s (%s)\n",fname
- ,strerror(errno));
- }else{
- int flags = set ? ext2flags : 0;
- ret = ioctl (fd,EXT2_IOC_SETFLAGS,&flags);
- close (fd);
- if (ret == -1){
- fprintf (stderr,"Can't %s immutable flag on file %s (%s)\n"
- ,(set ? "set" : "unset")
- ,fname
- ,strerror(errno));
- }
- }
- }
- return ret;
-}
-
-int vbuild_mkdir (const char *path, mode_t mode)
-{
- int ret = -1;
- if (testmode){
- printf ("mkdir %s; chmod %o %s\n",path,mode,path);
- ret = 0;
- }else{
- ret = mkdir (path,mode);
- if (ret == -1 && errno == EEXIST){
- struct stat st;
- if (lstat(path,&st)!=-1 && S_ISDIR(st.st_mode)){
- ret = chmod (path,mode);
- }
- }
- }
- return ret;
-}
-
-int vbuild_mknod(const char *path, mode_t mode, dev_t dev)
-{
- int ret = -1;
- if (testmode){
- printf ("mknod %s %o %02x:%02x\n",path,mode,major(dev),minor(dev));
- ret = 0;
- }else{
- ret = mknod (path,mode,dev);
- if (ret == -1 && errno == EEXIST){
- struct stat st;
- lstat(path,&st);
- if (lstat(path,&st)!=-1
- && (st.st_mode & S_IFMT) == (mode & S_IFMT)
- && st.st_rdev == dev){
- ret = chmod (path,mode);
- }
- }
- }
- return ret;
-}
-int vbuild_symlink(const char *src, const char *dst)
-{
- int ret = -1;
- if (testmode){
- printf ("ln -s %s %s\n",src,dst);
- ret = 0;
- }else{
- ret = symlink (src,dst);
- }
- return ret;
-}
-
-int vbuild_link(const char *src, const char *dst)
-{
- int ret = -1;
- if (testmode){
- printf ("ln %s %s\n",src,dst);
- ret = 0;
- }else{
- ret = link (src,dst);
- }
- return ret;
-}
-
-int vbuild_unlink(const char *path)
-{
- int ret = -1;
- if (testmode){
- printf ("unlink %s\n",path);
- ret = 0;
- }else{
- ret = unlink (path);
- }
- return ret;
-}
-
-int vbuild_chown(const char *path, uid_t uid, gid_t gid)
-{
- int ret = -1;
- if (testmode){
- printf ("chown %d.%d %s\n",uid,gid,path);
- ret = 0;
- }else{
- ret = chown (path,uid,gid);
- }
- return ret;
-}
-
-int vbuild_file_copy(
- const char *src,
- const char *dst,
- struct stat &st)
-{
- int ret = -1;
- if (testmode){
- printf ("cp -a %s %s\n",src,dst);
- ret = 0;
- }else{
- ret = file_copy (src,dst,st);
- }
- return ret;
-}
-
-/*
- Load the list of all packages in a vserver
-*/
-void vutil_loadallpkg (Vserver const &refserver, list<Package> &packages)
-{
- FILE *fin = vutil_execdistcmd (K_PKGVERSION,refserver,NULL);
- if (fin != NULL){
- char line[1000];
- while (fgets(line,sizeof(line)-1,fin)!=NULL){
- int last = strlen(line)-1;
- if (last >= 0 && line[last] == '\n') line[last] = '\0';
- packages.push_back (Package(line));
- }
- pclose (fin);
- }
-}
-
-int vutil_lstat (string path, struct stat &st)
-{
- int ret = 0;
- if (lstat(path.c_str(),&st) == -1){
- fprintf (stderr,"Can't lstat file %s (%s)\n"
- ,path.c_str(),strerror(errno));
- ret = -1;
- }
- return ret;
-}
-
-const char K_PKGVERSION[]="pkgversion";
-const char K_DUMPFILES[]="dumpfiles";
-const char K_UNIFILES[]="unifiles";
-
-FILE *vutil_execdistcmd (const char *key, Vserver const &vserver, const char *args)
-{
- string cmd = PKGLIBDIR "/distrib-info ";
- cmd += vserver.getConfDir();
- cmd += " ";
- cmd += key;
- if (args != NULL){
- cmd += " ";
- cmd += args;
- }
- FILE *ret = popen (cmd.c_str(),"r");
- if (ret == NULL){
- fprintf (stderr,"Can't execute command %s\n",cmd.c_str());
- }else{
- #if 0
- char buf[1000];
- while (fgets(buf,sizeof(buf)-1,fin)!=NULL){
- int last = strlen(buf)-1;
- if (last >= 0) buf[last] = '\0';
- ret = buf;
- break;
- }
- pclose (fin);
- #endif
- }
- return ret;
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on vutil.h by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-#pragma interface
-#ifndef VUTIL_H
-#define VUTIL_H
-
-#include "vserver.hh"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <string>
-#include <set>
-#include <algorithm>
-#include <iostream>
-#include <list>
-
-using namespace std;
-
-extern int debug;
-extern bool testmode;
-
-// Patch to help compile this utility on unpatched kernel source
-#ifndef EXT2_IMMUTABLE_FILE_FL
- #define EXT2_IMMUTABLE_FILE_FL 0x00000010
- #define EXT2_IMMUTABLE_LINK_FL 0x00008000
-#endif
-
-
-FILE *vutil_execdistcmd (const char *, Vserver const &, const char *);
-extern const char K_DUMPFILES[];
-extern const char K_UNIFILES[];
-extern const char K_PKGVERSION[];
-
-class Package{
-public:
- string name;
- string version; // version + release
- Package(string &_name, string &_version)
- : name (_name), version(_version)
- {
- }
- Package(const char *_name, const char *_version)
- : name (_name), version(_version)
- {
- }
- Package(const string &line)
- {
- *this = line;
- }
- Package & operator = (const string &_line)
- {
- string line (_line);
- string::iterator pos = find (line.begin(),line.end(),'=');
- if (pos != line.end()){
- name = string(line.begin(),pos);
- version = string(pos + 1,line.end());
- }
- return *this;
- }
- Package (const Package &pkg)
- {
- name = pkg.name;
- version = pkg.version;
- }
- bool operator == (const Package &v) const
- {
- return name == v.name && version == v.version;
- }
- bool operator < (const Package &v) const
- {
- bool ret = false;
- if (name < v.name){
- ret = true;
- }else if (name == v.name && version < v.version){
- ret = true;
- }
- return ret;
- }
- // Load the file member of the package, but exclude configuration file
- void loadfiles(Vserver const &ref, set<string> &files)
- {
- if (debug > 2) cout << "Loading files for package " << name << endl;
- string namever = name + '-' + version;
- FILE *fin = vutil_execdistcmd (K_UNIFILES,ref,namever.c_str());
- if (fin != NULL){
- char tmp[1000];
- while (fgets(tmp,sizeof(tmp)-1,fin)!=NULL){
- int last = strlen(tmp)-1;
- if (last >= 0 && tmp[last] == '\n') tmp[last] = '\0';
- files.insert (tmp);
- }
- }
- if (debug > 2) cout << "Done\n";
- }
- #if 0
- bool locate(const string &path)
- {
- return find (files.begin(),files.end(),path) != files.end();
- }
- #endif
-};
-
-// Check if two package have the same name (but potentially different version)
-class same_name{
- const Package &pkg;
-public:
- same_name(const Package &_pkg) : pkg(_pkg) {}
- bool operator()(const Package &p)
- {
- return pkg.name == p.name;
- }
-};
-
-
-#include "vutil.p"
-
-#endif
-
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on vutil.p by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-
-/* vutil.cc 11/04/2003 14.22.04 */
-int file_copy (const char *src, const char *dst, struct stat&st);
-int setext2flag (const char *fname, bool set, int ext2flags);
-int vbuild_mkdir (const char *path, mode_t mode);
-int vbuild_mknod (const char *path, mode_t mode, dev_t dev);
-int vbuild_symlink (const char *src, const char *dst);
-int vbuild_link (const char *src, const char *dst);
-int vbuild_unlink (const char *path);
-int vbuild_chown (const char *path, uid_t uid, gid_t gid);
-int vbuild_file_copy (const char *src,
- const char *dst,
- struct stat&st);
-void vutil_loadallpkg (Vserver const &refserver, list<Package>&packages);
-int vutil_lstat (string path, struct stat&st);
-FILE *vutil_execdistcmd (const char *key,
- const string&vserver,
- const char *args);
-/* syscall.cc 18/07/2003 09.50.10 */
-extern "C" int call_new_s_context (int nbctx,
- int ctxs[],
- int remove_cap,
- int flags);
-extern "C" int call_set_ipv4root (unsigned long ip[],
- int nb,
- unsigned long bcast,
- unsigned long mask[]);
-extern "C" int call_chrootsafe (const char *dir);
-extern "C" int has_chrootsafe (void);
-extern "C" int call_set_ctxlimit (int res, long limit);
+++ /dev/null
-rebootmgr
-v_gated
-v_httpd
-v_named
-v_portmap
-v_sendmail
-v_smb
-v_sshd
-v_xinetd
-vservers
+++ /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; either version 2, or (at your option)
-## any later version.
-##
-## 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.
-##
-
-AM_INSTALLCHECK_STD_OPTIONS_EXEMPT += \
- $(sysv_src_SCRPTS) \
- $(sysv_gen_SCRPTS)
-
-sysv_src_SCRPTS = sysv/rebootmgr \
- sysv/vprocunhide \
- sysv/vservers-default \
- sysv/vservers-legacy
-sysv_gen_SCRPTS = sysv/v_gated \
- sysv/v_httpd \
- sysv/v_named \
- sysv/v_portmap \
- sysv/v_sendmail \
- sysv/v_smb \
- sysv/v_sshd \
- sysv/v_xinetd
-sysv_conf_DTA = sysv/vservers.conf
-
-sysconf_DATA += $(sysv_conf_DTA)
-EXTRA_DIST += sysv/v_gated.subst \
- sysv/v_httpd.subst \
- sysv/v_named.subst \
- sysv/v_portmap.subst \
- sysv/v_sendmail.subst \
- sysv/v_smb.subst \
- sysv/v_sshd.subst \
- sysv/v_xinetd.subst \
- $(sysv_src_SCRPTS) \
- $(sysv_conf_DTA)
-
-initrd_SCRIPTS += $(sysv_src_SCRPTS) \
- $(sysv_gen_SCRPTS)
-
-CLEANFILES += $(sysv_gen_SCRPTS)
-
-sysv_SUBSTRULE = s!/usr/lib/util-vserver!$(pkglibdir)!g; \
- s!^USR_SBIN=/usr/sbin$$!USR_SBIN=$(sbindir)!g; \
- s!^DEFAULT_VSERVERDIR=/vservers$$!DEFAULT_VSERVERDIR=$(vserverdir)!g
-
-sysv/%: sysv/%.subst
- @mkdir -p $$(dirname '$@')
- sed -e '$(sysv_SUBSTRULE)' '$<' >'$@.tmp'
- @rm -f '$@'
- @if cmp -s '$<' '$@.tmp'; then \
- cp -p '$<' '$@'; \
- else \
- mv -f '$@.tmp' '$@'; \
- fi
- @rm -f '$@.tmp'
- @chmod a-w '$@'
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 98 02
-# description: The rebootmgr service is monitoring all virtual servers \
-# and restart them as need. Virtual servers are using \
-# the /sbin/vreboot command to talk with the reboot manager
-# processname: rebootmgr
-# config: /etc/vservers
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-PIDFILE=/var/run/rebootmgr.pid
-# See how we were called.
-case "$1" in
- start)
- echo "Starting the reboot manager"
- cd $__CONFDIR
- VSERVERS=
- for serv in *.conf
- do
- test -f "$serv" || continue
-
- serv=`basename $serv .conf`
- if [ -d $__DEFAULT_VSERVERDIR/$serv ] ; then
- VSERVERS="$VSERVERS $serv"
- fi
- done
- $_REBOOTMGR --pidfile $PIDFILE $VSERVERS &
- touch /var/lock/subsys/rebootmgr
- ;;
- stop)
- echo "Stopping the reboot manager"
- kill `cat $PIDFILE`
- rm -f /var/lock/subsys/rebootmgr
- rm -f $PIDFILE
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- reload)
- echo Not implemented
- ;;
- status)
- if [ -f $PIDFILE ] ; then
- if kill -0 `cat $PIDFILE`
- then
- echo rebootmgr is running
- else
- echo rebootmgr is NOT running
- fi
- fi
- ;;
- *)
- echo "Usage: rebootmgr {start|stop|restart|reload|status}"
- exit 1
-esac
-
-exit 0
-
-
-
-
-
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 32 75
-# description: Wrapper to start gated bound to a single IP
-
-# normally, you will need /etc/vservices/gated.conf
-# with the following line
-# IP=0.0.0.0
-# so gated is started without restriction even if you
-# restart it from an ssh session, itself "chbounded" to a single
-# IP.
-USR_LIB_VSERVER=/usr/lib/util-vserver
-exec $USR_LIB_VSERVER/vsysvwrapper gated $*
-
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 85 15
-# description: Wrapper to start httpd bound to a single IP
-USR_LIB_VSERVER=/usr/lib/util-vserver
-exec $USR_LIB_VSERVER/vsysvwrapper httpd $*
-
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 55 45
-# description: Wrapper to start named bound to a single IP
-USR_LIB_VSERVER=/usr/lib/util-vserver
-exec $USR_LIB_VSERVER/vsysvwrapper named $*
-
-
-
-
-
-
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 91 35
-# description: Wrapper to start portmap bound to a single IP
-USR_LIB_VSERVER=/usr/lib/util-vserver
-exec $USR_LIB_VSERVER/vsysvwrapper portmap $*
-
-
-
-
-
-
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 80 30
-# description: Wrapper to start sendmail bound to a single IP
-USR_LIB_VSERVER=/usr/lib/util-vserver
-exec $USR_LIB_VSERVER/vsysvwrapper sendmail $*
-
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 91 35
-# description: Wrapper to start smb bound to a single IP
-USR_LIB_VSERVER=/usr/lib/util-vserver
-exec $USR_LIB_VSERVER/vsysvwrapper smb $*
-
-
-
-
-
-
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 55 25
-# description: Wrapper to start sshd bound to a single IP
-USR_LIB_VSERVER=/usr/lib/util-vserver
-exec $USR_LIB_VSERVER/vsysvwrapper sshd $*
-
-
-
-
-
-
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 56 50
-# description: Wrapper to start xinetd bound to a single IP
-USR_LIB_VSERVER=/usr/lib/util-vserver
-exec $USR_LIB_VSERVER/vsysvwrapper xinetd $*
-
+++ /dev/null
-#!/bin/bash
-#
-# vprocunhide sets vserver related attributes for /proc
-#
-# chkconfig: 2345 26 74
-# description: Makes some /proc entries visibly for vservers
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-f=/etc/rc.d/init.d/functions
-if test -e "$f"; then
- . "$f"
- lockfile=/var/lock/subsys/vprocunhide
-else
- success() { echo .; }
- passed() { echo .; }
- failure() { echo ERROR; }
- lockfile=/var/run/vprocunhide
-fi
-
-
-function start()
-{
- echo -n $"Fixing /proc entries visibility..."
- $_VPROCUNHIDE
- retval=$?
- case "$retval" in
- 0) success;;
- 2) passed; retval=0;;
- *) failure;
- esac
- echo
- test "$retval" -ne 0 || touch "$lockfile"
- return $retval
-}
-
-function stop()
-{
- rm -f "$lockfile"
-}
-
-function restart()
-{
- stop
- start
-}
-
-case "$1" in
- start|stop|restart) $1;;
- reload) ;;
- condrestart)
- test -f $lockfile && restart || :
- ;;
- status)
- test -f $lockfile && {
- echo $"/proc entries were fixed"
- exit 0
- }
- echo $"/proc entries are not fixed"
- exit 1
- ;;
- *)
- echo "Usage: $0 {start|stop|reload|restart|condrestart|status}"
- exit 2
- ;;
-esac
+++ /dev/null
-#!/bin/sh
-# chkconfig: - 98 02
-# description: Wrapper to start the default vservers
-
-## The *basename* of the lockfile; this must be the same name like
-## this if the initscript. Else, the vservers will not be stopped at
-## shutdown
-#LOCKFILE=vserver-default
-
-## Number of vservers which shall be started in parallel; since most
-## initmethods are spending much time time in sleeps, it is safe to
-## use a high number here
-#NUMPARALLEL=99
-
-## The vserver-flavor; the 'default' vservers will be started very late
-## which may be inappropriately for early services like nameservers or
-## VPN tunnels. By copying this initscript to a new name and adapting
-## the startup-position (for RH/Fedora the numbers in line 2), other
-## vservers can be selected. Identification of vservers happens by
-## putting the flavor into /etc/vservers/<vserver-id>/apps/init/mark.
-#MARK=default
-
-export MARK NUMPARALLEL LOCKFILE
-exec /usr/lib/util-vserver/vserver-wrapper "$@"
-
+++ /dev/null
-#!/bin/sh
-# chkconfig: 345 98 02
-# description: The vservers service is used to start and stop all
-# the virtual servers.
-
-: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
-test -e "$UTIL_VSERVER_VARS" || {
- echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
- exit 1
-}
-. "$UTIL_VSERVER_VARS"
-
-# Print the vserver name in priority/alpha order
-sortserver(){
- (
- cd $__CONFDIR
- for serv in *.conf
- do
- test -f "$serv" || continue
-
- PRIORITY=100
- . $serv
- test "$ONBOOT" || continue
- printf "%03d %s\n" $PRIORITY `basename $serv .conf`
- done
- ) | sort $* | (while read a b; do echo $b; done)
-}
-
-startservers(){
- echo "Starting the virtual servers"
- cd $__CONFDIR
- for name in `sortserver`
- do
- ONBOOT=
- . $name.conf
- if [ "$ONBOOT" = "yes" ] ; then
- $_VSERVER_LEGACY $name start
- else
- echo virtual server $name not configured for on boot start
- fi
- done
-}
-
-BACKGROUND=off
-if [ -f /etc/vservers.conf ] ; then
- . /etc/vservers.conf
-fi
-
-
-# See how we were called.
-case "$1" in
- start)
- if [ "$BACKGROUND" = "yes" ] ; then
- startservers >/dev/tty8 </dev/tty8 2>/dev/tty8 &
- else
- startservers
- fi
- touch /var/lock/subsys/vservers-legacy
- ;;
- stop)
- echo "Stopping the virtual servers"
- cd $__CONFDIR
- for name in `sortserver -r`
- do
- $_VSERVER_LEGACY $name stop
- done
- rm -f /var/lock/subsys/vservers-legacy
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- reload)
- echo Not implemented
- ;;
- status)
- cd $__CONFDIR
- for serv in *.conf
- do
- ONBOOT=no
- name=`basename $serv .conf`
- . $serv
- echo -n ONBOOT=$ONBOOT " "
- $_VSERVER_LEGACY $name running
- done
- ;;
- *)
- echo "Usage: vservers {start|stop|restart|reload|status}"
- exit 1
-esac
-
-exit 0
+++ /dev/null
-# Configuration file for the vservers service
-# BACKGROUND=yes
-# start the vservers on tty9, in background so the rest of the
-# boot process end early
-BACKGROUND=no
-
-
+++ /dev/null
-.deps
-.dirstamp
-.libs
-chrootsafe
-escaperoot
-forkbomb
-getctx
-getinitpid
-testipc
-testlimit
-testopenf
-vserver-info
+++ /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; either version 2, or (at your option)
-## any later version.
-##
-## 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.
-##
-
-tests_dietprogs = tests/getctx \
- tests/getinitpid \
- tests/vserver-info
-
-noinst_PROGRAMS += tests/escaperoot \
- tests/forkbomb \
- tests/testipc \
- tests/testlimit \
- tests/testopenf \
- $(tests_dietprogs)
-
-
-DIETPROGS += $(tests_dietprogs)
-
-tests_escaperoot_SOURCES = tests/escaperoot.c
-tests_forkbomb_SOURCES = tests/forkbomb.c
-tests_testipc_SOURCES = tests/testipc.c
-tests_testlimit_SOURCES = tests/testlimit.c
-tests_testopenf_SOURCES = tests/testopenf.c
-
-tests_getctx_SOURCES = tests/getctx.c
-tests_getctx_LDADD = $(VSERVER_LDADDS)
-tests_getctx_LDFLAGS = $(VSERVER_LDFLGS)
-
-tests_getinitpid_SOURCES = tests/getinitpid.c
-tests_getinitpid_LDADD = $(VSERVER_LDADDS)
-tests_getinitpid_LDFLAGS = $(VSERVER_LDFLGS)
-
-tests_vserver_info_SOURCES = tests/vserver-info.c
-tests_vserver_info_LDADD = $(VSERVER_LDADDS)
-tests_vserver_info_LDFLAGS = $(VSERVER_LDFLGS)
+++ /dev/null
-// $Id$ --*- c++ -*--
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on tests/chrootsafe.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- Test the chrootsafe command.
- Pass the path of a vserver as the only argument
-
- chrootsafe /vservers/test
-*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <grp.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "compat.h"
-#include "vserver.h"
-
-int main (int UNUSED argc, char *argv[])
-{
- // This test must fail
- int fd = open ("/",O_RDONLY);
- if (fd != -1){
- if (vc_chrootsafe(argv[1])==-1){
- fprintf (stderr,"Ok, chrootsafe failed with one open directory errno=%s\n",strerror(errno));
- }else{
- fprintf (stderr,"Hum, chrootsafe succeed with one open directory\n");
- system ("/bin/sh");
- }
- close (fd);
- }
- // Now it should work
- if (vc_chrootsafe(argv[1])!=-1){
- fprintf (stderr,"Ok, chrootsafe worked\n");
- system ("/bin/sh");
- }else{
- fprintf (stderr,"chrootsafe failed errno=%s\n",strerror(errno));
- }
- return 0;
-}
-
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on tests/escaperoot.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- This program tries to escape out of a vserver using chroot flaws.
- Once escaped, it exec a shell.
-
- None of this works on 2.4.13.
-*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <wait.h>
-#include <limits.h>
-
-static void print_pwd()
-{
- char path[PATH_MAX];
- if (getcwd(path,sizeof(path)-1)!=NULL){
- printf ("PWD: %s\n",path);
- }
-}
-/*
- Just set a chroot in a sub-directory and keep the
- current directory behind
-*/
-static void test1()
-{
- printf ("test1\n");
- print_pwd();
- mkdir ("dummy_dir",0755);
- if (chroot ("dummy_dir")==-1){
- fprintf (stderr,"Can't chroot into dummy_dir (%s)\n",strerror(errno));
- }else{
- int i;
- // Try to chdir into the real root
- for (i=0; i<1000; i++) chdir("..");
- print_pwd();
- if (execl ("/bin/sh","/bin/sh",NULL)==-1){
- fprintf (stderr,"execl /bin/sh failed (%s)\n",strerror(errno));
- }
- }
-}
-
-/*
- Same as test1, except we open the current directory and do
- a fchdir() to it before trying to escape to the real root.
-*/
-static void test2()
-{
- int fd;
-
- printf ("test2\n");
- print_pwd();
- mkdir ("dummy_dir",0755);
- fd = open (".",O_RDONLY);
- if (fd == -1){
- fprintf (stderr,"Can't open current directory (%s)\n",strerror(errno));
- }else if (chroot ("dummy_dir")==-1){
- fprintf (stderr,"Can't chroot into dummy_dir (%s)\n",strerror(errno));
- }else if (fchdir(fd)==-1){
- fprintf (stderr,"Can't fchdir to the current directory (%s)\n"
- ,strerror(errno));
- }else{
- int i;
- // Try to chdir into the real root
- for (i=0; i<1000; i++) chdir("..");
- print_pwd();
- if (execl ("/bin/sh","/bin/sh",NULL)==-1){
- fprintf (stderr,"execl /bin/sh failed (%s)\n",strerror(errno));
- }
- }
-}
-
-/*
- Perform the test in a sub-process so it won't affect the current one
-*/
-static void dotest (void (*f)())
-{
- pid_t pid = fork();
- if (pid == 0){
- f();
- _exit (0);
- }else if (pid == -1){
- fprintf (stderr,"Can't fork (%s)\n",strerror(errno));
- }else{
- int status;
- wait (&status);
- }
-}
-
-int main ()
-{
- dotest (test1);
- dotest (test2);
- printf ("All attempts failed\n");
- return 0;
-}
-
-
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on tests/forkbomb.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdio.h>
-
-typedef enum {MODE_SLEEP,MODE_LOOP,MODE_FORK, MODE_FORKSHELL} MODE;
-
-
-static void forkbomb_userfork (MODE mode)
-{
- pid_t pid = fork();
- if (pid==-1){
- fprintf (stderr,"Fork failed (%s)\n",strerror(errno));
- }else if (pid == 0){
- if (mode == MODE_SLEEP){
- sleep(20);
- }else if (mode == MODE_LOOP){
- int k=0;
- while (1) k++;
- }else if (mode == MODE_FORKSHELL){
- system ("/bin/false");
- }
- _exit (0);
- }
-}
-
-
-int main (int argc, char *argv[])
-{
- if (argc != 4){
- fprintf (stderr,"formboom N M mode\n"
- "where N is the number of process to start\n"
- "and M is the number of user to start\n"
- "Each user will try to start N process\n"
- "\n"
- "mode is:\n"
- " sleep: Each process sleeps for 20 seconds and exits\n"
- " loop: Each process loops forever\n"
- " fork: Each process exits immediatly and is restarted\n"
- " by the parent\n"
- " forkshell: Each process runs /bin/false in a shell and\n"
- " exits, then the parent start a new one\n"
- );
- }else{
- MODE mode;
- int i;
- if (strcmp(argv[3],"sleep")==0){
- mode = MODE_SLEEP;
- }else if (strcmp(argv[3],"loop")==0){
- mode = MODE_LOOP;
- }else if (strcmp(argv[3],"fork")==0){
- mode = MODE_FORK;
- }else if (strcmp(argv[3],"forkshell")==0){
- mode = MODE_FORKSHELL;
- }else{
- fprintf (stderr,"Invalid mode\n");
- exit (-1);
- }
- for (i=0; i<atoi(argv[2]); i++){
- if (fork()==0){
- if (setuid (i+1)==-1){
- fprintf (stderr,"Can't setuid to uid %d (%s)\n",i+1
- ,strerror(errno));
- }else{
- int j;
- for (j=0; j<atoi(argv[1]); j++){
- forkbomb_userfork (mode);
- }
- if (mode == MODE_FORK || mode == MODE_FORKSHELL){
- // Ok, all processes are started, in MODE_FORK
- // we create a new one all the time
- int status;
- while (wait(&status)!=-1) forkbomb_userfork(mode);
- }
- }
- _exit (0);
- }
- }
- system ("ps ax | wc -l");
- printf ("All the process are running now\n");
- printf ("Exit to end all processes\n");
- system ("/bin/sh");
- system ("killall forkbomb");
- }
- return 0;
-}
-
+++ /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 "compat.h"
-#include "vserver.h"
-#include "internal.h"
-#include "src/util.h"
-
-#include <stdlib.h>
-#include <unistd.h>
-
-int main(int argc, char *argv[])
-{
- char buf[sizeof(int)*3+2];
- xid_t ctx;
-
- if (argc==1) ctx = vc_get_task_xid(0);
- else ctx = vc_get_task_xid(atoi(argv[1]));
-
- utilvserver_fmt_int(buf, ctx);
-
- WRITE_STR(1, buf);
- WRITE_MSG(1, "\n");
-
- return 0;
-}
+++ /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 "compat.h"
-#include "vserver.h"
-#include "internal.h"
-#include "src/util.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-int main(int argc, char *argv[])
-{
- char buf[sizeof(int)*3+2];
- xid_t xid;
- struct vc_vx_info info;
-
- if (argc==1) xid = vc_get_task_xid(0);
- else xid = vc_get_task_xid(atoi(argv[1]));
-
- if (xid==VC_NOCTX) {
- perror("vc_get_task_xid()");
- return EXIT_FAILURE;
- }
-
- if (vc_get_vx_info(xid, &info)==-1) {
- perror("vc_get_vx_info()");
- return EXIT_FAILURE;
- }
-
- utilvserver_fmt_int(buf, info.initpid);
-
- WRITE_STR(1, buf);
- WRITE_MSG(1, "\n");
-
- return 0;
-}
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on tests/testipc.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-/*
- Test to see isolation of the various IPC resources
- between security context
-*/
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/sem.h>
-
-int main (int argc, char *argv[])
-{
- int ret = -1;
- if (argc < 2){
- fprintf (stderr,
- "testipc createshm\n"
- );
- }else if(strcmp(argv[1],"createshm")==0){
- int id = shmget (1,1024,IPC_CREAT|0666);
- if (id == -1){
- fprintf (stderr,"shmget failed (%s)\n",strerror(errno));
- }else{
- void *pt = shmat (id,NULL,0);
- printf ("shmget id %d\n",id);
- if (pt == NULL){
- fprintf (stderr,"can't shmat to id %d (%s)\n",id,strerror(errno));
- }else{
- char tmp[100];
- int ok;
- strcpy ((char*)pt,"original string");
-
- printf ("Letting a sub-program attach to this memory\n");
- sprintf (tmp,"./testipc accessshm %d",id);
- ok = system (tmp);
- printf ("\tSub-program returned %d\n",ok);
-
- printf ("\tThe segment now hold :%s:\n",(char*)pt);
- shmdt (pt);
-
- printf ("A sub-program in another context can't attach\n");
- sprintf (tmp,"/usr/sbin/chcontext ./testipc accessshm %d",id);
- ok = system (tmp);
- printf ("\tSub-program returned %d\n",ok);
-
- printf ("Executing a sub-shell\n");
- system ("/bin/sh");
- }
- printf ("Delete the share memory segment\n");
- if (shmctl (id,IPC_RMID,NULL)==-1){
- fprintf (stderr,"shmctl failed (%s)\n",strerror(errno));
- }else{
- ret = 0;
- }
- }
- }else if(strcmp(argv[1],"accessshm")==0){
- int id = atoi(argv[2]);
- void *pt = shmat (id,NULL,0);
- if (pt == (void*)-1){
- fprintf (stderr,"can't shmat to id %d (%s)\n",id,strerror(errno));
- }else{
- printf ("\tWriting hello in share memory\n");
- strcpy ((char*)pt,"hello");
- ret = 0;
- }
- }else if(strcmp(argv[1],"createsem")==0){
- int id = semget (1,1,IPC_CREAT|0666);
- if (id == -1){
- fprintf (stderr,"semget failed (%s)\n",strerror(errno));
- }else{
- char tmp[100];
- int ok;
- printf ("semget id %d\n",id);
-
- printf ("Letting a sub-program play with this semaphore\n");
- sprintf (tmp,"./testipc accesssem %d",id);
- ok = system (tmp);
- printf ("\tSub-program returned %d\n",ok);
-
- printf ("A sub-program in another context can't use the semaphore\n");
- sprintf (tmp,"/usr/sbin/chcontext ./testipc accesssem %d",id);
- ok = system (tmp);
- printf ("\tSub-program returned %d\n",ok);
-
- printf ("Executing a sub-shell\n");
- system ("/bin/sh");
-
- printf ("Delete the semaphore\n");
- if (semctl (id,0,IPC_RMID,NULL)==-1){
- fprintf (stderr,"semctl failed (%s)\n",strerror(errno));
- }else{
- ret = 0;
- }
- }
- }else if(strcmp(argv[1],"accesssem")==0){
- int id = atoi(argv[2]);
- struct sembuf ops[]={
- {0,0,0}
- };
- if (semop (id,ops,1) == -1){
- fprintf (stderr,"can't semop with id %d (%s)\n",id,strerror(errno));
- }else{
- ret = 0;
- }
- }
- return ret;
-}
-
-
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on tests/testlimit.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-int main (int argc, char *argv[])
-{
- if (argc != 3){
- fprintf (stderr,"testlimit nbprocess malloc_size\n");
- }else{
- int nbproc = atoi(argv[1]);
- int size = atoi(argv[2]);
- int i;
- int status;
- for (i=0; i<nbproc; i++){
- if (fork()==0){
- void *pt = malloc(size);
- if (pt == NULL){
- fprintf (stderr,"Child %d: can't malloc (%s)\n"
- ,i,strerror(errno));
- }else{
- memset (pt,1,size);
- }
- sleep (100);
- _exit (0);
- }
- }
- while (wait(&status)!=-1);
- }
- return 0;
-}
-
+++ /dev/null
-// $Id$
-
-// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
-// based on tests/testopenf.cc by Jacques Gelinas
-//
-// 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; either version 2, or (at your option)
-// any later version.
-//
-// 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.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-int main (int argc, char *argv[])
-{
- if (argc != 3){
- fprintf (stderr,"testlimit nbprocess nbopen\n");
- }else{
- int nbproc = atoi(argv[1]);
- int nbopen = atoi(argv[2]);
- int i;
- int status;
- for (i=0; i<nbproc; i++){
- if (fork()==0){
- int j;
- for (j=0; j<nbopen; j++){
- FILE *fin = fopen ("/proc/self/status","r");
- if (fin == NULL){
- fprintf (stderr,"Can't open %d (%s)\n",errno,strerror(errno));
- break;
- }
- }
- printf ("%d open files, sleeping\n",j);
- sleep (100);
- _exit (0);
- }
- }
- while (wait(&status)!=-1);
- }
- return 0;
-}
-
+++ /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 "vserver.h"
-
-#include "src/util.h"
-#include <stdlib.h>
-
-static void
-checkArgs(int argc, char *argv[])
-{
- if (argc==2) {
- if (strcmp(argv[1], "--help")==0) {
- WRITE_MSG(1, "Usage: vserver-info <vserver>\n");
- exit(0);
- }
- if (strcmp(argv[1], "--version")==0) {
- WRITE_MSG(1, "vserver-info " VERSION "\n");
- exit(0);
- }
- }
- else {
- WRITE_MSG(2, "No vserver specified; try '--help' for more inforamtion\n");
- exit(1);
- }
-}
-
-int
-main(int argc, char *argv[])
-{
- vcCfgStyle style = (checkArgs(argc, argv), vc_getVserverCfgStyle(argv[1]));
- char const * name = vc_getVserverName(argv[1], style);
- char const * vdir = vc_getVserverVdir(argv[1], style, true);
-
- WRITE_MSG(2, "Style: ");
- switch (style) {
- case vcCFG_NONE : WRITE_MSG(2, "CFG_NONE"); break;
- case vcCFG_AUTO : WRITE_MSG(2, "CFG_AUTO"); break;
- case vcCFG_LEGACY : WRITE_MSG(2, "CFG_LEGACY"); break;
- case vcCFG_RECENT_FULL : WRITE_MSG(2, "CFG_RECENT_FULL"); break;
- case vcCFG_RECENT_SHORT : WRITE_MSG(2, "CFG_RECENT_SHORT"); break;
- default : WRITE_MSG(2, "???"); break;
- }
-
- WRITE_MSG(2, "\nName: ");
- if (name==0) WRITE_MSG(2, "<null>");
- else WRITE_STR(2, name);
-
- WRITE_MSG(2, "\nVdir: ");
- if (vdir==0) WRITE_MSG(2, "<null>");
- else WRITE_STR(2, vdir);
-
- WRITE_MSG(2, "\n");
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#! /bin/sh
-
-test -n "$1" || {
- echo "No target directory given; aborting...">&2
- exit 1
-}
-
-test -d "$1"/CVS || {
- echo "Target directory does not seem to be CVS managed; aborting..." >&2
- exit 1
-}
-
-tmp=$(mktemp -d /tmp/uv.XXXXXX)/doc || exit 1
-trap "rm -rf $tmp" EXIT
-
-mkdir -p "$tmp"/{apidoc/html,conf}
-install -p -m644 doc/*.css doc/*.html "$tmp"/conf/
-install -p -m644 lib/apidoc/latex/refman.pdf "$tmp"/apidoc/refman.pdf
-install -p -m644 lib/apidoc/html/*.{css,html,png} "$tmp"/apidoc/html/
-
-rsync -av --delete --exclude=css --exclude=img --exclude=CVS --exclude=.symlinks --exclude=.htaccess "$tmp"/ "$1"/
+++ /dev/null
-# $Id$
-
-## This package understands the following switches:
-## --without dietlibc ... disable usage of dietlibc
-## --without xalan ... do not require/use the xalan xslt processor
-
-%global confdir %_sysconfdir/vservers
-%global confdefaultdir %confdir/.defaults
-%global pkglibdir %_libdir/%name
-%global __chattr /usr/bin/chattr
-%global chkconfig /sbin/chkconfig
-
-%global _localstatedir %_var
-
-
-%{!?release_func:%global release_func() %1}
-
-Summary: Linux virtual server utilities
-Name: @PACKAGE@
-Version: @VERSION@
-Release: %release_func 0
-License: GPL
-Group: System Environment/Base
-URL: http://savannah.nongnu.org/projects/util-vserver/
-Source0: http://savannah.nongnu.org/download/util-vserver/stable.pkg/%version/%name-%version.tar.bz2
-BuildRoot: %_tmppath/%name-%version-%release-root
-Requires: init(%name)
-Requires: %name-core = %version-%release
-Requires: %name-lib = %version-%release
-Requires: diffutils mktemp sed
-Provides: vserver = %version-%release
-Obsoletes: vserver < %version
-BuildRequires: mount vconfig gawk iproute iptables
-BuildRequires: gcc-c++ wget
-BuildRequires: e2fsprogs-devel beecrypt-devel
-BuildRequires: doxygen tetex-latex
-Requires(post): %__chattr
-Requires(pre): %pkglibdir
-Requires(postun): %pkglibdir
-%{!?_without_dietlibc:BuildRequires: dietlibc >= 0:0.25}
-%{!?_without_xalan:BuildRequires: xalan-j}
-
-%package lib
-Summary: Dynamic libraries for util-vserver
-Group: System Environment/Libraries
-
-%package core
-Summary: The core-utilities for util-vserver
-Group: Applications/System
-Requires: util-linux
-
-%package build
-Summary: Tools which can be used to build vservers
-Group: Applications/System
-Requires: rpm apt wget binutils tar e2fsprogs
-Requires: %name = %version-%release
-Requires(pre): %confdir
-Requires(postun): %confdir
-
-%package sysv
-Summary: SysV-initscripts for vserver
-Group: System Environment/Base
-Provides: init(%name) = sysv
-Requires: make diffutils
-Requires: initscripts
-Requires: %name = %version-%release
-Requires(post): %chkconfig
-Requires(preun): %chkconfig
-Requires(pre): %_initrddir %pkglibdir
-requires(postun): %_initrddir %pkglibdir
-
-%package legacy
-Summary: Legacy utilities for util-vserver
-Group: Applications/System
-Requires: %name = %version-%release
-Requires(post): %chkconfig
-Requires(preun): %chkconfig
-Requires(pre): %_initrddir %pkglibdir
-requires(postun): %_initrddir %pkglibdir
-
-%package devel
-Summary: Header-files and libraries which are needed to develop vserver based applications
-Group: Development/Libraries
-Requires: pkgconfig
-
-
-%description
-util-vserver provides the components and a framework to setup virtual
-servers. A virtual server runs inside a linux server. It is nevertheless
-highly independent. As such, you can run various services with normal
-configuration. The various vservers can't interact with each other and
-can't interact with services in the main server.
-
-This requires a special kernel supporting the new new_s_context and
-set_ipv4root system call.
-
-%description lib
-util-vserver provides the components and a framework to setup virtual
-servers. A virtual server runs inside a linux server. It is nevertheless
-highly independent. As such, you can run various services with normal
-configuration. The various vservers can't interact with each other and
-can't interact with services in the main server.
-
-This package contains the shared libraries needed by all other
-'util-vserver' subpackages.
-
-%description core
-util-vserver provides the components and a framework to setup virtual
-servers. A virtual server runs inside a linux server. It is nevertheless
-highly independent. As such, you can run various services with normal
-configuration. The various vservers can't interact with each other and
-can't interact with services in the main server.
-
-This package contains utilities which are required to communicate with
-the Linux-Vserver enabled kernel.
-
-
-%description build
-util-vserver provides the components and a framework to setup virtual
-servers. A virtual server runs inside a linux server. It is nevertheless
-highly independent. As such, you can run various services with normal
-configuration. The various vservers can't interact with each other and
-can't interact with services in the main server.
-
-This package contains utilities which assist in building Vservers.
-
-%description sysv
-util-vserver provides the components and a framework to setup virtual
-servers. A virtual server runs inside a linux server. It is nevertheless
-highly independent. As such, you can run various services with normal
-configuration. The various vservers can't interact with each other and
-can't interact with services in the main server.
-
-This package contains the SysV initscripts which start and stop
-VServers and related tools.
-
-
-%description legacy
-util-vserver provides the components and a framework to setup virtual
-servers. A virtual server runs inside a linux server. It is nevertheless
-highly independent. As such, you can run various services with normal
-configuration. The various vservers can't interact with each other and
-can't interact with services in the main server.
-
-This package contains the tools which are needed to work with VServers
-having an old-style configuration.
-
-
-%description devel
-util-vserver provides the components and a framework to setup virtual
-servers. A virtual server runs inside a linux server. It is nevertheless
-highly independent. As such, you can run various services with normal
-configuration. The various vservers can't interact with each other and
-can't interact with services in the main server.
-
-This package contains header files and libraries which are needed to
-develop VServer related applications.
-
-
-%prep
-%setup -q
-
-
-%build
-%configure --with-initrddir=%_initrddir --enable-release \
- %{?_without_dietlibc:--disable-dietlibc}
-
-%__make %{?_smp_mflags} all
-%__make %{?_smp_mflags} doc
-
-
-%install
-rm -rf $RPM_BUILD_ROOT
-%__make DESTDIR="$RPM_BUILD_ROOT" install install-distribution
-
-rm -f $RPM_BUILD_ROOT/%_libdir/*.la
-
-MANIFEST_CONFIG='%config' \
-MANIFEST_CONFIG_NOREPLACE='%config(noreplace)' \
-contrib/make-manifest %name $RPM_BUILD_ROOT contrib/manifest.dat
-
-
-%check || :
-%__make check
-
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-
-%post
-test -d /vservers || mkdir -m0000 /vservers
-test -d /vservers/.pkg || mkdir -m0755 /vservers/.pkg
-
-f="%confdefaultdir/vdirbase"; test -L "$f" -o -e "$f" || ln -s /vservers "$f"
-f="%confdefaultdir/run.rev"; test -L "$f" -o -e "$f" || ln -s %_localstatedir/run/vservers.rev "$f"
-
-%_sbindir/setattr --barrier /vservers || :
-
-
-%post lib -p /sbin/ldconfig
-%postun lib -p /sbin/ldconfig
-
-
-%post sysv
-%chkconfig --add vservers-default
-%chkconfig --add vprocunhide
-
-
-
-%preun sysv
-test "$1" != 0 || %_initrddir/vprocunhide stop &>/dev/null || :
-
-test "$1" != 0 || %chkconfig --del vprocunhide
-test "$1" != 0 || %chkconfig --del vservers-default
-
-
-%postun sysv
-test "$1" = 0 || %_initrddir/vprocunhide condrestart >/dev/null || :
-
-
-%triggerin build -- fedora-release
-function copy()
-{
- base=$1
- shift
-
- for i; do
- test -r "$i" || continue
-
- target=%confdir/.distributions/.common/pubkeys/$base-$(basename "$i")
- cp -a "$i" "$target"
- done
-}
-copy fedora /usr/share/doc/fedora-release-*/RPM-GPG-*
-
-
-%preun build
-test "$1" != 0 || rm -f %confdir/.distributions/.common/pubkeys/fedora-*
-
-
-## Temporary workaround to remove old v_* files; it will conflict
-## somehow with the -legacy package but can be fixed by reinstalling
-## this package.
-## TODO: remove me in the final .spec file
-%define v_services httpd named portmap sendmail smb sshd xinetd gated
-%triggerun sysv -- util-vserver-sysv < 0.30.198
-for i in %v_services; do
- %chkconfig --del v_$i || :
-done
-
-
-%post legacy
-%chkconfig --add rebootmgr
-%chkconfig --add vservers-legacy
-
-for i in %v_services; do
- %chkconfig --add v_$i
-done
-
-
-%preun legacy
-test "$1" != 0 || %_initrddir/rebootmgr stop &>/dev/null || :
-
-test "$1" != 0 || for i in %v_services; do
- %chkconfig --del v_$i
-done
-
-test "$1" != 0 || %chkconfig --del rebootmgr
-test "$1" != 0 || %chkconfig --del vservers-legacy
-
-%postun legacy
-test "$1" = 0 || %_initrddir/rebootmgr condrestart >/dev/null || :
-
-
-%files -f %name-base.list
-%defattr(-,root,root,-)
-%doc AUTHORS COPYING ChangeLog NEWS README THANKS
-%doc doc/*.html doc/*.css
-/sbin/vshelper
-%dir %confdir
-%dir %confdefaultdir
-%dir %confdefaultdir/apps
-%dir %confdefaultdir/files
-%dir %pkglibdir/defaults
-%ghost %confdefaultdir/vdirbase
-%ghost %confdefaultdir/run.rev
-
-%dir %_localstatedir/run/vservers
-%dir %_localstatedir/run/vservers.rev
-%dir %_localstatedir/run/vshelper
-
-
-%files lib -f %name-lib.list
-%files sysv -f %name-sysv.list
-
-
-%files core -f %name-core.list
-%defattr(-,root,root,-)
-%dir %pkglibdir
-
-
-%files build -f %name-build.list
-%defattr(-,root,root,-)
-%dir %confdir/.distributions
-%dir %confdir/.distributions/*
-%dir %confdir/.distributions/*/apt
-%dir %confdir/.distributions/.common
-%dir %confdir/.distributions/.common/pubkeys
-%dir %confdefaultdir/apps/vunify
-%dir %confdefaultdir/apps/vunify/hash
-
-
-%files legacy -f %name-legacy.list
-%defattr(-,root,root,-)
-%dir %pkglibdir/legacy
-
-
-%files devel -f %name-devel.list
-%defattr(-,root,root,-)
-%doc lib/apidoc/latex/refman.pdf
-%doc lib/apidoc/html
-
-
-%changelog
-* Thu Mar 24 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.30.205-0
-- added some %%descriptions
-- copy GPG keys from the system into the confdir
-- buildrequire dietlibc-0.25
-- BuildRequire beecrypt-devel
-- cleanups
-- use %%global instead of %%define
-- removed 'run.rev' as a vserver-local variable and made it a system-wide setting
-
-* Wed Jan 26 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.30.198-0.3
-- updated BuildRequires:
-- use 'setattr --barrier' instead of 'chattr +t' in the %%post scriptlet
-- moved the v_* initscripts to legacy
-- do not ship the /vservers directory itself; as it is immutable, the
- extraction will fail else
-
-* Thu Sep 9 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.30.194-0
-- documented switches for 'rpmbuild'
-
-* Wed May 26 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.29.215-0
-- (re)added the MANIFEST_* variables which were lost some time ago;
- this will preserve %%config files...
-
-* Mon Mar 15 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.29.202-0
-- use file-list for sysv scripts also
-
-* Sat Mar 6 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.29.198-0
-- added vprocunhide-service support
-- added doxygen support
-- updated Requires:
-
-* Wed Oct 1 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.23.5-0
-- Initial build.
+++ /dev/null
-.deps
-.dirstamp
-.libs
-vserver.start.bin
+++ /dev/null
-## $Id$ --*- makefile -*--
-
-## Copyright (C) 2004 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.
-
-
-if ENSC_HAVE_C99_COMPILER
-DIETPROGS += vserver-start/vserver.start.bin
-pkglib_PROGRAMS += vserver-start/vserver.start.bin
-endif
-
-## HACK: for now...
-AM_INSTALLCHECK_STD_OPTIONS_EXEMPT += vserver-start/vserver.start.bin
-
-vserver_start_vserver_start_bin_SOURCES = \
- vserver-start/main.c \
- vserver-start/mount.c \
- vserver-start/mount.h \
- vserver-start/defaulttty.c \
- vserver-start/scriptlets.c \
- vserver-start/undo.c \
- vserver-start/undo.h \
- vserver-start/vshelper.c \
- vserver-start/vshelper.h \
- vserver-start/interface.c \
- vserver-start/interface.h \
- vserver-start/interface-add.c \
- vserver-start/interface-read.c \
- vserver-start/interface-free.hc \
- vserver-start/interface-init.hc \
- vserver-start/interface-remove.c \
- vserver-start/interface-print.c \
- vserver-start/configuration.c \
- vserver-start/configuration-init.c \
- vserver-start/configuration.h \
- vserver-start/vserver-start.h
-
-vserver_start_vserver_start_bin_LDADD = $(VSERVER_LDADDS) \
- $(LIBINTERNAL) \
- $(LIBENSCVECTOR)
-vserver_start_vserver_start_bin_LDFLAGS = $(VSERVER_LDFLGS)
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "configuration.h"
-#include "interface.h"
-void
-Cfg_init(struct Configuration *cfg)
-{
- struct vc_ctx_caps const caps = {
- .bcaps = 0,
- .bmask = 0,
- .ccaps = 0,
- .cmask = 0
- };
-
- struct vc_ctx_flags const flags = {
- .flagword = 0,
- .mask = 0
- };
-
- Vector_init(&cfg->interfaces, sizeof(struct Interface));
- cfg->vdir = 0;
- cfg->xid = VC_DYNAMIC_XID;
- cfg->broadcast = 0;
- cfg->ctx_caps = caps;
- cfg->ctx_flags = flags;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "configuration.h"
-#include "interface.h"
-
-#include <lib_internal/util.h>
-#include <lib_internal/filecfg.h>
-#include <ensc_vector/vector.h>
-#include <lib/internal.h>
-
-#include <dirent.h>
-#include <string.h>
-
-static inline bool
-getSingleInterface(struct Interface *res,
- struct Interface const *tmpl,
- PathInfo const *basedir, char const *d_entry)
-{
- PathInfo ent = { .d = d_entry, .l = strlen(d_entry) };
- PathInfo path = *basedir;
- char path_buf[ENSC_PI_APPSZ(path, ent)];
-
- PathInfo_append(&path, &ent, path_buf);
- if (!utilvserver_isDirectory(path.d, true))
- return true; // skip non-directories
-
- return Iface_read(res, &path, tmpl);
-}
-
-static inline bool
-getInterfaces(struct Configuration *cfg)
-{
- ENSC_PI_DECLARE(iface_subdir, "interfaces");
- PathInfo ifacepath = cfg->cfgdir;
- char path_buf[ENSC_PI_APPSZ(ifacepath, iface_subdir)];
- struct Interface iface_default;
- DIR *dir;
- bool rc = true;
-
- PathInfo_append(&ifacepath, &iface_subdir, path_buf);
-
- if (!utilvserver_isDirectory(ifacepath.d, true))
- return true; // no interface configuration -> ok
-
- Iface_init(&iface_default);
- if (!Iface_read(&iface_default, &ifacepath, 0))
- return false;
-
- // iterate through dir-entries...
- dir = opendir(ifacepath.d);
- while (dir!=0) {
- struct dirent *ent = readdir(dir);
- struct Interface iface;
-
- if (ent==0) break;
- if (isDotfile(ent->d_name)) continue; // skip dot-files
-
- Iface_init(&iface);
- if (!getSingleInterface(&iface, &iface_default, &ifacepath, ent->d_name))
- rc = false;
- else if (iface.addr.ipv4.ip!=0) { // HACK: non-directory entries would return true also
- struct Interface *new_iface = Vector_pushback(&cfg->interfaces);
- *new_iface = iface;
- }
- }
-
- if (dir!=0)
- closedir(dir);
-
- return rc;
-}
-
-static bool
-initVdir(char const **vdir, PathInfo const *cfgdir)
-{
- *vdir = vc_getVserverVdir(cfgdir->d, vcCFG_RECENT_FULL, true);
- if (*vdir==0) {
- WRITE_MSG(2, "Can not find root-directory of the vserver\n");
- return false;
- }
-
- return true;
-}
-
-static bool
-setFlag(void *flags_v, char const *str, size_t len)
-{
- struct vc_ctx_flags *flags = flags_v;
- int rc = vc_list2cflag(str,len, 0,flags);
-
- return rc!=-1;
-}
-
-static bool
-setCCap(void *caps_v, char const *str, size_t len)
-{
- struct vc_ctx_caps *caps = caps_v;
- int rc = vc_list2ccap(str,len, 0,caps);
-
- return rc!=-1;
-}
-
-static bool
-setBCap(void *caps_v, char const *str, size_t len)
-{
- struct vc_ctx_caps *caps = caps_v;
- int rc = vc_list2bcap(str,len, 0,caps);
-
- return rc!=-1;
-}
-
-static bool
-readSomething(void *dest, PathInfo const *cfgdir, char const *item,
- FileCfg_MultiLineHandler handler)
-{
- char const *data = FileCfg_readEntryStr(cfgdir, item, true, 0);
- bool res = false;
-
- if (!data) return true;
- if (!FileCfg_iterateOverMultiLine(data, handler, dest)) {
- WRITE_MSG(2, "Failed to parse '");
- WRITE_STR(2, item);
- WRITE_MSG(2, "' configuration\n");
- goto finish;
- }
-
- res = true;
- finish:
- free(const_cast(char *)(data));
- return res;
-}
-
-bool
-getConfiguration(struct Configuration *cfg, PathInfo const *cfgdir)
-{
- cfg->cfgdir = *cfgdir;
- cfg->nice = FileCfg_readEntryStr(cfgdir, "nice", false, 0);
-
- return (initVdir(&cfg->vdir, cfgdir) &&
- readSomething(&cfg->ctx_flags, cfgdir, "flags", setFlag) &&
- readSomething(&cfg->ctx_caps, cfgdir, "ccapabilities", setCCap) &&
- readSomething(&cfg->ctx_caps, cfgdir, "bcapabilities", setBCap) &&
- getInterfaces(cfg));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_VSERVER_START_CONFIGURATION_H
-#define H_UTIL_VSERVER_VSERVER_START_CONFIGURATION_H
-
-#include <lib/vserver.h>
-#include <ensc_vector/vector.h>
-#include <lib_internal/pathinfo.h>
-
-#include <stdbool.h>
-
-typedef struct Vector InterfaceList;
-
-struct Configuration {
- PathInfo cfgdir;
- char const * vdir;
- xid_t xid;
- uint32_t broadcast;
- InterfaceList interfaces;
- char const * nice;
-
- struct vc_ctx_caps ctx_caps;
- struct vc_ctx_flags ctx_flags;
-};
-
- //extern struct Configuration cfg;
-
-void Cfg_init(struct Configuration *);
-bool getConfiguration(struct Configuration *, PathInfo const *cfgdir);
-
-
-#endif // H_UTIL_VSERVER_VSERVER_START_CONFIGURATION_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver-start.h"
-#include <pathconfig.h>
-
-#include <lib_internal/string.h>
-
-#include <string.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#include <wrappers.h>
-
-
-inline static bool
-checkTTY(char const /*@null@*/ *p)
-{
- return p!=0 && access(p, R_OK|W_OK)==0;
-}
-
-void
-setDefaultTTY(PathInfo const *cfgdir, char const *dflt)
-{
- PathInfo subpath = ENSC_STRING_FIXED("/apps/init/tty");
- char buf[ENSC_PI_APPSZ(*cfgdir, subpath)];
- char const * new_tty = 0;
-
- do {
- PathInfo ttypath = *cfgdir;
-
- PathInfo_append(&ttypath, &subpath, buf);
- new_tty = String_c_str(&ttypath, buf);
- if (checkTTY(new_tty)) break;
-
- new_tty = CONFDIR "/.defaults/apps/init/tty";
- if (checkTTY(new_tty)) break;
-
- new_tty = dflt;
- if (checkTTY(new_tty)) break;
-
- new_tty = "/dev/null";
- } while (false);
-
- int fd_in = Eopen(new_tty, O_RDONLY, 0);
- if (fd_in!=0) {
- Edup2(fd_in, 0);
- Eclose(fd_in);
- }
-
- int fd_out = Eopen(new_tty, O_WRONLY, 0600);
- if (fd_out!=1) {
- Edup2(fd_out, 1);
- Eclose(fd_out);
- }
-
- Edup2(1, 2);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "interface.h"
-#include "pathconfig.h"
-
-#include <lib_internal/command.h>
-#include <lib_internal/util.h>
-#include <ensc_fmt/fmt.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-unsigned int
-Iface_getIPv4Prefix(struct Interface const *iface)
-{
- uint32_t mask = iface->addr.ipv4.mask;
- unsigned int res = 0;
- while (mask!=0) {
- res += mask & 1;
- mask >>= 1;
- }
-
- return res;
-}
-
-static bool
-invokeIpAddr(struct Interface const *iface)
-{
- struct Command cmd;
- unsigned int prefix = Iface_getIPv4Prefix(iface);
- char * tmp = inet_ntoa(*reinterpret_cast(struct in_addr *)(&iface->addr.ipv4.ip));
- size_t l = strlen(tmp);
- char addr[l + sizeof("/") + sizeof(unsigned int)*3 + 1];
- char * ptr;
- size_t l1 = strlen(iface->dev);
- size_t l2 = iface->name ? strlen(iface->name) : 0;
- char devlabel[l1 + l2 + sizeof(":")];
- bool result = true;
-
- ptr = Xmemcpy(addr, tmp, l);
- *ptr++ = '/';
- l = utilvserver_fmt_uint(ptr, prefix);
- ptr[l] = '\0';
-
- Command_init(&cmd);
-
- size_t idx = 6;
- char const * argv[] = {
- "/bin/echo",
- PROG_IP, "addr", "add",
- addr,
- "broadcast", 0,
- 0, 0, // label <name>
- 0, 0, // dev <dev>
- 0
- };
-
- if (iface->addr.ipv4.bcast!=0)
- argv[idx++] = inet_ntoa(*reinterpret_cast(struct in_addr *)(&iface->addr.ipv4.bcast));
- else
- argv[idx++] = "+";
-
- if (iface->name) {
- ptr = Xmemcpy(devlabel, iface->dev, l1);
- *ptr++ = ':';
- ptr = Xmemcpy(ptr, iface->name, l2);
- *ptr = '\0';
-
- argv[idx++] = "label";
- argv[idx++] = devlabel;
- }
-
- argv[idx++] = "dev";
- argv[idx++] = iface->dev;
-
- Command_setParams(&cmd, argv);
- if (!Command_exec(&cmd, true) ||
- !Command_wait(&cmd, true) ||
- cmd.rc!=0)
- result = false;
-
- Command_free(&cmd);
-
- return result;
-}
-
-static bool
-addVLAN(struct Interface const UNUSED *iface)
-{
- abort(); // TODO: implement me
-}
-
-static bool
-addIndirect(struct Interface const UNUSED *iface)
-{
- abort(); // TODO: implement me
-}
-
-static bool
-addIP(struct Interface const *iface)
-{
- return invokeIpAddr(iface);
- //invokeIpLink(iface);
-}
-
-bool
-Iface_add(struct Interface const *iface)
-{
- if (iface->nodev) return true;
- if (strchr(iface->dev, '.')!=0) return addVLAN(iface);
- if (!iface->direct) return addIndirect(iface);
- return addIP(iface);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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.
-
-static inline UNUSED void
-Iface_free(struct Interface *iface)
-{
- free(const_cast(char *)(iface->name));
- free(const_cast(char *)(iface->scope));
- free(const_cast(char *)(iface->dev));
- free(const_cast(char *)(iface->mac));
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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.
-
-#include <string.h>
-
-static inline UNUSED void
-Iface_init(struct Interface *iface)
-{
- memset(&iface->addr, 0, sizeof (iface->addr));
- iface->name = 0;
- iface->scope = 0;
- iface->dev = 0;
- iface->mac = 0;
- iface->nodev = false;
- iface->direct = false;
- iface->up = true;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "interface.h"
-
-void
-Iface_print(struct Interface const UNUSED *iface, int UNUSED fd)
-{
-
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "interface.h"
-
-#include <lib_internal/filecfg.h>
-#include <lib_internal/util.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-static inline char *
-readEntryStr(PathInfo const *cfgdir, char const *file, char const *dflt)
-{
- return FileCfg_readEntryStr(cfgdir, file, false, dflt);
-}
-
-static inline bool
-readEntryFlag(PathInfo const *cfgdir, char const *file, bool dflt)
-{
- return FileCfg_readEntryFlag(cfgdir, file, dflt);
-}
-
-static int
-assumeNonNull(PathInfo const *cfgdir, char const *file, char const *val)
-{
- if (val!=0) return 0;
-
- WRITE_MSG(2, "vserver-start: no value configured for '");
- Vwrite (2, cfgdir->d, cfgdir->l);
- WRITE_MSG(2, "/");
- WRITE_STR(2, file);
- WRITE_STR(2, "'\n");
- return 1;
-}
-
-bool
-Iface_read(struct Interface *res, PathInfo *cfgdir,
- struct Interface const *dflt)
-{
- char const * extip;
- char const * ip;
- char const * mask;
- char const * prefix;
- char const * bcast;
- bool rc = false;
-
- // skip 'disabled' interfaces
- if (readEntryFlag(cfgdir, "disabled", false)) return true;
-
- ip = readEntryStr (cfgdir, "ip", 0);
- mask = readEntryStr (cfgdir, "mask", 0);
- prefix = readEntryStr (cfgdir, "prefix", 0);
- extip = readEntryStr (cfgdir, "extip", 0);
- bcast = readEntryStr (cfgdir, "bcast", 0);
- res->mac = readEntryStr (cfgdir, "mac", 0);
- res->name = readEntryStr (cfgdir, "name", 0);
- res->dev = readEntryStr (cfgdir, "dev", dflt ? dflt->dev : 0);
- res->scope = readEntryStr (cfgdir, "scope", dflt ? dflt->scope : 0);
- res->nodev = readEntryFlag(cfgdir, "nodev", false);
- res->direct = !readEntryFlag(cfgdir, "indirect", false);
- res->up = !readEntryFlag(cfgdir, "down", false);
-
- if (dflt && (
- assumeNonNull(cfgdir, "ip", ip) +
- assumeNonNull(cfgdir, "dev", res->dev) +
- (dflt->addr.ipv4.mask>0) ? 0 : (
- (mask ? 0 : assumeNonNull(cfgdir, "prefix", prefix)) +
- (prefix ? 0 : assumeNonNull(cfgdir, "mask", mask))
- )))
- goto err;
-
- if (mask && prefix) {
- WRITE_MSG(2, "vserver-start: both 'prefix' and 'mask' specified in '");
- Vwrite (2, cfgdir->d, cfgdir->l);
- WRITE_MSG(2, "'\n");
- goto err;
- }
-
- if (bcast)
- res->addr.ipv4.bcast = inet_addr(bcast);
-
- if (ip)
- res->addr.ipv4.ip = inet_addr(ip);
-
- if (extip)
- res->addr.ipv4.extip = inet_addr(extip);
-
- if (prefix) {
- int p = atoi(prefix);
- if (p==0) {
- WRITE_MSG(2, "vserver-start: invalid 'prefix' specified in '");
- Vwrite (2, cfgdir->d, cfgdir->l);
- WRITE_MSG(2, "'\n");
- goto err;
- }
-
- res->addr.ipv4.mask = htonl(-1u << (32-p));
- }
- else if (mask)
- res->addr.ipv4.mask = inet_addr(mask);
- else if (dflt)
- res->addr.ipv4.mask = dflt->addr.ipv4.mask;
-
- rc = true;
-
- err:
- free(const_cast(void *)(bcast));
- free(const_cast(void *)(extip));
- free(const_cast(void *)(ip));
- free(const_cast(void *)(mask));
- free(const_cast(void *)(prefix));
-
- return rc;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "interface.h"
-
-bool
-Iface_remove(struct Interface const UNUSED *iface)
-{
- return true;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "interface.h"
-
-#include "vserver-start.h"
-#include "configuration.h"
-#include "undo.h"
-
-#include <lib_internal/util.h>
-
-static void
-Iface_removeWrapper(void const *iface)
-{
- (void)Iface_remove(iface);
-}
-
-void
-activateInterfaces(InterfaceList const *interfaces)
-{
- struct Interface const * iface;
-
- for (iface=Vector_begin_const(interfaces);
- iface!=Vector_end_const(interfaces);
- ++iface) {
- if (!Iface_add(iface)) {
- WRITE_MSG(2, "Failed to add interface ");
- Iface_print(iface, 2);
- WRITE_MSG(2, "\n");
-
- exit(1);
- }
- Undo_addTask(Iface_removeWrapper, iface);
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_VSERVER_START_INTERFACE_H
-#define H_UTIL_VSERVER_VSERVER_START_INTERFACE_H
-
-#include "configuration.h"
-
-#include <lib_internal/util-cast.h>
-#include <lib_internal/pathinfo.h>
-#include <lib/vserver.h>
-#include <stdbool.h>
-
-struct Interface {
- union {
- struct {
- uint32_t ip;
- uint32_t mask;
- uint32_t extip;
- uint32_t bcast;
- } ipv4;
- } addr;
-
- char const * name;
- char const * scope;
- char const * dev;
- char const * mac;
- bool nodev;
- bool direct;
- bool up;
-};
-
-void activateInterfaces(InterfaceList const *interfaces);
-void deactivateInterfaces(InterfaceList const *interfaces);
-
-static void Iface_init(struct Interface *);
-static void Iface_free(struct Interface *);
-bool Iface_read(struct Interface *, PathInfo *cfgdir,
- struct Interface const *dflt);
-bool Iface_add(struct Interface const *);
-bool Iface_del(struct Interface const *);
-bool Iface_remove(struct Interface const *);
-void Iface_print(struct Interface const *, int fd);
-
-#include "interface-init.hc"
-#include "interface-free.hc"
-
-#endif // H_UTIL_VSERVER_VSERVER_START_INTERFACE_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver-start.h"
-#include "vshelper.h"
-#include "pathconfig.h"
-#include "interface.h"
-#include "configuration.h"
-#include "mount.h"
-#include "undo.h"
-
-#include "lib_internal/util.h"
-#include "lib_internal/errinfo.h"
-#include "lib_internal/sys_clone.h"
-#include "lib/vserver.h"
-#include "lib/internal.h"
-
-#include <sys/file.h>
-#include <sched.h>
-#include <signal.h>
-#include <unistd.h>
-#include <sys/socket.h>
-
-#define ENSC_WRAPPERS_VSERVER 1
-#define ENSC_WRAPPERS_SOCKET 1
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#define ENSC_WRAPPERS_STDLIB 1
-#include <ensc_wrappers/wrappers.h>
-
-struct Options opts;
-struct Configuration cfg;
-int wrapper_exit_code;
-
-static void
-env2Str(char const **var, char const *env, bool req)
-{
- char const * tmp = getenv(env);
- if (req && tmp==0) {
- WRITE_MSG(2, "vserver.start: required environment variable $");
- WRITE_STR(2, env);
- WRITE_STR(2, " not set; aborting...\n");
- exit(1);
- }
-
- *var = tmp;
- unsetenv(env);
-}
-
-static void
-env2Bool(bool *var, char const *env, bool req)
-{
- char const * tmp;
- env2Str(&tmp, env, req);
- *var = !(tmp==0 || atoi(tmp)==0);
-}
-
-static void
-initGlobals()
-{
- env2Str (&opts.VSERVER_DIR, "VSERVER_DIR", true);
- env2Str (&opts.VSERVER_NAME, "VSERVER_NAME", true);
- env2Bool(&opts.OPTION_DEBUG, "OPTION_DEBUG", false);
- env2Bool(&opts.OPTION_DEFAULTTTY, "OPTION_DEFAULTTTY", false);
-}
-
-static void
-initLock()
-{
- size_t l = strlen(opts.VSERVER_DIR);
- char tmp[sizeof(LOCKDIR "/vserver..startup") + l];
- char * ptr = tmp;
- struct ErrorInformation err = { .app = 0 };
- int fd;
-
- ptr = Xmemcpy(ptr, LOCKDIR "/vserver.", sizeof(LOCKDIR "/vserver.")-1);
- ((char *)(Xmemcpy(ptr, opts.VSERVER_DIR, l)))[0] = '\0';
- ptr += canonifyVserverName(ptr);
- ptr = Xmemcpy(ptr, ".startup", sizeof(".startup"));
- *ptr = '\0';
-
- if (!lockfile(&fd, tmp, LOCK_EX, 30, &err)) {
- WRITE_MSG(2, "vserver.start: failed to lock '");
- WRITE_STR(2, tmp);
- WRITE_MSG(2, "': ");
- ErrInfo_writeErrno(&err);
- exit(1);
- }
-}
-
-static void
-checkConstraints()
-{
- xid_t xid;
- bool is_running;
- struct vc_vx_info info;
-
- xid = vc_getVserverCtx(opts.VSERVER_DIR, vcCFG_RECENT_FULL,
- true, &is_running);
-
- if (xid!=VC_NOCTX && vc_get_vx_info(xid, &info)!=-1) {
- WRITE_MSG(2, "vserver.start: vserver '");
- WRITE_STR(2, opts.VSERVER_NAME);
- WRITE_MSG(2, "' already running; aborting...\n");
- exit(1);
- }
-
- Vshelper_doSanityCheck();
-}
-
-static void
-setCFlag(xid_t xid, uint_least64_t value)
-{
- struct vc_ctx_flags flags = {
- .flagword = value,
- .mask = value
- };
-
- Evc_set_cflags(xid, &flags);
-}
-
-int main(int UNUSED argc, char UNUSED *argv[])
-{
- Cfg_init(&cfg);
-
- initGlobals();
- initLock();
- checkConstraints();
-
- int sync_fd[2];
- char c;
- xid_t xid;
- char buf[sizeof(xid)*3 + 2];
- PathInfo cfgdir = { .d = opts.VSERVER_DIR, .l = strlen(opts.VSERVER_DIR) };
-
- Esocketpair(AF_UNIX, SOCK_STREAM, 0, sync_fd);
- Efcntl(sync_fd[0], F_SETFD, FD_CLOEXEC);
- Efcntl(sync_fd[1], F_SETFD, FD_CLOEXEC);
-
- getConfiguration(&cfg, &cfgdir);
- pid_t pid = sys_clone(CLONE_NEWNS|SIGCHLD, 0);
- FatalErrnoError(pid==-1, "sys_clone()");
-
- switch (pid) {
- case 0 :
- Undo_init();
- execScriptlets(&cfgdir, opts.VSERVER_NAME, "prepre-start");
- activateInterfaces(&cfg.interfaces);
-
- xid = Evc_ctx_create(cfg.xid);
- setCFlag(xid, VC_VXF_INFO_NAMESPACE);
-
- mountVserver(&cfg);
- // prepareInit(&cfg, &cfgdir);
-
- Esend(sync_fd[0], &xid, sizeof xid, MSG_NOSIGNAL);
- // 'pre-start.parent' will be executed now in the parent-context
- Erecv(sync_fd[0], &c, 1, 0);
- execScriptlets(&cfgdir, opts.VSERVER_NAME, "pre-start");
-
- if (cfg.nice)
- Enice(atoi(cfg.nice));
- if (opts.OPTION_DEFAULTTTY)
- setDefaultTTY(&cfgdir, 0);
-
-
-
- Undo_detach();
- break;
-
- default :
- Erecv(sync_fd[1], &xid, sizeof xid, 0);
- utilvserver_fmt_uint(buf, xid);
- Esetenv("CHILD_XID", buf, 1);
-
- execScriptlets(&cfgdir, opts.VSERVER_NAME, "pre-start.parent");
- Esend(sync_fd[1], ".", 1, MSG_NOSIGNAL);
-
- break;
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "mount.h"
-#include "configuration.h"
-#include "undo.h"
-
-#include <pathconfig.h>
-
-#include <lib/internal.h>
-#include <lib_internal/command.h>
-
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <wait.h>
-#include <string.h>
-
-#define ENSC_WRAPPERS_UNISTD 1
-#define ENSC_WRAPPERS_FCNTL 1
-#include <ensc_wrappers/wrappers.h>
-
-static char const *
-findMtab(char const *vserver_mtab)
-{
- char const *tmp;
-
- if (utilvserver_isFile(vserver_mtab, true)) return vserver_mtab;
-
- tmp=CONFDIR "/.defaults/init/mtab";
- if (utilvserver_isFile(tmp, true)) return tmp;
-
- tmp=PKGLIBDEFAULTDIR "/mtab";
- if (utilvserver_isFile(tmp, true)) return tmp;
-
- return 0;
-}
-
-static void
-initMtab(struct Configuration const *cfg)
-{
- ENSC_PI_DECLARE(mtab_subpath, "apps/init/mtab");
- PathInfo mtab_path = cfg->cfgdir;
- char mtab_buf[ENSC_PI_APPSZ(mtab_path, mtab_subpath)];
-
- PathInfo_append(&mtab_path, &mtab_subpath, mtab_buf);
- char const * mtab = findMtab(mtab_path.d);
- pid_t pid;
- int p[2];
-
- Epipe(p);
- pid = Efork();
- if (pid==0) {
- Undo_detach();
- Eclose(p[1]);
-
- Echdir(cfg->vdir);
- Echroot(".");
-
- int fd = Eopen("/etc/mtab", O_WRONLY|O_CREAT, 0644);
- for (;;) {
- char buf[4096];
- ssize_t len = TEMP_FAILURE_RETRY(read(p[0], buf, sizeof buf));
- if (len==0) break;
- if (len==-1) {
- perror("vserver-start: initMtab/read():");
- _exit(1);
- }
-
- Ewrite(fd, buf, len);
- }
- Eclose(fd);
- Eclose(p[0]);
- _exit(0);
- }
- else {
- Eclose(p[0]);
-
- if (mtab!=0) {
- int fd = Eopen(mtab, O_RDONLY, 0644);
-
- for (;;) {
- char buf[4096];
- ssize_t len = TEMP_FAILURE_RETRY(read(fd, buf, sizeof buf));
- if (len==0) break;
- if (len==-1) {
- perror("vserver-start: initMtab/read():");
- _exit(1);
- }
-
- Ewrite(p[1], buf, len);
- }
-
- Eclose(fd);
- }
-
- Eclose(p[1]);
-
- int status;
- TEMP_FAILURE_RETRY(wait4(pid, &status, 0,0));
-
- if (!WIFEXITED(status) || WEXITSTATUS(status)!=0) {
- exit(1);
- }
- }
-}
-
-static void
-mountVserverInternal(struct Configuration const *cfg,
- PathInfo const *path, bool use_chbind)
-{
- if (!utilvserver_isFile(path->d,true)) return;
-
- pid_t pid = Efork();
- if (pid==0) {
- Undo_detach();
-
- Echdir(cfg->vdir);
-
- if (use_chbind) {
- // TODO
- }
-
- struct Command cmd;
- char const * argv[] = {
- PROG_SECURE_MOUNT,
- "-a",
- "--chroot",
- "--fstab", path->d,
- 0
- };
-
- Command_init(&cmd);
- Command_setParams(&cmd, argv);
- Command_exec(&cmd, false);
- }
- else {
- int status;
- TEMP_FAILURE_RETRY(wait4(pid, &status, 0,0));
-
- if (!WIFEXITED(status) || WEXITSTATUS(status)!=0)
- exit(1);
- }
-}
-
-void
-mountVserver(struct Configuration const *cfg)
-{
- ENSC_PI_DECLARE(fstab_subpath, "fstab");
- ENSC_PI_DECLARE(fstabl_subpath, "fstab.local");
-
- PathInfo fstab_path = cfg->cfgdir;
- char fstab_buf[ENSC_PI_APPSZ(fstab_path, fstab_subpath)];
-
- PathInfo fstabl_path = cfg->cfgdir;
- char fstabl_buf[ENSC_PI_APPSZ(fstabl_path, fstabl_subpath)];
-
-
- PathInfo_append(&fstab_path, &fstab_subpath, fstab_buf);
- PathInfo_append(&fstabl_path, &fstabl_subpath, fstabl_buf);
- initMtab(cfg);
-
- mountVserverInternal(cfg, &fstab_path, true);
- mountVserverInternal(cfg, &fstabl_path, false);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_VSERVER_START_MOUNT_H
-#define H_UTIL_VSERVER_VSERVER_START_MOUNT_H
-
-#include <lib_internal/pathinfo.h>
-
-struct Configuration;
-void mountVserver(struct Configuration const *cfg);
-
-#endif // H_UTIL_VSERVER_VSERVER_START_MOUNT_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver-start.h"
-
-#include <pathconfig.h>
-#include <lib_internal/command.h>
-#include <lib_internal/util.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#define HAS_SUFFIX(STR, LEN, SUF) \
- (LEN>sizeof(SUF) && strcmp(STR+LEN-sizeof(SUF), SUF)==0)
-
-static bool
-visitFile(char const *fname, char const *vname, char const *style)
-{
- struct stat st;
- struct Command cmd;
-
- if (stat(fname, &st)==-1 ||
- !S_ISREG(st.st_mode))
- return false;
-
- if ((st.st_mode & 0111)==0) {
- WRITE_MSG(2,
- "!!!LEGACY ALERT!!!\n"
- "The special handling of non-executable scriptlets which allows to\n"
- "override environment variables is not supported anymore. This change\n"
- "was needed as 'vserver ... start' is done by a native C program now.\n"
- "If you need the old functionality please fill a bugreport so that\n"
- "workarounds can be found/implemented.\n"
- "The file triggering this message was\n"
- " '");
- WRITE_STR(2, fname);
- WRITE_MSG(2, "'\n");
-
- return false;
- }
-
- char const *par[] = { fname, style, vname, 0 };
- Command_setParams(&cmd, par);
-
- if (!Command_exec(&cmd, true) ||
- !Command_wait(&cmd, true)) {
- WRITE_MSG(2, "vserver-start: exec('");
- WRITE_STR(2, fname);
- WRITE_MSG(2, "'): ");
- WRITE_STR(2, strerror(cmd.err));
- WRITE_MSG(2, "; aborting...\n");
-
- exit(1);
- }
-
- if (cmd.rc!=0) {
- WRITE_MSG(2, "vserver-start: scriptlet '");
- WRITE_STR(2, fname);
- WRITE_MSG(2, "' failed; aborting...\n");
-
- exit (1);
- }
-
- Command_free(&cmd);
-
- return true;
-}
-
-static bool
-visitDirentry(PathInfo const *basepath, char const *d_name,
- char const *vname,
- char const *style)
-{
- size_t l = strlen(d_name);
- char path[basepath->l + l + 1];
- char * ptr;
-
- if (isDotfile(d_name) ||
- HAS_SUFFIX(d_name, l, ".rpmnew") ||
- HAS_SUFFIX(d_name, l, ".rpmsave") ||
- HAS_SUFFIX(d_name, l, ".rpmorig") ||
- HAS_SUFFIX(d_name, l, ".cfsaved"))
- return false;
-
- ptr = Xmemcpy(path, basepath->d, basepath->l);
- ptr = Xmemcpy(ptr, d_name, l);
- *ptr = '\0';
-
- return visitFile(path, vname, style);
-}
-
-static bool
-visitPath(PathInfo const *basepath,
- char const *vname,
- PathInfo const *style)
-{
- char tmp[basepath->l + style->l + sizeof(".d/")];
- PathInfo path = { .d = tmp };
- char * ptr;
- DIR * dir;
- bool did_something = false;
-
- ptr = Xmemcpy(tmp, basepath->d, basepath->l);
- ptr = Xmemcpy(ptr, style->d, style->l);
- *ptr = '\0';
- path.l = ptr-tmp;
-
- did_something = visitFile(path.d, vname, style->d) || did_something;
-
- ptr = Xmemcpy(ptr, ".d/", sizeof(".d/"));
- path.l = ptr-tmp;
-
- dir = opendir(tmp);
- while (dir) {
- struct dirent *ent = readdir(dir);
- if (ent==0) break;
-
- did_something = visitDirentry(&path, ent->d_name, vname, style->d) || did_something;
- }
- if (dir!=0) closedir(dir);
-
- return did_something;
-}
-
-void
-execScriptlets(PathInfo const *cfgdir, char const *vname, char const *style)
-{
- char path_buf[MAX(cfgdir->l, sizeof(CONFDIR "/.defaults")) +
- sizeof("/scripts/")];
- PathInfo basepath = { .d = path_buf };
- PathInfo styledir = {
- .d = style,
- .l = strlen(style)
- };
- char * ptr;
- bool doit = true;
-
- ptr = Xmemcpy(path_buf, cfgdir->d, cfgdir->l);
- ptr = Xmemcpy(ptr, "/scripts/", sizeof("/scripts/"));
- basepath.l = ptr-path_buf-1;
- doit = !visitPath(&basepath, vname, &styledir);
-
- if (doit) {
- ptr = Xmemcpy(path_buf, CONFDIR "/.defaults/scripts/",
- sizeof(CONFDIR "/.defaults/scripts/"));
- basepath.l = ptr-path_buf-1;
- doit = !visitPath(&basepath, vname, &styledir);
- }
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "undo.h"
-
-#include <lib_internal/util.h>
-#include <ensc_vector/vector.h>
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <assert.h>
-
-struct FuncData
-{
- ExitFunction fn;
- void const * args;
-};
-
-struct Undo
-{
- pid_t pid_;
- struct Vector funcs;
-};
-
-
-static struct Undo undo_data = {
- .pid_ = -1
-};
-
-static void
-atexitHandler()
-{
- struct FuncData const * ptr;
-
- if (undo_data.pid_ != getpid())
- return; // skip 'exit()' from forked processes
-
- for (ptr=Vector_end(&undo_data.funcs);
- ptr!=Vector_begin(&undo_data.funcs);
- --ptr)
- (ptr[-1].fn)(ptr[-1].args);
-}
-
-void
-Undo_init()
-{
- if (undo_data.pid_!=-1) {
- WRITE_MSG(2, "Undo already initialized; internal error...\n");
- _exit(1);
- }
-
- undo_data.pid_ = getpid();
- Vector_init(&undo_data.funcs, sizeof(struct FuncData));
-
- atexit(&atexitHandler);
-}
-
-void
-Undo_addTask(ExitFunction fn, void const *args)
-{
- struct FuncData *tmp = Vector_pushback(&undo_data.funcs);
- assert(tmp!=0); // Vector_pushback never returns a null-pointer
-
- tmp->fn = fn;
- tmp->args = args;
-}
-
-void
-Undo_detach()
-{
- Vector_free(&undo_data.funcs);
- undo_data.pid_ = -1;
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_VSERVER_START_UNDO_H
-#define H_UTIL_VSERVER_VSERVER_START_UNDO_H
-
-typedef void (*ExitFunction)(void const *);
-
-void Undo_init();
-void Undo_addTask(ExitFunction fn, void const *args);
-void Undo_detach();
-
-#endif // H_UTIL_VSERVER_VSERVER_START_UNDO_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_VSERVER_START_VSERVER_START_H
-#define H_UTIL_VSERVER_VSERVER_START_VSERVER_START_H
-
-#include <lib_internal/pathinfo.h>
-#include <stdbool.h>
-
-struct Options {
- char const * VSERVER_DIR;
- char const * VSERVER_NAME;
- bool OPTION_DEBUG;
- bool OPTION_DEFAULTTTY;
- bool OPTION_SECURE;
-};
-
-extern struct Options opts;
-
-void execScriptlets(PathInfo const *cfgdir, char const *name, char const *style);
-void setDefaultTTY(PathInfo const *cfgdir, char const *dflt);
-
-#endif // H_UTIL_VSERVER_VSERVER_START_VSERVER_START_H
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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 "vserver-start.h"
-#include "pathconfig.h"
-
-#include <lib_internal/util.h>
-#include <lib_internal/command.h>
-
-void
-Vshelper_doSanityCheck()
-{
- struct Command cmd;
- char const * argv[] = {
- "/bin/bash", "-c",
- ". " PATH_UTILVSERVER_VARS ";. " PATH_FUNCTIONS "; vshelper.doSanityCheck",
- 0
- };
-
- Command_init(&cmd);
- Command_setParams(&cmd, argv);
- if (!Command_exec(&cmd, true) ||
- !Command_wait(&cmd, true))
- WRITE_MSG(2, "vserver-start: failed to do the vshelper-sanitycheck\n");
-
- if (cmd.rc!=0)
- exit(0);
-}
+++ /dev/null
-// $Id$ --*- c -*--
-
-// Copyright (C) 2004 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_VSERVER_START_VSHELPER_H
-#define H_UTIL_VSERVER_VSERVER_START_VSHELPER_H
-
-void Vshelper_doSanityCheck();
-
-
-#endif // H_UTIL_VSERVER_VSERVER_START_VSHELPER_H