-.X_usr_local_etc-up-to-date
+.*-up-to-date
.deps
COPYING
ChangeLog
INSTALL
+Makefile
aclocal.m4
autom4te.cache
compile
stamp-h2
util-vserver-*.tar.bz2*
util-vserver-*.tar.gz
+util-vserver.spec
vserver.spec
vserverx-*.tar.*
vservercfgdir = $(sysconfdir)/vservers
include_HEADERS = $(lib_HDRS)
-noinst_HEADERS = $(src_HDRS)
+noinst_HEADERS = $(src_HDRS) $(lib_XHDRS) compat.h
lib_LIBRARIES = $(lib_lib_LIBS)
-pkglib_SCRIPTS = $(distrib_SCRPTS) $(scripts_SCRPTS)
+pkglib_SCRIPTS = $(distrib_SCRPTS) $(scripts_SCRPTS) $(src_pkglib_SCRPTS)
pkglib_DATA = $(distrib_DAT) $(scriptscfg_DATA)
pkglib_PROGRAMS = $(src_pkglib_PRGS)
-sbin_SCRIPTS = $(scripts_PRGS)
+sbin_SCRIPTS = $(scripts_PRGS) $(linuxconf_SCRPTS)
sbin_PROGRAMS = $(src_sbin_PRGS)
noinst_PROGRAMS = $(test_PRGS)
sysv_SCRIPTS = $(sysv_SCRPTS)
sysconf_DATA = $(sysv_CFG)
-vservercfg_DATA = newvserver.defaults
+vservercfg_DATA = $(linuxconf_cfg_DTA)
-BUILT_SOURCES = linuxcaps.h
+BUILT_SOURCES = linuxcaps.h linuxvirtual.h
-man_MANS = $(man_DATMAN)
+man_MANS = $(man_DATMAN) $(linuxconf_DATMAN)
EXTRA_DIST = $(distrib_SCRPTS) $(distrib_DAT) \
$(sysv_XTRAS) $(sysv_CFG) \
- $(doc_DAT) $(man_DATMAN) \
- $(scripts_SCRPTS) $(scripts_PRGS) $(scripts_XTRAS) \
- vserver.spec newvserver.defaults \
+ $(doc_DAT) $(man_DATMAN) $(linuxconf_DATMAN) \
+ $(scripts_SCRPTS) $(scripts_XTRAS) \
+ $(linuxconf_XTRAS) \
+ util-vserver.spec \
m4/ensc_cflags.m4 \
THANKS
AM_CPPFLAGS = -I $(top_srcdir)/lib -D VERSION=\"$(VERSION)\" -D PKGLIBDIR=\"$(pkglibdir)\" -D _GNU_SOURCE
AM_CFLAGS = -Wall -pedantic
-CLEANFILES = $(sysv_GENSCRPTS) $(scripts_GENSCRPTS) linuxcaps.h
+CLEANFILES = $(sysv_GENSCRPTS) $(scripts_GENSCRPTS) \
+ $(linuxconf_GENFILES) \
+ $(BUILT_SOURCES)
linuxcaps.h:
ln -sf ${kernelincludedir}/linux/capability.h linuxcaps.h
+linuxvirtual.h:
+ ln -sf '$(kernelincludedir)/linux/virtual.h' '$@' && test -e '$@' || \
+ ln -sf '$(top_srcdir)/lib/virtual.h' '$@'
include $(top_srcdir)/lib/Makefile-files
include $(top_srcdir)/src/Makefile-files
include $(top_srcdir)/scripts/Makefile-files
include $(top_srcdir)/tests/Makefile-files
include $(top_srcdir)/sysv/Makefile-files
+include $(top_srcdir)/linuxconf/Makefile-files
include $(top_srcdir)/m4/gpgsig.am
include $(top_srcdir)/m4/validate.am
+Version 0.24
+============
+
+ - updated to new syscall API (patch c17h and later)
+
+ - revived linuxconf module
+
+ - revived copy-all-mode for 'vserver ... build' (can be disabled
+ with $UTIL_VSERVER_AVOID_COPY)
+
+ - use '-HS' ulimit switch for newly created vservers
+
+ - added QUOTACTL capability, removed OPENDEV capability
+
+
+
+version 0.23.6
+==============
+
+ - fixed '--level' option on 'vserver ... chkconfig'
--- /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(__GNUC__)
+# define UNUSED __attribute__((__unused__))
+# define NORETURN __attribute__((__noreturn__))
+# if __GNUC__ >= 3
+# define ALWAYSINLINE __attribute__((__always_inline__))
+# else
+# define ALWAYSINLINE
+# endif
+#else
+# define UNUSED
+# define NORETURN
+# define ALWAYSINLINE
+#endif
+
+#if !defined(HAVE_DECL_MS_MOVE) || !(HAVE_DECL_MS_MOVE)
+ // from <linux/fs.h>
+# define MS_MOVE 8192
+#endif
+
+#ifndef HAVE_CTX_T
+typedef short int ctx_t;
+#endif
+
+#endif // H_UTIL_VSERVER_COMPAT_H
dnl
AC_PREREQ(2.57)
-AC_INIT(util-vserver, 0.23.5, enrico.scholz@informatik.tu-chemnitz.de)
+
+AC_INIT(util-vserver, 0.23.95, enrico.scholz@informatik.tu-chemnitz.de)
AC_CONFIG_SRCDIR([src/capchroot.c])
AC_CONFIG_HEADER([config.h])
kernelincludedir=$kerneldir/include
AC_SUBST(kernelincludedir)
AC_MSG_RESULT($kernelincludedir/linux)
-
-AC_CONFIG_FILES([vserver.spec Makefile])
+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,ALL (default: ALL)])],
+ [],
+ [supported_apis=ALL])
+
+test x"$supported_apis" != xALL || supported_apis='legacy,compat'
+old_IFS=$IFS
+IFS=,;
+for i in $supported_apis; do
+ case "$i" in
+ compat) AC_DEFINE(VC_ENABLE_API_COMPAT, 1, [Enable support for compatibily syscall API]);;
+ legacy) AC_DEFINE(VC_ENABLE_API_LEGACY, 1, [Enable support for old, /proc parsing API]);;
+ *) AC_MSG_ERROR(['$i' is not a supported API]);;
+ esac
+done
+IFS=$old_IFS
+AC_MSG_RESULT([$supported_apis])
+
+AC_CHECK_FUNCS([sys_virtual_context])
+AC_CHECK_DECLS(MS_MOVE,,,[#include <linux/fs.h>])
+AC_CHECK_TYPES(ctx_t,,,[#include <sys/types.h>])
+
+AC_CONFIG_FILES([util-vserver.spec Makefile])
AC_OUTPUT
--- /dev/null
+.deps
+.dirstamp
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
-lib_SRCS = lib/syscall.c
+lib_SRCS = lib/syscall.c \
+ lib/checkversion.c \
+ lib/getctx.c \
+ lib/getversion.c \
+ lib/uint2str.c
+
lib_HDRS = lib/vserver.h
+lib_XHDRS = lib/syscall-compat.hc \
+ lib/syscall-legacy.hc \
+ lib/getctx-compat.hc \
+ lib/getctx-legacy.hc \
+ lib/getversion-internal.hc \
+ lib/safechroot-internal.hc \
+ lib/virtual.h \
+ lib/vserver-internal.h
+
lib_lib_LIBS = lib/libvserver.a
-lib_libvserver_a_SOURCES = lib/syscall.c
-lib_libvserver_a_CPPFLAGS = -I$(kernelincludedir)
+lib_libvserver_a_SOURCES = $(lib_SRCS)
+lib_libvserver_a_CPPFLAGS = -I$(kernelincludedir) -D_GNU_SOURCE
--- /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 "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) 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_GETCTX_COMPAT_H
+#define H_UTIL_VSERVER_LIB_GETCTX_COMPAT_H
+
+#include "getctx-legacy.hc"
+
+static inline ALWAYSINLINE ctx_t
+vc_X_getctx_compat(pid_t pid)
+{
+ return vc_X_getctx_legacy(pid);
+}
+
+#endif // H_UTIL_VSERVER_LIB_GETCTX_COMPAT_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_LIB_GETCTX_LEGACY_H
+#define H_UTIL_VSERVER_LIB_GETCTX_LEGACY_H
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include "compat.h"
+
+#include "vserver.h"
+#include "vserver-internal.h"
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#define CTX_TAG "\ns_context: "
+
+static ctx_t
+vc_X_getctx_legacy(pid_t pid)
+{
+ static volatile size_t bufsize=4097;
+ // TODO: is this really race-free?
+ size_t cur_bufsize = bufsize;
+ int fd;
+ char status_name[ sizeof("/proc/01234/status") ];
+ char buf[cur_bufsize];
+ size_t len;
+ char *pos = 0;
+
+ if (pid<0 || (uint32_t)(pid)>99999) {
+ errno = EINVAL;
+ return 0;
+ }
+
+ if (pid==0) strcpy(status_name, "/proc/self/status");
+ else {
+ strcpy(status_name, "/proc/");
+ len = utilvserver_uint2str(status_name+sizeof("/proc/")-1,
+ sizeof(status_name)-sizeof("/proc//status")+1,
+ pid, 10);
+ strcpy(status_name+sizeof("/proc/")+len-1, "/status");
+ }
+
+ fd = open(status_name, O_RDONLY);
+ if (fd==-1) return VC_NOCTX;
+
+ len = read(fd, buf, cur_bufsize);
+ close(fd);
+
+ if (len<cur_bufsize) {
+ buf[len] = '\0';
+ pos = strstr(buf, CTX_TAG);
+ }
+ else if (len!=(size_t)-1) {
+ bufsize = cur_bufsize * 2 - 1;
+ errno = EAGAIN;
+ }
+
+ if (pos!=0) return atoi(pos+sizeof(CTX_TAG)-1);
+ else return VC_NOCTX;
+}
+
+#endif // H_UTIL_VSERVER_LIB_GETCTX_LEGACY_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 "vserver.h"
+#include "vserver-internal.h"
+
+#ifdef VC_ENABLE_API_COMPAT
+# include "getctx-compat.hc"
+#endif
+
+#ifdef VC_ENABLE_API_LEGACY
+# include "getctx-legacy.hc"
+#endif
+
+#include <sys/types.h>
+
+ctx_t
+vc_X_getctx(pid_t pid)
+{
+ CALL_VC(CALL_VC_COMPAT(vc_X_getctx, pid),
+ CALL_VC_LEGACY(vc_X_getctx, pid));
+}
--- /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
+#include "compat.h"
+
+#include "vserver-internal.h"
+#include "linuxvirtual.h"
+
+static inline ALWAYSINLINE int
+vc_get_version_internal(int cat)
+{
+ return sys_virtual_context(VC_CMD(VERSION, 0, 0), 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 "compat.h"
+
+#include "getversion-internal.hc"
+
+int
+vc_get_version(int cat)
+{
+ return vc_get_version(cat);
+}
--- /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 "vserver-internal.h"
+
+#include <unistd.h>
+
+static inline ALWAYSINLINE int
+vc_new_s_context_compat(ctx_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 sys_virtual_context(VC_CMD(COMPAT, 1, 1), 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 = -EINVAL;
+ return -1;
+ }
+
+ msg.broadcast = bcast;
+
+ for (i=0; i<nb; ++i) {
+ msg.ip_mask_pair[i].ip = ips[i].ip;
+ msg.ip_mask_pair[i].mask = ips[i].mask;
+ }
+
+ return sys_virtual_context(VC_CMD(COMPAT, 2, 3), nb, &msg);
+}
+
+static inline ALWAYSINLINE int
+vc_chrootsafe_compat(char const *dir)
+{
+ vc_tell_unsafe_chroot();
+ return chroot(dir);
+}
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <syscall.h>
+#include <asm/unistd.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;
+
+
+static _syscall1(int, set_ipv4root_rev0, unsigned long, ip)
+static _syscall2(int, set_ipv4root_rev1, unsigned long, ip, unsigned long, bcast)
+static _syscall3(int, set_ipv4root_rev2, unsigned long *, ip, int, nb, unsigned long, bcast)
+static _syscall4(int, set_ipv4root_rev3, unsigned long *, ip, int, nb, unsigned long, bcast, unsigned long *, mask)
+
+static int def_NR_new_s_context = 273;
+#undef __NR_new_s_context
+static int __NR_new_s_context_rev0;
+ //static int __NR_new_s_context_rev1;
+static int rev_s_context=0;
+
+static _syscall3(int, new_s_context_rev0, int, newctx, int, remove_cap, int, flags)
+ //static _syscall4(int, new_s_context_rev1, int, nbctx, int *, ctxs, int, remove_cap, int, flags)
+
+#if 0
+#undef __NR_set_ctxlimit
+static int __NR_set_ctxlimit=-1;
+static int rev_set_ctxlimit=-1;
+
+static _syscall2 (int, set_ctxlimit, int, resource, long, limit)
+#endif
+
+#undef __NR_chrootsafe
+static int __NR_chrootsafe=-1;
+static int rev_chrootsafe=-1;
+
+static _syscall1 (int, chrootsafe, const char *, dir)
+
+static void init()
+{
+ static int is_init = 0;
+ if (!is_init){
+ FILE *fin = fopen ("/proc/self/status","r");
+ __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;
+ //__NR_new_s_context_rev1 = def_NR_new_s_context;
+ if (fin != NULL){
+ char line[100];
+ while (fgets(line,sizeof(line)-1,fin)!=NULL){
+ int num;
+ char title[100],rev[100];
+ rev[0] = '\0';
+ if (sscanf(line,"%s %d %s",title,&num,rev)>=2){
+ if (strcmp(title,"__NR_set_ipv4root:")==0){
+ __NR_set_ipv4root_rev0 = num;
+ __NR_set_ipv4root_rev1 = num;
+ __NR_set_ipv4root_rev2 = num;
+ __NR_set_ipv4root_rev3 = num;
+ if (strncmp(rev,"rev",3)==0){
+ rev_ipv4root = atoi(rev+3);
+ }
+#if 0
+ }else if (strcmp(title,"__NR_set_ctxlimit:")==0){
+ __NR_set_ctxlimit = num;
+ if (strncmp(rev,"rev",3)==0){
+ rev_set_ctxlimit = atoi(rev+3);
+ }
+#endif
+ }else if (strcmp(title,"__NR_chrootsafe:")==0){
+ __NR_chrootsafe = num;
+ if (strncmp(rev,"rev",3)==0){
+ rev_chrootsafe = atoi(rev+3);
+ }
+ }else if (strcmp(title,"__NR_new_s_context:")==0){
+ __NR_new_s_context_rev0 = num;
+ //__NR_new_s_context_rev1 = num;
+ if (strncmp(rev,"rev",3)==0){
+ rev_s_context = atoi(rev+3);
+ }
+ }
+ }
+ }
+ fclose (fin);
+ }
+ is_init = 1;
+ }
+}
+
+void vc_init_legacy()
+{
+ init();
+}
+
+static ALWAYSINLINE int
+vc_new_s_context_legacy(int ctx, int remove_cap, int flags)
+{
+ int ret = -1;
+ init();
+ if (rev_s_context == 0){
+ return new_s_context_rev0(ctx, remove_cap, flags);
+ }else{
+ errno = -ENOSYS;
+ ret = -1;
+ }
+ 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){
+ fprintf (stderr,"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){
+ fprintf (stderr,"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);
+}
+
+static ALWAYSINLINE int
+vc_chrootsafe_legacy (const char *dir)
+{
+ init();
+ if (rev_chrootsafe == -1){
+ vc_tell_unsafe_chroot();
+ return chroot(dir);
+ }else if (rev_chrootsafe == 0){
+ return chrootsafe (dir);
+ }else{
+ fprintf (stderr,"chrootsafe: kernel support version %d, application expects version 0\n"
+ ,rev_chrootsafe);
+ }
+ errno = EINVAL;
+ return -1;
+}
+
+#if 0
+/*
+ Return != 0 if chrootsafe is available
+*/
+int has_chrootsafe()
+{
+ init();
+ return rev_chrootsafe != -1;
+}
+
+int call_set_ctxlimit (int res, long limit)
+{
+ init();
+ if (rev_set_ctxlimit == -1){
+ fprintf (stderr,"set_ctxlimit: Unsupported system call, update kernel\n");
+ }else if (rev_set_ctxlimit == 0){
+ return set_ctxlimit (res,limit);
+ }else{
+ fprintf (stderr,"set_ctxlimit: kernel support version %d, application expects version 0\n"
+ ,rev_set_ctxlimit);
+ }
+ errno = EINVAL;
+ return -1;
+}
+
+
+#endif
-// $Id$
+// $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.
+// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// 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 <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <syscall.h>
-#include <asm/unistd.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include "compat.h"
#include "vserver.h"
+#include "vserver-internal.h"
+#include "linuxvirtual.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 = 227;
-#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;
-
-
-static _syscall1(int, set_ipv4root_rev0, unsigned long, ip)
-static _syscall2(int, set_ipv4root_rev1, unsigned long, ip, unsigned long, bcast)
-static _syscall3(int, set_ipv4root_rev2, unsigned long *, ip, int, nb, unsigned long, bcast)
-static _syscall4(int, set_ipv4root_rev3, unsigned long *, ip, int, nb, unsigned long, bcast, unsigned long *, mask)
+#ifdef VC_ENABLE_API_COMPAT
+# include "syscall-compat.hc"
+#endif
-static int def_NR_new_s_context = 226;
-#undef __NR_new_s_context
-static int __NR_new_s_context_rev0;
-static int __NR_new_s_context_rev1;
-static int rev_s_context=0;
+#ifdef VC_ENABLE_API_LEGACY
+# include "syscall-legacy.hc"
+#endif
-static _syscall3(int, new_s_context_rev0, int, newctx, int, remove_cap, int, flags)
-static _syscall4(int, new_s_context_rev1, int, nbctx, int *, ctxs, int, remove_cap, int, flags)
-
-#undef __NR_set_ctxlimit
-static int __NR_set_ctxlimit=-1;
-static int rev_set_ctxlimit=-1;
-
-static _syscall2 (int, set_ctxlimit, int, resource, long, limit)
-
-#undef __NR_chrootsafe
-static int __NR_chrootsafe=-1;
-static int rev_chrootsafe=-1;
-
-static _syscall1 (int, chrootsafe, const char *, dir)
-
-static void init()
-{
- static int is_init = 0;
- if (!is_init){
- FILE *fin = fopen ("/proc/self/status","r");
- __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_rev1 = def_NR_new_s_context;
- if (fin != NULL){
- char line[100];
- while (fgets(line,sizeof(line)-1,fin)!=NULL){
- int num;
- char title[100],rev[100];
- rev[0] = '\0';
- if (sscanf(line,"%s %d %s",title,&num,rev)>=2){
- if (strcmp(title,"__NR_set_ipv4root:")==0){
- __NR_set_ipv4root_rev0 = num;
- __NR_set_ipv4root_rev1 = num;
- __NR_set_ipv4root_rev2 = num;
- __NR_set_ipv4root_rev3 = num;
- if (strncmp(rev,"rev",3)==0){
- rev_ipv4root = atoi(rev+3);
- }
- }else if (strcmp(title,"__NR_set_ctxlimit:")==0){
- __NR_set_ctxlimit = num;
- if (strncmp(rev,"rev",3)==0){
- rev_set_ctxlimit = atoi(rev+3);
- }
- }else if (strcmp(title,"__NR_chrootsafe:")==0){
- __NR_chrootsafe = num;
- if (strncmp(rev,"rev",3)==0){
- rev_chrootsafe = atoi(rev+3);
- }
- }else if (strcmp(title,"__NR_new_s_context:")==0){
- __NR_new_s_context_rev0 = num;
- __NR_new_s_context_rev1 = num;
- if (strncmp(rev,"rev",3)==0){
- rev_s_context = atoi(rev+3);
- }
- }
- }
- }
- fclose (fin);
- }
- is_init = 1;
- }
-}
-
-void vserver_init()
-{
- init();
-}
-
-int call_new_s_context(int nbctx, int ctxs[], int remove_cap, int flags)
-{
- int ret = -1;
- init();
- if (rev_s_context == 0){
- if (nbctx > 1){
- errno = EINVAL;
- fprintf (stderr,"The current kernel does not support new_s_context revision 1\n");
- }else if (nbctx == 0){
- ret = new_s_context_rev0(-2,remove_cap,flags);
- }else if (nbctx == 1){
- ret = new_s_context_rev0(ctxs[0],remove_cap,flags);
- }
- }else{
-fprintf (stderr,"new_s_context rev1 %d %d\n",nbctx,ctxs[0]);
- ret = new_s_context_rev1(nbctx,ctxs,remove_cap,flags);
- }
- return ret;
-}
+#include <stdbool.h>
+#include <errno.h>
-int call_set_ipv4root (
- unsigned long ip[],
- int nb,
- unsigned long bcast,
- unsigned long mask[])
-{
- init();
- if (rev_ipv4root == 0){
- if (nb > 1){
- fprintf (stderr,"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){
- fprintf (stderr,"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;
-}
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
-int call_chrootsafe (const char *dir)
+int
+vc_new_s_context(ctx_t ctx, unsigned int remove_cap, unsigned int flags)
{
- init();
- if (rev_chrootsafe == -1){
- fprintf (stderr,"chrootsafe: Unsupported system call, update kernel\n");
- }else if (rev_chrootsafe == 0){
- return chrootsafe (dir);
- }else{
- fprintf (stderr,"chrootsafe: kernel support version %d, application expects version 0\n"
- ,rev_chrootsafe);
- }
- errno = EINVAL;
- return -1;
+ CALL_VC(CALL_VC_COMPAT(vc_new_s_context, ctx, remove_cap, flags),
+ CALL_VC_LEGACY(vc_new_s_context, ctx, remove_cap, flags));
}
-/*
- Return != 0 if chrootsafe is available
-*/
-int has_chrootsafe()
+int
+vc_set_ipv4root(uint32_t bcast, size_t nb, struct vc_ip_mask_pair const *ips)
{
- init();
- return rev_chrootsafe != -1;
+ CALL_VC(CALL_VC_COMPAT(vc_set_ipv4root, bcast, nb, ips),
+ CALL_VC_LEGACY(vc_set_ipv4root, bcast, nb, ips));
}
-int call_set_ctxlimit (int res, long limit)
+int
+vc_chrootsafe(char const *dir)
{
- init();
- if (rev_set_ctxlimit == -1){
- fprintf (stderr,"set_ctxlimit: Unsupported system call, update kernel\n");
- }else if (rev_set_ctxlimit == 0){
- return set_ctxlimit (res,limit);
- }else{
- fprintf (stderr,"set_ctxlimit: kernel support version %d, application expects version 0\n"
- ,rev_set_ctxlimit);
- }
- errno = EINVAL;
- return -1;
+ CALL_VC(CALL_VC_COMPAT(vc_chrootsafe, dir),
+ CALL_VC_LEGACY(vc_chrootsafe, dir));
}
-
+#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 <assert.h>
+#include <stdbool.h>
+#include <string.h>
+
+size_t
+utilvserver_uint2str(char *buf, size_t len, unsigned int val, unsigned char base)
+{
+ char *ptr = buf+len-1;
+ register size_t res;
+ if (base>=36 || len==0) return 0;
+
+ *ptr = '\0';
+ while (ptr>buf) {
+ unsigned char digit = val%base;
+
+ --ptr;
+ *ptr = (digit<10 ? '0'+digit :
+ digit<36 ? 'a'+digit-10 :
+ (assert(false),'?'));
+
+ val /= base;
+ if (val==0) break;
+ }
+
+ assert(ptr>=buf && ptr<=buf+len-1);
+
+ res = buf+len-ptr;
+ memmove(buf, ptr, res);
+
+ return res-1;
+}
--- /dev/null
+#ifndef _LINUX_VIRTUAL_H
+#define _LINUX_VIRTUAL_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))
+
+#define VC_CAT_VERSION 0
+#define VC_CAT_PROCESS 1
+#define VC_CAT_MEMORY 2
+#define VC_CAT_NETWORK 3
+
+#define VC_CAT_LIMITS 8
+#define VC_CAT_QUOTA 9
+
+#define VC_CAT_OTHER 62
+#define VC_CAT_COMPAT 63
+
+/* interface version */
+
+ //#define VC_VERSION 0x00010000
+
+
+
+/* query version */
+
+#define VCMD_get_version VC_CMD(VERSION, 0, 0)
+
+
+/* compatibiliy vserver commands */
+
+#define VCMD_new_s_context VC_CMD(COMPAT, 1, 1)
+#define VCMD_set_ipv4root VC_CMD(COMPAT, 2, 3)
+
+/* compatibiliy vserver arguments */
+
+struct vcmd_new_s_context_v1 {
+ uint32_t remove_cap;
+ uint32_t flags;
+};
+
+#define NB_IPV4ROOT 16
+
+struct vcmd_set_ipv4root_v3 {
+ /* number of pairs in id */
+ uint32_t broadcast;
+ struct {
+ uint32_t ip;
+ uint32_t mask;
+ } ip_mask_pair[NB_IPV4ROOT];
+};
+
+
+#endif /* _LINUX_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.
+
+
+#ifndef H_VSERVER_SYSCALL_INTERNAL_H
+#define H_VSERVER_SYSCALL_INTERNAL_H
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <syscall.h>
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <errno.h>
+
+#ifndef __NR_sys_virtual_context
+# define __NR_sys_virtual_context 273
+#endif
+
+#define VC_PREFIX 0)
+#define VC_SUFFIX else (void)((void)0
+#define CALL_VC_NOOP (void)0
+#define CALL_VC_GENERAL(ID, SUFFIX, FUNC, ...) \
+ VC_PREFIX; VC_SELECT(ID) return FUNC ## _ ## SUFFIX(__VA_ARGS__); VC_SUFFIX
+
+#if 1
+# define VC_SELECT(ID) case ID: if(1)
+# define CALL_VC(...) \
+ switch (utilvserver_checkCompatVersion()) { \
+ case -1 : if (1) break; \
+ VC_SUFFIX, __VA_ARGS__ , VC_PREFIX; \
+ default : errno = EINVAL; \
+ } \
+ return -1
+#else
+# define VC_SELECT(ID) if (1)
+# define CALL_VC(...) \
+ if (1) {} VC_SUFFIX, __VA_ARGS__, VC_PREFIX; \
+ errno = ENOSYS; return -1
+#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 __cplusplus
+extern "C" {
+#endif
+
+#ifndef HAVE_SYS_VIRTUAL_CONTEXT
+static UNUSED
+_syscall3(int, sys_virtual_context,
+ uint32_t, cmd, uint32_t, id, void *, data)
+#endif
+
+size_t utilvserver_uint2str(char *buf, size_t len,
+ unsigned int val, unsigned char base);
+int utilvserver_checkCompatVersion();
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // H_VSERVER_SYSCALL_INTERNAL_H
#ifndef H_VSERVER_SYSCALL_H
#define H_VSERVER_SYSCALL_H
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#define VC_NOCTX ((ctx_t)(-1))
+
#ifdef __cplusplus
extern "C" {
#endif
-int call_new_s_context(int nbctx, int ctxs[], int remove_cap, int flags);
-int call_set_ipv4root (unsigned long ip[], int nb,
- unsigned long bcast, unsigned long mask[]);
-int call_chrootsafe (const char *dir);
-int has_chrootsafe();
-int call_set_ctxlimit (int res, long limit);
+ struct vc_ip_mask_pair {
+ uint32_t ip;
+ uint32_t mask;
+ };
+
+ /** Returns version of the given API-category */
+ int vc_get_version(int category);
+
+ /** Puts current process into context <ctx>, removes the given caps and
+ * sets flags.
+ * Special values for ctx are
+ * - -2 which means the current context (just for changing caps and flags)
+ * - -1 which means the next free context; this value can be used by
+ * ordinary users also */
+ int vc_new_s_context(ctx_t ctx, unsigned int remove_cap, unsigned int flags);
+
+ /** Sets the ipv4root information.
+ * \precondition: nb<16 */
+ int vc_set_ipv4root(uint32_t bcast, size_t nb, struct vc_ip_mask_pair const *ips);
+
+ int vc_chrootsafe(char const *dir);
-void vserver_init();
+ /** Returns the context of the given process. pid==0 means the current process. */
+ ctx_t vc_X_getctx(pid_t pid);
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+newvserver
--- /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.
+
+linuxconf_gen_SCRPTS = linuxconf/newvserver
+linuxconf_DATMAN = linuxconf/newvserver.8
+linuxconf_cfg_DTA = linuxconf/newvserver.defaults
+
+linuxconf_XTRAS = linuxconf/newvserver.subst \
+ $(linuxconf_cfg_DTA)
+
+linuxconf_SCRPTS = $(linuxconf_gen_SCRPTS)
+linuxconf_GENFILES = $(linuxconf_gen_SCRPTS)
+
+linuxconf/%: linuxconf/%.subst
+ @mkdir -p $$(dirname '$@')
+ sed -e 's!@'PKGLIBDIR'@!$(pkglibdir)!g; \
+ s!@'SBINDIR'@!$(sbindir)!g' '$<' >'$@.tmp'
+ @-chmod --reference='$<' '$@.tmp'
+ @-rm -f '$@'
+ mv '$@.tmp' '$@'
+ @chmod a-w '$@'
--- /dev/null
+#!/usr/bin/shellmod
+# This module is used to create a new virtual private server
+
+# This module may be use inside linuxconf
+# Do linuxconf --modulemain shellmod --setmod @SBINDIR@/newvserver
+
+# Load shellmod support function
+. /usr/lib/linuxconf/lib/shellmod-lib.sh
+
+USR_SBIN=@SBINDIR@
+USR_LIB_VSERVER=@PKGLIBDIR@
+VSERVER_CMD=$USR_SBIN/vserver
+CHBIND_CMD=$USR_SBIN/chbind
+CHCONTEXT_CMD=$USR_SBIN/chcontext
+SAVE_S_CONTEXT_CMD=$USR_LIB_VSERVER/save_s_context
+CAPCHROOT_CMD=$USR_LIB_VSERVER/capchroot
+VSERVERKILLALL_CMD=$USR_LIB_VSERVER/vserverkillall
+
+
+usage(){
+ cat <<-EOF >&2
+
+newvserver [ options ]
+
+ Interactive utility to create vservers.
+
+Options:
+ --name: Set the name of the new vserver.
+ --desc: Set the description.
+ --unify 1/0: Turn on unification on and off.
+ --hostname: Set the host name of the new vserver
+ --ip: Set the IP number(s)
+ --ondev: Install the IP numbers as IP aliases on device.
+ --clone: Create the vserver from another one or a distribution CD.
+
+The distribution CD are identified by special strings:
+ #rh9.0m: RedHat 9 minimal
+ #rh9.0f: RedHat 9 complete first CD
+ #rh8.0m: RedHat 8 minimal
+ #rh8.0f: RedHat 8 complete first CD
+ #rh7.3m: RedHat 7.3 minimal
+ #rh7.3f: RedHat 7.3 complete first CD
+ #rh7.2m: RedHat 7.2 minimal
+ #rh7.2f: RedHat 7.2 complete first CD
+
+EOF
+}
+
+register(){
+ qecho regmenu main MENU_MISCSERV "Create a new vserver"
+}
+
+check_name(){
+ LEN=`echo -n $1 | wc -c`
+ SMALL=`expr $LEN \<= 10`
+ if [ "$SMALL" = "1" ] ; then
+ return 0
+ fi
+ return 1
+}
+
+check_hostname(){
+ case $1 in
+ *\.*)
+ return 0
+ ;;
+ *)
+ ;;
+ esac
+ return 1
+}
+
+check_ip(){
+ case $1 in
+ *\.*\.*\.*)
+ return 0
+ ;;
+ *)
+ ;;
+ esac
+ return 1
+}
+
+check_device(){
+ if [ "$1" = "" ] ; then
+ return 1;
+ fi
+ return 0
+}
+
+# Tell the user to mount the CD
+check_cd(){
+ echo defval s1 "Make sure the $1"
+ echo defval s1 "is mounted on /mnt/cdrom"
+ echo defval s1
+ echo defval s1 "Execute \"mount /mnt/cdrom\" if not"
+ echo notice =s1
+}
+
+# Set a fake fstab and mtab in a vserver
+# $1 is the vserver path (/vserver/id)
+set_fstab(){
+ mkdir -p $1/etc
+ echo /dev/hdv1 / ext2 defaults 1 1 >$1/etc/fstab
+ echo /dev/hdv1 / ext2 rw 1 1 >$1/etc/mtab
+}
+
+# Show a progress bar during installation
+# The sub-process sends the number of output line first, then the lines
+execprogress(){
+ LOG=$1
+ title=$2
+ desc=$3
+ shift; shift; shift
+ $* |
+ (
+ >$LOG
+ read SIZE rest
+ qecho DIALOG
+ qecho settype DIATYPE_POPUP
+ qecho newf_str p1 "Package"
+ qecho newf_gauge s1 "$desc" 0 $SIZE
+ qecho show "$title" "$SIZE $rest"
+ nb=0
+ while read pkg line
+ do
+ nb=`expr $nb + 1`
+ printf "%-20s %s\n" $pkg $line >>$LOG
+ qecho newf_str p1 "Package" "$pkg"
+ qecho newf_gauge s1 "$desc" $nb $SIZE
+ qecho show "$title" "$SIZE $rest"
+ done
+ qecho end
+ )
+}
+
+# install some packages with a progress bar
+installpkgs(){
+ LOG=$1
+ shift
+ execprogress $LOG "Installing" "Packages installed" $*
+}
+
+# Point d'entré du module
+main(){
+ name=
+ desc=
+ clone=/
+ unify=1
+ hostname=
+ ip=
+ ondev=eth0
+ if [ -f /etc/vservers/newvserver.defaults ] ; then
+ source /etc/vservers/newvserver.defaults
+ fi
+ while [ "$1" != "" ]
+ do
+ case $1 in
+ --help)
+ usage
+ exit
+ ;;
+ --name)
+ name=$2
+ shift; shift
+ ;;
+ --desc)
+ desc=$2
+ shift; shift
+ ;;
+ --unify)
+ unify=$2
+ shift; shift
+ ;;
+ --hostname)
+ hostname=$2
+ shift; shift
+ ;;
+ --ip)
+ ip="$2"
+ shift; shift
+ ;;
+ --ondev)
+ ondev=$2
+ shift; shift
+ ;;
+ --clone)
+ clone=$2
+ shift; shift
+ ;;
+ *)
+ qecho error "Invalid option $1"
+ exit 1
+ esac
+ done
+ qecho DIALOG
+ qecho newf_title top 1 top
+ qecho newf_str name "Vserver name (max 10 chars)" $name
+ qecho newf_str desc "Vserver description" "$desc"
+ qecho newf_list clone "Clone vserver" $clone
+ for conf in /etc/vservers/*.conf
+ do
+ case $conf in
+ /etc/vservers/\*.conf)
+ ;;
+ *)
+ DESC=`grep "# Description:" $conf | ( read a b c; echo $c)`
+ qecho listitem `basename $conf .conf` "$DESC"
+ ;;
+ esac
+ done
+ qecho listitem / "Root server"
+ qecho listitem "#rh9.0m" "From RedHat 9.0 CDrom/Minimal"
+ qecho listitem "#rh9.0f" "From RedHat 9.0 CDrom/Full"
+ qecho listitem "#rh8.0m" "From RedHat 8.0 CDrom/Minimal"
+ qecho listitem "#rh8.0f" "From RedHat 8.0 CDrom/Full"
+ qecho listitem "#rh7.3m" "From RedHat 7.3 CDrom/Minimal"
+ qecho listitem "#rh7.3f" "From RedHat 7.3 CDrom/Full"
+ qecho listitem "#rh7.2" "From RedHat 7.2 CDrom"
+ #qecho listitem "#mdk8.2m" "From Mandrake 8.2 CDrom/Minimal"
+ #qecho listitem "#mdk8.2f" "From Mandrake 8.2 CDrom/Full"
+ qecho newf_chk unify "Unified mode" 1 "Share disk space" $unify
+
+ qecho newf_title Networking 1 Networking
+ qecho newf_str hostname "Host name" $hostname
+ qecho newf_info "" "Up to 16 IP numbers"
+ qecho newf_str ip "IP number(s)" "$ip"
+ qecho newf_str ondev "Install IP on device" $ondev
+
+ qecho newf_title Authentication 1 Authentication
+ qecho newf_pass pass1 "Root password"
+ qecho newf_pass pass2 "Root password (retype)"
+ qecho newf_chk usemd5 "Password format" 1 "Use MD5"
+ qecho newf_chk useshadow "Password location" 1 "/etc/shadow"
+
+ qecho newf_title NIS/LDAP 1 NIS/LDAP
+ qecho newf_str nisserver "NIS server"
+ qecho newf_str domainname "NIS domainname"
+ qecho newf_str ldapserver "LDAP server"
+ qecho newf_str ldapbasedn "LDAP base dn"
+
+ qecho newf_title Services 1 Services
+ qecho newf_chk crond "crond" 1 "Scheduled tasks"
+ qecho newf_chk httpd "httpd" 0 "Web server"
+ qecho newf_chk sshd "sshd" 1 "Secure shell server"
+ qecho newf_chk cleansshd "" 1 "Redo sshd server keys"
+ qecho newf_chk syslog "syslog" 1 "Message logger"
+ qecho newf_chk xinetd "xinetd" 0 "On demand inet service"
+ qecho newf_chk nscd "nscd" 0 "Name service cache daemon"
+
+ qecho newf_title "Backup profile" 1 "Backup profile"
+ qecho newf_str bkhostname "Host name"
+ qecho newf_info "" "Up to 16 IP numbers"
+ qecho newf_str bkip "IP number(s)"
+ qecho newf_str bkondev "Install IP on device" eth0
+
+ qecho newf_title Extra 1 Extra
+ qecho newf_chk onboot "Start server" 0 "at boot time"
+ qecho newf_str priority "Start priority" 100
+ qecho newf_str nice "Nice level"
+ qecho newf_info "Available flags" "lock nproc sched hideinfo private"
+ qecho newf_str flags "Flags" "lock nproc"
+ qecho newf_str ulimit "Vserver ulimit" "-H -u 1000"
+
+
+ qecho newf_title "Shared directories" 1 "Shared directories"
+ qecho newf_str dir1 "Directory"
+ qecho newf_str dir2 "Directory"
+ qecho newf_str dir3 "Directory"
+ qecho newf_str dir4 "Directory"
+
+ qecho newf_title "Excluded directories" 1 "Excluded directories"
+ qecho newf_info "" "Won't copy files in those directories"
+ qecho newf_str exdir1 "Directory" "/var/log"
+ qecho newf_str exdir2 "Directory" "/var/run"
+ qecho newf_str exdir3 "Directory" "/var/spool/mail"
+ qecho newf_str exdir4 "Directory" "/tmp"
+ qecho newf_str exdir5 "Directory" ""
+ qecho newf_str exdir6 "Directory" ""
+
+
+ while true
+ do
+ qecho edit "Vserver basic setup"
+ dispatch
+ if [ $CODE != "accept" ] ; then
+ break
+ elif ! check_name $name ; then
+ qecho error "You must provide a name (10 chars max)"
+ elif ! check_hostname $hostname ; then
+ qecho error "You must provide a valid/fully qualified host name"
+ elif ! check_ip $ip ; then
+ qecho error "You must provide a valid IP number"
+ elif ! check_device $ondev ; then
+ qecho error "You must provide a valid network device"
+ elif [ "$pass1" != "" -a "$pass1" != "$pass2" ] ; then
+ echo defval s1 The two passwords differ.
+ echo defval s1 You must re-enter the root password.
+ echo error =s1
+ else
+ STARTTIME=`date +%s`
+ ONBOOT=no
+ if [ "$onboot" = "1" ] ; then
+ ONBOOT=yes
+ fi
+ VROOT=/vservers/$name
+ CONF=/etc/vservers/$name.conf
+ $USR_LIB_VSERVER/install-pre.sh $name
+ rm -f $CONF >/dev/null 2>/dev/null
+ echo "# Description: $desc" >>$CONF
+ echo >>$CONF
+ echo "if [ \"$PROFILE\" = \"\" ]; then" >>$CONF
+ echo " PROFILE=prod" >>$CONF
+ echo "fi" >>$CONF
+ echo "case \$PROFILE in" >>$CONF
+ echo "prod)" >>$CONF
+ echo " # Select the IP number(s) assigned to the virtual server" >>$CONF
+ echo " # These IPs will be defined as IP alias" >>$CONF
+ echo " # The alias will be setup on IPROOTDEV" >>$CONF
+ echo " # You can specify the device if needed" >>$CONF
+ echo " # IPROOT=\"eth0:1.2.3.4 eth1:3.4.5.6\" " >>$CONF
+ echo " IPROOT=\"$ip\"" >>$CONF
+ echo " # You can define on which device the IP alias will be done" >>$CONF
+ echo " # The IP alias will be set when the server is started and unset" >>$CONF
+ echo " # when the server is stopped" >>$CONF
+ echo " # The netmask and broadcast are computed by default from IPROOTDEV" >>$CONF
+ echo " #IPROOTMASK=" >>$CONF
+ echo " #IPROOTBCAST=" >>$CONF
+ echo " IPROOTDEV=$ondev" >>$CONF
+ echo " # You can set a different host name for the vserver" >>$CONF
+ echo " # If empty, the host name of the main server is used" >>$CONF
+ echo " S_HOSTNAME=$hostname" >>$CONF
+ echo " ;;" >>$CONF
+ echo "backup)" >>$CONF
+ echo " IPROOT=\"$bkip\"" >>$CONF
+ echo " #IPROOTMASK=" >>$CONF
+ echo " #IPROOTBCAST=" >>$CONF
+ echo " IPROOTDEV=$bkondev" >>$CONF
+ echo " S_HOSTNAME=$bkhostname" >>$CONF
+ echo " ;;" >>$CONF
+ echo "esac" >>$CONF
+ echo "# Set ONBOOT to yes or no if you want to enable this" >>$CONF
+ echo "# virtual server at boot time" >>$CONF
+ echo "ONBOOT=$ONBOOT" >>$CONF
+ echo "# Control the start order of the vservers" >>$CONF
+ echo "# Lower value start first" >>$CONF
+ echo "PRIORITY=$priority" >>$CONF
+ echo "# You can set a different NIS domain for the vserver" >>$CONF
+ echo "# If empty, the current on is kept" >>$CONF
+ echo "# Set it to \"none\" to have no NIS domain set" >>$CONF
+ echo "S_DOMAINNAME=$domainname" >>$CONF
+ echo "# You can set the priority level (nice) of all process in the vserver" >>$CONF
+ echo "# Even root won't be able to raise it" >>$CONF
+ echo "S_NICE=$nice" >>$CONF
+ echo "# You can set various flags for the new security context" >>$CONF
+ echo "# lock: Prevent the vserver from setting new security context" >>$CONF
+ echo "# sched: Merge scheduler priority of all processes in the vserver" >>$CONF
+ echo "# so that it acts a like a single one." >>$CONF
+ echo "# nproc: Limit the number of processes in the vserver according to ulimit" >>$CONF
+ echo "# (instead of a per user limit, this becomes a per vserver limit)" >>$CONF
+ echo "# private: No other process can join this security context. Even root" >>$CONF
+ echo "# Do not forget the quotes around the flags" >>$CONF
+ echo "S_FLAGS=\"$flags\"" >>$CONF
+ echo "# You can set various ulimit flags and they will be inherited by the" >>$CONF
+ echo "# vserver. You enter here various command line argument of ulimit" >>$CONF
+ echo "# ULIMIT=\"-H -u 200\"" >>$CONF
+ echo "# The example above, combined with the nproc S_FLAGS will limit the" >>$CONF
+ echo "# vserver to a maximum of 200 processes" >>$CONF
+ echo "ULIMIT=\"$ulimit\"" >>$CONF
+ echo "# You can set various capabilities. By default, the vserver are run" >>$CONF
+ echo "# with a limited set, so you can let root run in a vserver and not" >>$CONF
+ echo "# worry about it. He can\'t take over the machine. In some cases" >>$CONF
+ echo "# you can to give a little more capabilities \(such as CAP_NET_RAW\)" >>$CONF
+ echo "# S_CAPS=\"CAP_NET_RAW\"" >>$CONF
+ echo "S_CAPS=\"\"" >>$CONF
+ echo "# Select an unused context (this is optional)" >>$CONF
+ echo "# The default is to allocate a free context on the fly" >>$CONF
+ echo "# In general you don't need to force a context" >>$CONF
+ echo "#S_CONTEXT=" >>$CONF
+
+ # Now we create the optional companion startup script
+ # for the vserver
+ SCRIPT=/etc/vservers/$name.sh
+ echo "#!/bin/sh" >$SCRIPT
+ echo 'case $1 in' >>$SCRIPT
+ echo "pre-start)" >>$SCRIPT
+ for dir in $dir1 $dir2 $dir3 $dir4 none
+ do
+ if [ "$dir" != "none" ] ; then
+ echo " mkdir -p $VROOT/$dir" >>$SCRIPT
+ echo " mount --bind $dir $VROOT/$dir" >>$SCRIPT
+ fi
+ done
+ echo " ;;" >>$SCRIPT
+ echo "post-start)" >>$SCRIPT
+ echo " ;;" >>$SCRIPT
+ echo "pre-stop)" >>$SCRIPT
+ echo " ;;" >>$SCRIPT
+ echo "post-stop)" >>$SCRIPT
+ for dir in $dir1 $dir2 $dir3 $dir4 none
+ do
+ if [ "$dir" != "none" ] ; then
+ echo " umount $VROOT/$dir" >>$SCRIPT
+ fi
+ done
+ echo " ;;" >>$SCRIPT
+ echo '*)' >>$SCRIPT
+ echo ' echo $0 pre-start' >>$SCRIPT
+ echo ' echo $0 pre-stop' >>$SCRIPT
+ echo ' echo $0 post-start' >>$SCRIPT
+ echo ' echo $0 post-stop' >>$SCRIPT
+ echo " ;;" >>$SCRIPT
+ echo "esac" >>$SCRIPT
+ chmod +x $SCRIPT
+
+ LOG=/var/run/newvserver.log.$$
+ if [ "$clone" = "/" ] ; then
+ # Unification does not work on / yet
+ $VSERVER_CMD $name build >$LOG
+ elif [ "$clone" = "#rh7.2" ] ; then
+ check_cd "first RedHat 7.2 CD"
+ set_fstab $VROOT
+ installpkgs $LOG $USR_LIB_VSERVER/install-rh7.2 $name
+ elif [ "$clone" = "#rh7.3m" -o "$clone" = "#rh7.3f" ] ; then
+ check_cd "first RedHat 7.3 CD"
+ set_fstab $VROOT
+ if [ "$clone" = "#rh7.3m" ] ;then
+ installpkgs $LOG $USR_LIB_VSERVER/install-rh7.3 $name minimum
+ else
+ installpkgs $LOG $USR_LIB_VSERVER/install-rh7.3 $name full
+ fi
+ elif [ "$clone" = "#rh8.0m" -o "$clone" = "#rh8.0f" ] ; then
+ check_cd "first RedHat 8.0 CD"
+ set_fstab $VROOT
+ if [ "$clone" = "#rh8.0m" ] ;then
+ installpkgs $LOG $USR_LIB_VSERVER/install-rh8.0 $name minimum
+ else
+ installpkgs $LOG $USR_LIB_VSERVER/install-rh8.0 $name full
+ fi
+ elif [ "$clone" = "#rh9.0m" -o "$clone" = "#rh9.0f" ] ; then
+ check_cd "first RedHat 9.0 CD"
+ set_fstab $VROOT
+ if [ "$clone" = "#rh9.0m" ] ;then
+ installpkgs $LOG $USR_LIB_VSERVER/install-rh9.0 $name minimum
+ else
+ installpkgs $LOG $USR_LIB_VSERVER/install-rh9.0 $name full
+ fi
+ elif [ "$unify" = "0" ] ; then
+ cp -ax /vservers/$clone/. $VROOT/. >$LOG
+ else
+ EXCLOPT=
+ for dir in $exdir1 $exdir2 $exdir3 $exdir4 $exdir5 $exdir6 none
+ do
+ if [ "$dir" != "none" ] ; then
+ EXCLOPT="$EXCLOPT --excldir $dir"
+ fi
+ done
+ $USR_LIB_VSERVER/vbuild $EXCLOPT --stats /vservers/$clone $VROOT >$LOG
+ fi
+ rm -f $VROOT/var/run/utmp
+ $USR_LIB_VSERVER/fakerunlevel 3 $VROOT/var/run/utmp
+ test "$crond" = 1 && $VSERVER_CMD $name chkconfig crond on >/dev/null
+ test "$httpd" = 1 && $VSERVER_CMD $name chkconfig httpd on >/dev/null
+ test "$sshd" = 1 && $VSERVER_CMD $name chkconfig sshd on >/dev/null
+ if [ "$cleansshd" = 1 ] ; then
+ echo Deleting sshd server keys >>$LOG
+ rm -f $VROOT/etc/ssh/*_key
+ rm -f $VROOT/etc/ssh/*_key.pub
+ fi
+ test "$syslog" = 1 && $VSERVER_CMD $name chkconfig syslog on >/dev/null
+ test "$xinetd" = 1 && $VSERVER_CMD $name chkconfig xinetd on >/dev/null
+ test "$nscd" = 1 && $VSERVER_CMD $name chkconfig nscd on >/dev/null
+ host0=`echo $hostname | sed 's/\./ /g' | ( read a b; echo $a)`
+ echo $ip $hostname $host0 localhost >$VROOT/etc/hosts
+ RHNETWORK=$VROOT/etc/sysconfig/network
+ if [ -f $RHNETWORK ] ; then
+ cat $RHNETWORK | grep -v HOSTNAME >/tmp/newvserver.tmp.$$
+ cp /tmp/newvserver.tmp.$$ $RHNETWORK
+ echo HOSTNAME=$hostname >>$RHNETWORK
+ fi
+ # Umount proc and /dev/pts
+ $VSERVER_CMD $name stop >/dev/null
+ ENDTIME=`date +%s`
+ DURATION=`expr $ENDTIME - $STARTTIME`
+
+ echo defval s1 Server $name was installed in $VROOT
+ echo defval s1 The configuration file /etc/vservers/$name.conf was created
+ echo defval s1 The script /etc/vservers/$name.sh was created
+ echo defval s1 Vserver $name was created in $DURATION seconds
+ echo defval s1
+ cat $LOG | while read line
+ do
+ echo defval s1 $line
+ done
+ echo notice =s1
+ rm -f $LOG
+ # Finish some stuff: root password, account policies
+ if [ -x $VROOT/usr/sbin/authconfig ] ; then
+ SHADOWOPT=
+ MD5OPT=
+ NISOPT=
+ LDAPOPT=
+ if [ "$usemd5" = "1" ] ; then
+ MD5OPT=--usemd5
+ fi
+ if [ "$useshadow" = "1" ] ; then
+ SHADOWOPT=--useshadow
+ fi
+ if [ "$nisserver" != "" ] ; then
+ NISOPT="--nisserver $nisserver --nisdomain $domainname"
+ fi
+ if [ "$ldapserver" != "" ] ; then
+ LDAPOPT="--ldapserver $ldapserver --ldapbasedn $ldapbasedn"
+ fi
+ $VSERVER_CMD $name exec /usr/sbin/authconfig \
+ --nostart --kickstart \
+ $SHADOWOPT $MD5OPT $NISOPT $LDAPOPT
+ fi
+ if [ "$pass1" != "" ] ; then
+ (echo $pass1; sleep 5; echo $pass1) \
+ | $VSERVER_CMD --silent $name exec passwd >/dev/null
+ fi
+ break
+ fi
+ done
+ qecho end
+}
+
+dispatch
man_DATMAN = man/chbind.8 \
man/chcontext.8 \
man/distrib-info.8 \
- man/newvserver.8 \
man/rebootmgr.8 \
man/reducecap.8 \
man/vps.8 \
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_OPENDEV
+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
--- /dev/null
+util-vserver-vars
+vkill
+vps
scriptscfgdir = $(sbindir)
-scripts_SCRPTS = scripts/distrib-info \
+scripts_src_SCRPTS = scripts/distrib-info \
scripts/rootshell \
scripts/save_s_context \
scripts/vprofile \
scripts/vservers.grabinfo.sh \
scripts/vsysvwrapper \
scripts/vunify.old.sh
+scripts_gen_SCRPTS =
-scripts_PRGS = scripts/vkill \
- scripts/vps \
- scripts/vpstree \
+scripts_src_PRGS = scripts/vpstree \
scripts/vrpm \
scripts/vserver \
scripts/vserver-copy \
scripts/vtop
+scripts_gen_PRGS = scripts/vkill \
+ scripts/vps
+
+scripts_PRGS = $(scripts_src_PRGS) $(scripts_gen_PRGS)
scriptscfg_DATA = scripts/util-vserver-vars
+scripts_SCRPTS = $(scripts_src_SCRPTS) $(scripts_gen_SCRPTS)
+
+scripts_XTRAS = scripts/util-vserver-vars.subst \
+ scripts/vkill.subst \
+ scripts/vps.subst \
+ $(scripts_src_SCRPTS) $(scripts_src_PRGS)
-scripts_XTRAS = scripts/util-vserver-vars.subst
-scripts_GENSCRPTS = scripts/util-vserver-vars
+scripts_GENSCRPTS = scripts/util-vserver-vars \
+ $(scripts_gen_SCRPTS) $(scripts_gen_PRGS)
scripts/%: scripts/%.subst
@mkdir -p $$(dirname '$@')
sed -e 's!@'PKGLIBDIR'@!$(pkglibdir)!g; \
s!@'SBINDIR'@!$(sbindir)!g' '$<' >'$@.tmp'
+ @-chmod --reference='$<' '$@.tmp'
@-rm -f '$@'
mv '$@.tmp' '$@'
@chmod a-w '$@'
-#!/bin/sh
+#!/bin/bash
# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
# based on distrib-info by Jacques Gelinas
# distrib-info vserver1 pkgversion
# If vserver1 is a redhat system, it executes
# rpm -qa --queryformat "%{name}=%{version}-%{release}
-USR_LIB_VSERVER=$(dirname $0)
+: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
+test -e "$UTIL_VSERVER_VARS" || {
+ echo "Can not find util-vserver installation; aborting..."
+ exit 1
+}
+. "$UTIL_VSERVER_VARS"
if [ "$1" = "" ] ; then
echo distrib-info vserver-name command [ args ... ] >&2
CHROOTCMD=
elif [ -d "$1" ] ; then
DISTDIR=$1
- CHROOTCMD="/usr/sbin/chroot $DISTDIR"
+ CHROOTCMD="$SBINDIR/chroot $DISTDIR"
else
DISTDIR=/vservers/$1
- CHROOTCMD="/usr/sbin/chroot $DISTDIR"
+ CHROOTCMD="$SBINDIR/chroot $DISTDIR"
fi
KEY=$2
shift
# We remove /etc and /var/log to make sure no special file
# there will be unified
$CHROOTCMD /bin/rpm -ql --dump $* \
- | $USR_LIB_VSERVER/parserpmdump /etc/
+ | $PKGLIBDIR/parserpmdump /etc/
;;
dumpfiles)
$CHROOTCMD /bin/rpm -ql $*
# 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:=$(dirname $0)/util-vserver-vars}
+test -e "$UTIL_VSERVER_VARS" || {
+ echo "Can not find util-vserver installation; aborting..."
+ exit 1
+}
+. "$UTIL_VSERVER_VARS"
-echo $* >/tmp/log
OPTIONS=$@
if [ "$OPTIONS" = "" ] ; then
OPTIONS=--login
fi
-exec /usr/sbin/chbind --silent --ip 0.0.0.0 /bin/bash $OPTIONS
+exec $SBINDIR/chbind --silent --ip 0.0.0.0 /bin/bash $OPTIONS
$PROC = $ARGV[0];
# Grab the output from a context query against this process id
-open(PH, "/usr/sbin/chcontext --silent --ctx 1 cat /proc/$PROC/status 2>&1 |");
+open(PH, "@SBINDIR@/chcontext --silent --ctx 1 cat /proc/$PROC/status 2>&1 |");
# Loop through the output
while (<PH>) {
# Since we have the context and the process id, we can kill it
print " + Killing... ";
- `/usr/sbin/chcontext --ctx $1 kill $PROC`;
+ `@SBINDIR@/chcontext --ctx $1 kill $PROC`;
print "[done]\n";
} else {
exit;
}
if ($context != 1) {
- exec("/usr/sbin/chcontext --silent --ctx 1 $0 @ARGV");
+ exec("@SBINDIR@/chcontext --silent --ctx 1 $0 @ARGV");
print "Can not execute chcontext\n";
exit; # not reached
}
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#Presents the processes running in all virtual servers
-exec /usr/sbin/chcontext --silent --ctx 1 pstree $*
+: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
+test -e "$UTIL_VSERVER_VARS" || {
+ echo "Can not find util-vserver installation; aborting..."
+ exit 1
+}
+. "$UTIL_VSERVER_VARS"
+
+exec $SBINDIR/chcontext --silent --ctx 1 pstree $*
fi
#echo rpm --root /vservers/$serv $*
echo Updating server $serv
- /usr/sbin/chcontext --silent $CTXOPT rpm --root /vservers/$serv $*
+ $SBINDIR/chcontext --silent $CTXOPT rpm --root /vservers/$serv $*
done
if [ "$UNIFY" = "yes" ] ; then
PACKAGES=
-#!/bin/sh
+#!/bin/bash
# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
# based on vserver by Jacques Gelinas
fi
mkdir -p /vservers/$1 || exit 1
chmod 755 /vservers/$1
- mkdir -p /vservers/$1/{etc/rc.d/init.d,sbin,var/run,var/log}
+ if test "$UTIL_VSERVER_AVOID_COPY"; then
+ mkdir -p /vservers/$1/{etc/rc.d/init.d,sbin,var/run,var/log}
+ else
+ cp -ax /sbin /bin /etc /usr /var /lib /vservers/$1/. || exit 1
+ fi
cd /vservers/$1 || exit 1
rm -fr lib/modules/*
rm -f var/spool/mail/*
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="-H -u 200"
+# ULIMIT="-HS -u 200"
# The example above, combined with the nproc S_FLAGS will limit the
# vserver to a maximum of 200 processes
-ULIMIT="-H -u 1000"
+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
exec $0 $NODEV $SILENT $VSERVER exec /sbin/service "$@"
elif [ "$2" = "chkconfig" ] ; then
VSERVER=$1
+ LEVELS=()
shift
shift
if [ "$1" = "--level" ] ; then
- shift
- LEVELS=$1
- shift
+ LEVELS=( --level "$2" )
+ shift 2
fi
if [ $# != 2 -a ! -x /vservers/$VSERVER/sbin/chkconfig ] ; then
echo Invalid argument, expected vserver name chkconfig [ --level nnn ] service on\|off
elif [ -x /vservers/$VSERVER/sbin/chkconfig ] ; then
- exec $0 --silent $VSERVER exec /sbin/chkconfig "$@"
+ exec $0 --silent $VSERVER exec /sbin/chkconfig "${LEVELS[@]}" "$@"
elif [ -x /vservers/$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
# 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:=$(dirname $0)/util-vserver-vars}
+test -e "$UTIL_VSERVER_VARS" || {
+ echo "Can not find util-vserver installation; aborting..."
+ exit 1
+}
+. "$UTIL_VSERVER_VARS"
+
VERSION="0.4"
umask 022
me=${0##*/}
fi
# This works both locally and remote
-if ($shcmd $dhost /usr/sbin/vserver $newname running | grep 'is running'); then
+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
if $stopstart; then
info "Stopping virtual server \"$vserver\" on localhost"
- /usr/sbin/vserver $vserver stop
+ $SBINDIR/vserver $vserver stop
fi
info "Syncing directories"
if $stopstart; then
info "Starting virtual server \"$vserver\" on $dhost"
- $shcmd $dhost /usr/sbin/vserver $vserver start
- if ($shcmd $dhost /usr/sbin/vserver $vserver running | \
+ $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
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Helper script for all the v_xxx scripts
-USR_SBIN=/usr/sbin
+: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
+test -e "$UTIL_VSERVER_VARS" || {
+ echo "Can not find util-vserver installation; aborting..."
+ exit 1
+}
+. "$UTIL_VSERVER_VARS"
+
if [ $# = 0 ] ; then
echo vsysvwrapper service_name >&2
else
do
IPOPT="$IPOPT --ip $oneip"
done
- echo exec $USR_SBIN/chbind $IPOPT /etc/init.d/$SERVICE $*
- exec $USR_SBIN/chbind $IPOPT /etc/init.d/$SERVICE $*
+ echo exec $SBINDIR/chbind $IPOPT /etc/init.d/$SERVICE $*
+ exec $SBINDIR/chbind $IPOPT /etc/init.d/$SERVICE $*
fi
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#Presents the processes running in all virtual servers
-exec /usr/sbin/chcontext --silent --ctx 1 top $*
-
+: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
+test -e "$UTIL_VSERVER_VARS" || {
+ echo "Can not find util-vserver installation; aborting..."
+ exit 1
+}
+. "$UTIL_VSERVER_VARS"
+exec $SBINDIR/chcontext --silent --ctx 1 top $*
--- /dev/null
+.deps
+.dirstamp
+capchroot
+chbind
+chcontext
+fakerunlevel
+filetime
+ifspec
+listdevip
+parserpmdump
+readlink
+rebootmgr
+reducecap
+setctxlimit
+showattr
+showperm
+vbuild
+vcheck
+vdu
+vfiles
+vreboot
+vserver-stat
+vunify
src_HDRS = src/vutil.h src/vutil.p
+src_pkglib_SCRPTS = src/setattr
src_pkglib_PRGS = src/capchroot \
src/fakerunlevel \
src/filetime \
src/chcontext \
src/rebootmgr \
src/reducecap \
- src/setctxlimit \
src/vdu \
src/vfiles \
src/vserver-stat
src_listdevip_SOURCES = src/listdevip.c
src_parserpmdump_SOURCES = src/parserpmdump.c
src_readlink_SOURCES = src/readlink.c
+
src_rebootmgr_SOURCES = src/rebootmgr.c
+src_rebootmgr_CPPFLAGS = $(AM_CPPFLAGS) -DSBINDIR=\"$(sbindir)\"
src_reducecap_SOURCES = src/reducecap.c
src_reducecap_LDADD = lib/libvserver.a
-src_setctxlimit_SOURCES = src/setctxlimit.c
-src_setctxlimit_LDADD = lib/libvserver.a
-
src_showattr_SOURCES = src/showattr.c
src_showperm_SOURCES = src/showperm.c
src_vbuild_SOURCES = src/vbuild.cc src/vutil.cc
src_vunify_SOURCES = src/vunify.cc src/vutil.cc
src_vcheck_SOURCES = src/vcheck.cc src/vutil.cc
+#install-data-hook: $(DESTDIR)$(pkglibdir)/setattr
+
+#$(DESTDIR)$(pkglibdir)/setattr:
+# ln -s showattr '$@'
+
+src/setattr$(EXEEXT): src/showattr$(EXEEXT)
+ @rm -f '$@'
+ ln -s showattr$(EXEEXT) '$@'
## Local Variables:
## compile-command: "make -C .. -k"
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 "compat.h"
+
#include <stdio.h>
#include <string.h>
#include <pwd.h>
#include "linuxcaps.h"
#include "vserver.h"
-static int my_chroot(const char *dir)
-{
- int ret = -1;
- if (has_chrootsafe()){
- ret = call_chrootsafe(dir);
- }else{
- //fprintf (stderr,"Kernel do not support chrootsafe(), using chroot()\n");
- ret = chroot (dir);
- }
- return ret;
-}
-
int main (int argc, char *argv[])
{
if (argc < 3){
// and also a security flaw. The shared objects in the vserver
// may be tweaked to get control of the root server ...
getpwnam ("root");
- if (my_chroot (argv[dir]) == -1){
+ if (vc_chrootsafe (argv[dir]) == -1){
fprintf (stderr,"Can't chroot to directory %s (%s)\n",argv[dir]
,strerror(errno));
}else{
int cmd = dir + 1;
if (nochroot){
- call_new_s_context (0,NULL,1<<CAP_SYS_CHROOT,0);
+ vc_new_s_context (-2,1<<CAP_SYS_CHROOT,0);
}
if (uid != NULL && strcmp(uid,"root")!=0){
// 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
int ret = -1;
int silent = 0;
int i;
- unsigned long addrs[16],masks[16];
+ struct vc_ip_mask_pair ips[16];
int nbaddrs = 0;
unsigned long bcast = 0xffffffff;
for (i=1; i<argc; i++){
usage();
}else{
memcpy (&addr,h->h_addr,sizeof(addr));
- masks[nbaddrs] = mask;
- addrs[nbaddrs++] = addr;
+ ips[nbaddrs].ip = addr;
+ ips[nbaddrs].mask = mask;
+ ++nbaddrs;
}
}else{
- masks[nbaddrs] = mask;
- addrs[nbaddrs++] = addr;
+ ips[nbaddrs].ip = addr;
+ ips[nbaddrs].mask = mask;
+ ++nbaddrs;
}
i++;
}else if (strcmp(arg,"--bcast")==0){
}else if (argv[i][0] == '-'){
usage();
}else{
- if (call_set_ipv4root(addrs,nbaddrs,bcast,masks)==0){
+ if (vc_set_ipv4root(bcast,nbaddrs,ips)==0){
if (!silent){
int i;
printf ("ipv4root is now");
for (i=0; i<nbaddrs; i++){
- unsigned long hostaddr = ntohl(addrs[i]);
+ unsigned long hostaddr = ntohl(ips[i].ip);
printf (" %ld.%ld.%ld.%ld"
,hostaddr>>24
,(hostaddr>>16)&0xff
does little more than mapping command line option to the system call
arguments.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include "compat.h"
+
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "linuxcaps.h"
#include "vserver.h"
+#ifndef CAP_QUOTACTL
+# define CAP_QUOTACTL 29
+#endif
+
static void usage()
{
fprintf (stderr,"chcontext version %s\n",VERSION);
|(1<<CAP_SYS_NICE)
|(1<<CAP_SYS_RESOURCE)
|(1<<CAP_SYS_TIME)
- |(1<<CAP_MKNOD);
+ |(1<<CAP_MKNOD)
+ |(1<<CAP_QUOTACTL);
const char *hostname=NULL, *domainname=NULL;
for (i=1; i<argc; i++){
{"CAP_SYS_RESOURCE",CAP_SYS_RESOURCE},
{"CAP_SYS_TIME", CAP_SYS_TIME},
{"CAP_MKNOD", CAP_MKNOD},
+ {"CAP_QUOTACTL", CAP_QUOTACTL},
{NULL,0}
};
int j;
if (disconnect == 0 || fork()==0){
int newctx;
if (nbctx == 0) ctxs[nbctx++] = -1;
- newctx = call_new_s_context(nbctx,ctxs,0,flags);
+ newctx = vc_new_s_context(ctxs[0],0,flags);
if (newctx != -1){
if (hostname != NULL){
if (sethostname (hostname,strlen(hostname))==-1){
}
}
remove_cap &= (~add_cap);
- if (remove_cap != 0) call_new_s_context (0,NULL,remove_cap,0);
+ if (remove_cap != 0) vc_new_s_context (-2,remove_cap,0);
if (!silent){
printf ("New security context is %d\n"
,ctxs[0] == -1 ? newctx : ctxs[0]);
The vreboot utility is used to send the signal from the vserver
environment.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include "compat.h"
+
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
if (strcmp(buf,"reboot\n")==0){
char cmd[1000];
syslog (LOG_NOTICE,"reboot vserver %s\n",vname);
- snprintf (cmd,sizeof(cmd)-1,"/usr/sbin/vserver %s restart >>/var/log/boot.log 2>&1",vname);
+ snprintf (cmd,sizeof(cmd)-1,"%s/vserver %s restart >>/var/log/boot.log 2>&1",SBINDIR, 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,"/usr/sbin/vserver %s stop >>/var/log/boot.log 2>&1",vname);
+ snprintf (cmd,sizeof(cmd)-1,"%s/vserver %s stop >>/var/log/boot.log 2>&1",SBINDIR, vname);
system (cmd);
ret = 0;
}else{
int fd = sockets[i];
if (FD_ISSET(fd,&fdin)){
struct sockaddr_un unc;
- size_t len = sizeof(unc);
+ socklen_t len = sizeof(unc);
unc.sun_family = AF_UNIX;
fd = accept (fd,(struct sockaddr*)&unc,&len);
if (fd != -1){
// 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 <stdio.h>
#include <errno.h>
#include <unistd.h>
#include "linuxcaps.h"
#include "vserver.h"
+#ifndef CAP_QUOTACTL
+# define CAP_QUOTACTL 29
+#endif
+
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 *);
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
- "CAP_OPENDEV",
+ "CAP_QUOTACTL",
NULL
};
int i;
|(1<<CAP_SYS_NICE)
|(1<<CAP_SYS_RESOURCE)
|(1<<CAP_SYS_TIME)
- |(1<<CAP_MKNOD);
+ |(1<<CAP_MKNOD)
+ |(1<<CAP_QUOTACTL);
int i;
for (i=1; i<argc; i++){
const char *arg = argv[i];
{"--SYS_RESOURCE",CAP_SYS_RESOURCE},
{"--SYS_TIME", CAP_SYS_TIME},
{"--MKNOD", CAP_MKNOD},
+ {"--QUOTACTL", CAP_QUOTACTL},
{NULL,0}
};
int j;
if (show){
reducecap_print (&user);
}
- if (call_new_s_context(0,NULL,remove,flags)==-1){
+ if (vc_new_s_context(-2,remove,flags)==-1){
perror ("new_s_context -2");
}else{
fprintf (stderr,"Executing\n");
2001-11-20 added vmsize, rss, stime and utime stat
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include "compat.h"
+
+#include "vserver.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define CTX_DIR_NAME "/var/run/vservers/"
#define CTX_NAME_MAX_LEN 50
-int call_new_s_context(int nbctx, int ctxs[], int remove_cap, int flags);
-
-
struct ctx_list
{
int ctx;
DIR *proc_dir;
struct dirent *dir_entry;
pid_t my_pid;
- static int ctx1[]={1};
// for error msg
process_name = argv[0];
my_pid = getpid();
// try to switch in context 1
- if (call_new_s_context(1,ctx1, 0, 0) < 0)
+ if (vc_new_s_context(1,0, 0) < 0)
{
fprintf(stderr, "%s: unable to switch in context security #1\n", process_name);
return -1;
--- /dev/null
+rebootmgr
+v_gated
+v_httpd
+v_named
+v_portmap
+v_sendmail
+v_smb
+v_sshd
+v_xinetd
+vservers
sysv/%: sysv/%.subst
@mkdir -p $$(dirname '$@')
- sed -s 's!/usr/lib/util-vserver!$(pkglibdir)!g; \
+ sed -e 's!/usr/lib/util-vserver!$(pkglibdir)!g; \
s!^USR_SBIN=/usr/sbin$$!USR_SBIN=$(sbindir)!g' '$<' >'$@.tmp'
if cmp -s '$<' '$@.tmp'; then \
cp -p '$<' '$@'; \
--- /dev/null
+.deps
+.dirstamp
+chrootsafe
+escaperoot
+forkbomb
+testipc
+testlimit
+testopenf
chrootsafe /vservers/test
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include "compat.h"
+
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
// This test must fail
int fd = open ("/",O_RDONLY);
if (fd != -1){
- if (call_chrootsafe(argv[1])==-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");
close (fd);
}
// Now it should work
- if (call_chrootsafe(argv[1])!=-1){
+ if (vc_chrootsafe(argv[1])!=-1){
fprintf (stderr,"Ok, chrootsafe worked\n");
system ("/bin/sh");
}else{
Summary: Linux virtual server utilities
Name: @PACKAGE@
Version: @VERSION@
-Release: 1
+Release: 0
Epoch: 0
Copyright: GPL
Group: System Environment/Base
-Source: %name-%version.tar.bz2
+URL: http://savannah.nongnu.org/projects/util-vserver/
+Source0: http://savannah.nongnu.org/download/util-vserver/stable.pkg/%version/%name-%version.tar.bz2
Provides: %name-devel = %epoch:%version-%release
BuildRoot: %_tmppath/%name-%version-%release-root
Provides: vserver = %epoch:%version-%release
Conflicts: vserver < %epoch:%version
+%package linuxconf
+Summary: Linuxconf administration modules for vservers
+Group: Applications/System
+Requires: %name = %epoch:%version-%release
+
%description
This package provides the components and a framework to setup virtual
set_ipv4root system call.
+%description linuxconf
+This package provides the components to setup virtual servers with
+linuxconf.
+
+
%prep
%setup -q
rm -rf $RPM_BUILD_ROOT
%__make DESTDIR=$RPM_BUILD_ROOT install
+test "%_initrddir" = %_sysconfdir/init.d || {
+ mkdir -p ${RPM_BUILD_ROOT}%_initrddir
+ mv ${RPM_BUILD_ROOT}%_sysconfdir/init.d/* ${RPM_BUILD_ROOT}%_initrddir/
+}
+
%clean
rm -rf $RPM_BUILD_ROOT
%_includedir/vserver.h
%_libdir/libvserver.a
%_mandir/man8/*
-%config /etc/init.d/*
-%config(noreplace) /etc/vservers/newvserver.defaults
+%config %_initrddir/*
%config(noreplace) /etc/vservers.conf
+%exclude %_sbindir/newvserver
+%exclude %_mandir/man8/newvserver*
+
+
+%files linuxconf
+%defattr(-,root,root)
+%config(noreplace) /etc/vservers/newvserver.defaults
+%_sbindir/newvserver
+%_mandir/man8/newvserver*
+
%changelog