use $(LIBENSCVECTOR) instead of libensc_vector.a
[util-vserver.git] / util-vserver / src / reducecap.c
index bf56eb9..2567ebd 100644 (file)
 #include <getopt.h>
 #include <sys/param.h>
 
-#include "linuxcaps.h"
-
 #define ENSC_WRAPPERS_PREFIX   "reducecap: "
 #define ENSC_WRAPPERS_VSERVER  1
 #define ENSC_WRAPPERS_UNISTD   1
 #include <wrappers.h>
 
 
+#undef _POSIX_SOURCE
+#include "capability-compat.h"
+
+
 #define CMD_HELP       0x1000
 #define CMD_VERSION    0x1001
 
@@ -138,9 +140,6 @@ CMDLINE_OPTIONS[] = {
 
 int wrapper_exit_code  = 255;
 
-extern int capget (struct __user_cap_header_struct *, struct __user_cap_data_struct *);
-extern int capset (struct __user_cap_header_struct *, struct __user_cap_data_struct *);
-
 static void
 showHelp(int fd, char const *cmd, int res)
 {
@@ -188,7 +187,7 @@ printReducecap(struct __user_cap_data_struct *user)
     buf[23 + 10*0 + 4] = (user->effective   & bit) ? 'X' : ' ';
     buf[23 + 10*1 + 4] = (user->permitted   & bit) ? 'X' : ' ';
     buf[23 + 10*2 + 4] = (user->inheritable & bit) ? 'X' : ' ';
-    write(1, buf, len);
+    Vwrite(1, buf, len);
   }
 }
 
@@ -227,7 +226,9 @@ int main (int argc, char *argv[])
   bool                 do_show = false;
   uint32_t             flags   = 0;
   pid_t                        pid     = 0;
+#ifdef VC_ENABLE_API_LEGACY
   bool                 show_obsolete_warning = true;
+#endif    
 
   while (1) {
     int                c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
@@ -247,18 +248,17 @@ 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_securecaps(); break;
+      case CMD_SECURE          :  remove  = vc_get_insecurebcaps(); break;
       case CMD_SHOW            :  do_show = true;  break; 
       case CMD_PID             :  pid     = atoi(optarg);   break;
       case CMD_CAP             :  remove  = getCap(optarg); break;
       case CMD_FLAG            : {
-       char const      *err_ptr;
-       size_t          err_len;
+       struct vc_err_listparser        err;
        
-       flags = vc_list2flag_compat(optarg, 0, &err_ptr, &err_len);
-       if (err_ptr!=0) {
+       flags = vc_list2cflag_compat(optarg, 0, &err);
+       if (err.ptr!=0) {
          WRITE_MSG(2, "Unknown flag '");
-         write(2, err_ptr, err_len);
+         Vwrite(2, err.ptr, err.len);
          WRITE_MSG(2, "'\n");
          exit(wrapper_exit_code);
        }