removed the C++ tools; they do not work with recent configuration and
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sat, 2 Jul 2005 09:17:55 +0000 (09:17 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sat, 2 Jul 2005 09:17:55 +0000 (09:17 +0000)
are adding huge dependencies

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2112 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/src/Makefile-files
util-vserver/src/vbuild.cc [deleted file]
util-vserver/src/vcheck.cc [deleted file]
util-vserver/src/vfiles.cc [deleted file]
util-vserver/src/vserver.cc [deleted file]
util-vserver/src/vserver.hh [deleted file]
util-vserver/src/vutil.cc [deleted file]
util-vserver/src/vutil.h [deleted file]
util-vserver/src/vutil.p [deleted file]

index 813d344..277ec1e 100644 (file)
@@ -17,8 +17,8 @@
 ## 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_sbin_CXX_PROGS =   
+src_pkglib_CXX_PROGS = 
 
 src_pkglib_C99_PROGS = src/vunify src/vcopy
 
@@ -80,8 +80,7 @@ if ENSC_CAN_BEECRYPT_WITH_DIETLIBC
 DIETPROGS +=           src/vhashify
 endif
 
-noinst_HEADERS +=      src/vutil.h src/vutil.p \
-                       src/capability-compat.h \
+noinst_HEADERS +=      src/capability-compat.h \
                        src/util.h \
                        src/fstool.h \
                        src/compat-pivot_root.h \
@@ -92,8 +91,7 @@ noinst_HEADERS +=     src/vutil.h src/vutil.p \
                        src/vhashify.h \
                        src/vhashify-init.hc \
                        src/vserver-visitdir.hc \
-                       src/context-sync.hc \
-                       src/vserver.hh
+                       src/context-sync.hc
 
 pkglib_PROGRAMS +=     src/capchroot \
                        src/chain-echo \
@@ -244,10 +242,6 @@ 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) 
diff --git a/util-vserver/src/vbuild.cc b/util-vserver/src/vbuild.cc
deleted file mode 100644 (file)
index 706ce3e..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-// $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;
-}
-
-
diff --git a/util-vserver/src/vcheck.cc b/util-vserver/src/vcheck.cc
deleted file mode 100644 (file)
index bd0c5bf..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-// $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;
-}
-
-
-
diff --git a/util-vserver/src/vfiles.cc b/util-vserver/src/vfiles.cc
deleted file mode 100644 (file)
index ce301af..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-// $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;
-}
-
-
-
diff --git a/util-vserver/src/vserver.cc b/util-vserver/src/vserver.cc
deleted file mode 100644 (file)
index 920ff9c..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-// $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();
-}
diff --git a/util-vserver/src/vserver.hh b/util-vserver/src/vserver.hh
deleted file mode 100644 (file)
index 3e8e8a1..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// $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
diff --git a/util-vserver/src/vutil.cc b/util-vserver/src/vutil.cc
deleted file mode 100644 (file)
index f6e6f96..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-// $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;
-}
diff --git a/util-vserver/src/vutil.h b/util-vserver/src/vutil.h
deleted file mode 100644 (file)
index 276858f..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-// $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
-
diff --git a/util-vserver/src/vutil.p b/util-vserver/src/vutil.p
deleted file mode 100644 (file)
index ca9e4fe..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// $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);