use real 'umount' program to unmount directories
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Wed, 22 Oct 2003 18:23:59 +0000 (18:23 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Wed, 22 Oct 2003 18:23:59 +0000 (18:23 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@281 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/src/secure-umount.c

index e2084bd..2220ed5 100644 (file)
@@ -19,7 +19,8 @@
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
-#include "compat-pivot_root.h"
+
+#include "pathconfig.h"
 
 #include "wrappers.h"
 #include "util.h"
@@ -52,6 +53,9 @@ showVersion()
 int main(int argc, char *argv[])
 {
   char const * dir;
+  int          root_fd;
+  int          this_fd;
+  char *       umount_cmd[] = { UMOUNT_PROG, "-l", "-n", ".", 0 };
 
   if (argc<2) {
     WRITE_MSG(2, "Try '");
@@ -66,9 +70,16 @@ int main(int argc, char *argv[])
   dir = argv[1];
   if (strcmp(dir, "--")==0 && argc>=3) dir = argv[2];
 
+  root_fd = Eopen("/", O_RDONLY, 0);
+  Echroot(".");
+  Echdir(dir);
+  this_fd = Eopen(".", O_RDONLY, 0);
+  Efchdir(root_fd);
   Echroot(".");
-  Echdir("/");
+  Efchdir(this_fd);
+
+  Eclose(root_fd);
+  Eclose(this_fd);
 
-  Eumount2(dir, 0);
-  return EXIT_SUCCESS;
+  Eexecv(umount_cmd[0], umount_cmd);
 }