use real 'umount' program to unmount directories
[util-vserver.git] / util-vserver / src / rpm-fake.c
index 849c242..71706f2 100644 (file)
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#ifndef CLONE_NEWNS
+#  define CLONE_NEWNS  0x00020000
+#endif
+
 #define LIBNAME                "rpm-fake.so"
 #define PLATFORM_FILE  "/etc/rpm/platform"
 
@@ -70,6 +74,19 @@ initLib()
 {
   if (is_initialized) return;
 
+#ifdef VC_ENABLE_API_LEGACY
+  {
+    extern void vc_init_internal_legacy(int ctx_rev, int ctx_number,
+                                       int ipv4_rev, int ipv4_number);
+  
+    vc_init_internal_legacy(getAndClearEnv("RPM_FAKE_S_CONTEXT_REV", 0),
+                           getAndClearEnv("RPM_FAKE_S_CONTEXT_NR",  280),
+                           3, 281);
+  }
+#else
+  (void)getAndClearEnv("RPM_FAKE_S_CONTEXT_REV", 0);
+  (void)getAndClearEnv("RPM_FAKE_S_CONTEXT_NR",  280);
+#endif  
   INIT(RTLD_NEXT, execv);
     //INIT(RTLD_NEXT, open);
 
@@ -162,21 +179,21 @@ removeNamespaceMounts(char const *path, char * const argv[])
   if (mnts==0) return execvWorker(path, argv);
 
   {
-    char       buf[512 + 2*strlen(mnts)];
-    int                status;
-    pid_t      p;
-    struct ExecvParams         params = {
-      .path = path,
-      .argv = argv,
-      .mnts = mnts,
-    };
+    char                       buf[512 + 2*strlen(mnts)];
+    int                                status;
+    pid_t                      p, pid;
+    struct ExecvParams         params;
+
+    params.path = path;
+    params.argv = argv;
+    params.mnts = mnts;
 
       // the rpmlib signal-handler is still active; use the default one to
       // make wait4() working...
     signal(SIGCHLD, SIG_DFL);
 
-    pid_t      pid = clone(removeNamespaceMountsChild, buf+sizeof(buf)/2,
-                           CLONE_NEWNS|SIGCHLD|CLONE_VFORK, &params);
+    pid = clone(removeNamespaceMountsChild, buf+sizeof(buf)/2,
+               CLONE_NEWNS|SIGCHLD|CLONE_VFORK, &params);
 
     if (pid==-1) return -1;
     while ((p=wait4(pid, &status, 0,0))==-1 &&