install vkill and vunify.sh into LEGACYDIR
[util-vserver.git] / util-vserver / src / capchroot.c
index 50f03bf..16ece83 100644 (file)
        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){
@@ -80,7 +73,7 @@ int main (int argc, char *argv[])
                // 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 (chroot(argv[dir]) == -1){
                        fprintf (stderr,"Can't chroot to directory %s (%s)\n",argv[dir]
                                ,strerror(errno));
                }else{
@@ -88,7 +81,7 @@ int main (int argc, char *argv[])
                        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){