added capability support
[util-vserver.git] / util-vserver / lib / vserver.h
1 // $Id$
2
3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 //  
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2, or (at your option)
8 // any later version.
9 //  
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //  
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 #ifndef H_VSERVER_SYSCALL_H
20 #define H_VSERVER_SYSCALL_H
21
22 #include <stdint.h>
23 #include <stdlib.h>
24 #include <sys/types.h>
25
26 #ifndef VC_NOCTX
27 #  define VC_NOCTX      ((ctx_t)(-1))
28 #endif
29
30 #ifndef S_CTX_INFO_LOCK
31 #  define S_CTX_INFO_LOCK       1
32 #endif
33
34 #ifndef S_CTX_INFO_SCHED
35 #  define S_CTX_INFO_SCHED      2
36 #endif
37
38 #ifndef S_CTX_INFO_NPROC
39 #  define S_CTX_INFO_NPROC      4
40 #endif
41
42 #ifndef S_CTX_INFO_PRIVATE
43 #  define S_CTX_INFO_PRIVATE    8
44 #endif
45
46 #ifndef S_CTX_INFO_INIT
47 #  define S_CTX_INFO_INIT       16
48 #endif
49
50 #ifndef S_CTX_INFO_HIDEINFO
51 #  define S_CTX_INFO_HIDEINFO   32
52 #endif
53
54 #ifndef S_CTX_INFO_ULIMIT
55 #  define S_CTX_INFO_ULIMIT     64
56 #endif
57
58 #define VC_CAP_CHOWN                     0
59 #define VC_CAP_DAC_OVERRIDE              1
60 #define VC_CAP_DAC_READ_SEARCH           2
61 #define VC_CAP_FOWNER                    3
62 #define VC_CAP_FSETID                    4
63 #define VC_CAP_KILL                      5
64 #define VC_CAP_SETGID                    6
65 #define VC_CAP_SETUID                    7
66 #define VC_CAP_SETPCAP                   8
67 #define VC_CAP_LINUX_IMMUTABLE           9
68 #define VC_CAP_NET_BIND_SERVICE         10
69 #define VC_CAP_NET_BROADCAST            11
70 #define VC_CAP_NET_ADMIN                12
71 #define VC_CAP_NET_RAW                  13
72 #define VC_CAP_IPC_LOCK                 14
73 #define VC_CAP_IPC_OWNER                15
74 #define VC_CAP_SYS_MODULE               16
75 #define VC_CAP_SYS_RAWIO                17
76 #define VC_CAP_SYS_CHROOT               18
77 #define VC_CAP_SYS_PTRACE               19
78 #define VC_CAP_SYS_PACCT                20
79 #define VC_CAP_SYS_ADMIN                21
80 #define VC_CAP_SYS_BOOT                 22
81 #define VC_CAP_SYS_NICE                 23
82 #define VC_CAP_SYS_RESOURCE             24
83 #define VC_CAP_SYS_TIME                 25
84 #define VC_CAP_SYS_TTY_CONFIG           26
85 #define VC_CAP_MKNOD                    27
86 #define VC_CAP_LEASE                    28
87 #define VC_CAP_OPENDEV                  29
88
89
90 #ifdef __cplusplus
91 extern "C" {
92 #endif
93
94   struct vc_ip_mask_pair {
95     uint32_t    ip;
96     uint32_t    mask;
97   };
98
99     /** Returns version of the given API-category */
100   int   vc_get_version(int category);
101   
102     /** Puts current process into context <ctx>, removes the given caps and
103      *  sets flags.
104      *  Special values for ctx are
105      *  - -2 which means the current context (just for changing caps and flags)
106      *  - -1 which means the next free context; this value can be used by
107      *    ordinary users also */
108   int   vc_new_s_context(ctx_t ctx, unsigned int remove_cap, unsigned int flags);
109
110     /** Sets the ipv4root information.
111      *  \precondition: nb<16 */
112   int   vc_set_ipv4root(uint32_t  bcast, size_t nb, struct vc_ip_mask_pair const *ips);
113   
114   int   vc_chrootsafe(char const *dir);
115
116
117     /** Returns the context of the given process. pid==0 means the current process. */
118   ctx_t vc_X_getctx(pid_t pid);
119
120     /** Returns the pid of the 'init' process */
121   pid_t vc_X_getinitpid(pid_t pid);
122
123
124   int           vc_text2cap(char const *);
125   char const *  vc_cap2text(int);
126   
127 #ifdef __cplusplus
128 }
129 #endif
130
131 #endif