added some workarounds so that it build without compat/legacy API
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sun, 22 Jan 2006 18:15:21 +0000 (18:15 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sun, 22 Jan 2006 18:15:21 +0000 (18:15 +0000)
resp. give out warnings explaining the situation

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

util-vserver/src/capchroot.c
util-vserver/src/chcontext.c
util-vserver/src/reducecap.c

index e151bb2..dd1dc74 100644 (file)
@@ -66,6 +66,11 @@ static void
 showHelp(int fd, char const *cmd, int res)
 {
   VSERVER_DECLARE_CMD(cmd);
+
+#if !defined(VC_ENABLE_API_COMPAT) && !defined(VC_ENABLE_API_LEGACY)
+  WRITE_MSG(2, "ERROR: tools were built without legacy API support; capchroot will not work!\n\n");
+#endif
+  
   WRITE_MSG(fd, "Usage:  ");
   WRITE_STR(fd, cmd);
   WRITE_MSG(fd,
@@ -92,7 +97,7 @@ showVersion()
   exit(0);
 }
 
-static void
+static UNUSED void
 setUser(char const *user)
 {
   struct passwd                *p = 0;
@@ -141,6 +146,7 @@ int main (int argc, char *argv[])
     }
   }
 
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
   if (optind==argc)
     WRITE_MSG(2, "No directory specified; try '--help' for more information\n");
   else if (optind+1==argc)
@@ -159,6 +165,9 @@ int main (int argc, char *argv[])
     setUser(suid_user);
     EexecvpD(argv[optind+1], argv+optind+1);
   }
-
+#else
+  WRITE_MSG(2, "capchroot: tools were built without legacy API support; can not continue\n");
+#endif
+  
   return EXIT_FAILURE;
 }
index 0e0ae48..c63b1eb 100644 (file)
@@ -95,6 +95,10 @@ static void
 showHelp(int fd, char const *cmd, int res)
 {
   VSERVER_DECLARE_CMD(cmd);
+
+#if !defined(VC_ENABLE_API_COMPAT) && !defined(VC_ENABLE_API_LEGACY)
+  WRITE_MSG(2, "ERROR: tools were built without legacy API support; chcontext will not work!\n\n");
+#endif
   
   WRITE_MSG(fd, "Usage: ");
   WRITE_STR(fd, cmd);
@@ -178,6 +182,8 @@ showVersion()
   exit(0);
 }
 
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
+
 static inline void
 setCap(char const *str, uint32_t *add_caps, uint32_t *remove_caps)
 {
@@ -266,6 +272,9 @@ tellContext(xid_t ctx)
 
 #include "context-sync.hc"
 
+#endif
+
+
 int main (int argc, char *argv[])
 {
   struct Arguments args = {
@@ -278,10 +287,13 @@ int main (int argc, char *argv[])
     .hostname      = 0,
     .domainname    = 0
   };
+
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
   xid_t                newctx;
   int          xflags;
   int          p[2][2];
   pid_t                pid;
+#endif
   
   global_args = &args;
   signal(SIGCHLD, SIG_DFL);
@@ -298,6 +310,7 @@ int main (int argc, char *argv[])
       case CMD_DOMAINNAME      :  args.domainname    = optarg; break;
       case CMD_HOSTNAME                :  args.hostname      = optarg; break;
        
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
       case CMD_CAP             :
        setCap(optarg, &args.add_caps, &args.remove_caps);
        break;
@@ -316,7 +329,12 @@ int main (int argc, char *argv[])
        }
        args.ctxs[args.nbctx++] = Evc_xidopt2xid(optarg, true);
        break;
-
+#else
+      case CMD_CAP             :
+      case CMD_SECURE          :
+      case CMD_FLAG            :
+      case CMD_CTX             :  break;
+#endif 
          
       default          :
        WRITE_MSG(2, "Try '");
@@ -327,6 +345,7 @@ int main (int argc, char *argv[])
     }
   }
 
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
   if (optind>=argc) {
     WRITE_MSG(2, "No command given; use '--help' for more information.\n");
     exit(255);
@@ -364,8 +383,14 @@ int main (int argc, char *argv[])
 
   waitOnSync(pid, p, args.ctxs[0]!=VC_DYNAMIC_XID);
   return EXIT_SUCCESS;
+#else
+  WRITE_MSG(2, "chcontext: tools were built without legacy API support; can not continue\n");
+  return EXIT_FAILURE;
+#endif
 }
 
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
+
 #ifdef ENSC_TESTSUITE
 #define FLAG_TEST(STR,EXP) \
   {                       \
@@ -394,3 +419,7 @@ test()
   CAP_TEST("!CAP_CHOWN", 0, 1);
 }
 #endif
+
+#else
+void test() {}
+#endif
index 2567ebd..fb936dd 100644 (file)
@@ -143,6 +143,10 @@ int wrapper_exit_code      = 255;
 static void
 showHelp(int fd, char const *cmd, int res)
 {
+#if !defined(VC_ENABLE_API_COMPAT) && !defined(VC_ENABLE_API_LEGACY)
+  WRITE_MSG(2, "ERROR: tools were built without legacy API support; reducecap will not work!\n\n");
+#endif
+  
   WRITE_MSG(fd, "Usage:\n  ");
   WRITE_STR(fd, cmd);
   WRITE_MSG(fd,
@@ -206,6 +210,8 @@ show(pid_t pid)
   printReducecap(&user);
 }
 
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
+
 static uint32_t
 getCap(char const *cap)
 {
@@ -220,6 +226,8 @@ getCap(char const *cap)
   return (1<<bit);
 }
 
+#endif
+
 int main (int argc, char *argv[])
 {
   uint32_t             remove  = 0;
@@ -248,9 +256,10 @@ int main (int argc, char *argv[])
     switch (c) {
       case CMD_HELP            :  showHelp(1, argv[0], 0);
       case CMD_VERSION         :  showVersion();
-      case CMD_SECURE          :  remove  = vc_get_insecurebcaps(); break;
       case CMD_SHOW            :  do_show = true;  break; 
       case CMD_PID             :  pid     = atoi(optarg);   break;
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
+      case CMD_SECURE          :  remove  = vc_get_insecurebcaps(); break;
       case CMD_CAP             :  remove  = getCap(optarg); break;
       case CMD_FLAG            : {
        struct vc_err_listparser        err;
@@ -264,6 +273,11 @@ int main (int argc, char *argv[])
        }
        break;
       }
+#else
+      case CMD_SECURE          :  
+      case CMD_CAP             :
+      case CMD_FLAG            :  flags = 0; remove = 0; break;
+#endif
     }
   }
 
@@ -279,6 +293,7 @@ int main (int argc, char *argv[])
 
   if (do_show && optind==argc)
     show(pid);
+#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
   else {
     Evc_new_s_context(VC_SAMECTX, remove, flags);
     if (do_show) show(pid);
@@ -286,6 +301,14 @@ int main (int argc, char *argv[])
     WRITE_MSG(2, "Executing\n");
     Eexecvp(argv[optind], argv+optind);
   }
-
+#else
+  else if (do_show)
+    show(pid);
+  else {
+    WRITE_MSG(2, "reducecap: tools were built without legacy API support; can not continue\n");
+    exit(wrapper_exit_code);
+  }
+#endif
+    
   return EXIT_SUCCESS;
 }