use sethostname(2)/setdomainname(2) again...
[util-vserver.git] / util-vserver / src / reducecap.c
index 0efcb35..2852dcd 100644 (file)
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+#include "compat.h"
+
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "linuxcaps.h"
 #include "vserver.h"
+#include "linuxcaps.h"
+
+#ifndef CAP_QUOTACTL
+#  define CAP_QUOTACTL         VC_CAP_QUOTACTL
+#endif
 
 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 *);
@@ -38,48 +47,18 @@ static void usage()
 
 static void reducecap_print(struct __user_cap_data_struct *user)
 {
-       static const char *tb[]={
-               "CAP_CHOWN",
-               "CAP_DAC_OVERRIDE",
-               "CAP_DAC_READ_SEARCH",
-               "CAP_FOWNER",
-               "CAP_FSETID",
-               "CAP_KILL",
-               "CAP_SETGID",
-               "CAP_SETUID",
-               "CAP_SETPCAP",
-               "CAP_LINUX_IMMUTABLE",
-               "CAP_NET_BIND_SERVICE",
-               "CAP_NET_BROADCAST",
-               "CAP_NET_ADMIN",
-               "CAP_NET_RAW",
-               "CAP_IPC_LOCK",
-               "CAP_IPC_OWNER",
-               "CAP_SYS_MODULE",
-               "CAP_SYS_RAWIO",
-               "CAP_SYS_CHROOT",
-               "CAP_SYS_PTRACE",
-               "CAP_SYS_PACCT",
-               "CAP_SYS_ADMIN",
-               "CAP_SYS_BOOT",
-               "CAP_SYS_NICE",
-               "CAP_SYS_RESOURCE",
-               "CAP_SYS_TIME",
-               "CAP_SYS_TTY_CONFIG",
-               "CAP_MKNOD",
-               "CAP_LEASE",
-               "CAP_OPENDEV",
-               NULL
-       };
        int i;
        printf ("%22s %9s %9s %9s\n","Capability","Effective","Permitted"
                ,"Inheritable");
-       for (i=0; tb[i] != NULL; i++){
-               int bit = (1 << i);
-               printf ("%22s %9s %9s %9s\n"
-                       ,tb[i]
-                       ,(user->effective & bit) ? "X    " : " "
-                       ,(user->permitted & bit) ? "X    " : " "
+       for (i=0;; ++i) {
+               char const *    text = vc_cap2text(i);
+               int             bit  = 1<<i;
+               if (text==0) break;
+               
+               printf ("%-22s %9s %9s %9s\n"
+                       ,text
+                       ,(user->effective   & bit) ? "X    " : " "
+                       ,(user->permitted   & bit) ? "X    " : " "
                        ,(user->inheritable & bit) ? "X    " : " ");
        }
 }
@@ -119,7 +98,8 @@ int main (int argc, char *argv[])
                |(1<<CAP_SYS_NICE)
                |(1<<CAP_SYS_RESOURCE)
                |(1<<CAP_SYS_TIME)
-               |(1<<CAP_MKNOD);
+               |(1<<CAP_MKNOD)
+               |(1<<CAP_QUOTACTL);
        int i;
        for (i=1; i<argc; i++){
                const char *arg = argv[i];
@@ -183,6 +163,7 @@ int main (int argc, char *argv[])
                                {"--SYS_RESOURCE",CAP_SYS_RESOURCE},
                                {"--SYS_TIME",  CAP_SYS_TIME},
                                {"--MKNOD",             CAP_MKNOD},
+                               {"--QUOTACTL",          CAP_QUOTACTL},
                                {NULL,0}
                        };
                        int j;
@@ -218,7 +199,7 @@ int main (int argc, char *argv[])
                        if (show){
                                reducecap_print (&user);
                        }
-                       if (call_new_s_context(0,NULL,remove,flags)==-1){
+                       if (vc_new_s_context(VC_SAMECTX,remove,flags)==VC_NOCTX){
                                perror ("new_s_context -2");
                        }else{
                                fprintf (stderr,"Executing\n");