summaryrefslogtreecommitdiffstats
path: root/include/intercept.pb-c.h
blob: 2ea16832909448cfcd14f9fb942f253a5a07d5f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/* Generated by the protocol buffer compiler.  DO NOT EDIT! */
/* Generated from: intercept.proto */

#ifndef PROTOBUF_C_intercept_2eproto__INCLUDED
#define PROTOBUF_C_intercept_2eproto__INCLUDED

#include <protobuf-c/protobuf-c.h>

PROTOBUF_C__BEGIN_DECLS

#if PROTOBUF_C_VERSION_NUMBER < 1003000
# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers.
#elif 1004000 < PROTOBUF_C_MIN_COMPILER_VERSION
# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c.
#endif


typedef struct InterceptRequest InterceptRequest;
typedef struct InterceptHello InterceptHello;
typedef struct HelloResponse HelloResponse;
typedef struct PolicyCheckRequest PolicyCheckRequest;
typedef struct PolicyAcceptMessage PolicyAcceptMessage;
typedef struct PolicyRejectMessage PolicyRejectMessage;
typedef struct PolicyErrorMessage PolicyErrorMessage;
typedef struct InterceptResponse InterceptResponse;


/* --- enums --- */


/* --- messages --- */

typedef enum {
  INTERCEPT_REQUEST__TYPE__NOT_SET = 0,
  INTERCEPT_REQUEST__TYPE_POLICY_CHECK_REQ = 1,
  INTERCEPT_REQUEST__TYPE_HELLO = 2
    PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(INTERCEPT_REQUEST__TYPE__CASE)
} InterceptRequest__TypeCase;

/*
 * Intercept message from sudo_intercept.so.  Messages on the
 * wire are prefixed with a 32-bit size in network byte order.
 */
struct  InterceptRequest
{
  ProtobufCMessage base;
  InterceptRequest__TypeCase type_case;
  union {
    PolicyCheckRequest *policy_check_req;
    InterceptHello *hello;
  } u;
};
#define INTERCEPT_REQUEST__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&intercept_request__descriptor) \
    , INTERCEPT_REQUEST__TYPE__NOT_SET, {0} }


/*
 * Hello message from sudo_intercept.so to main sudo process.
 * Sudo sends back the token and localhost port number.
 */
struct  InterceptHello
{
  ProtobufCMessage base;
  int32_t pid;
};
#define INTERCEPT_HELLO__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&intercept_hello__descriptor) \
    , 0 }


/*
 * Sudo response to an InterceptHello from sudo_intercept.so.
 * The client uses the port number and token to connect back to sudo.
 * If log_only is set there is no InterceptResponse to a PolicyCheckRequest.
 */
struct  HelloResponse
{
  ProtobufCMessage base;
  uint64_t token_lo;
  uint64_t token_hi;
  int32_t portno;
  protobuf_c_boolean log_only;
};
#define HELLO_RESPONSE__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&hello_response__descriptor) \
    , 0, 0, 0, 0 }


/*
 * Policy check request from sudo_intercept.so.
 * Note that the plugin API only currently supports passing
 * the new environment in to the open() function.
 */
struct  PolicyCheckRequest
{
  ProtobufCMessage base;
  char *command;
  char *cwd;
  size_t n_argv;
  char **argv;
  size_t n_envp;
  char **envp;
  int32_t intercept_fd;
};
#define POLICY_CHECK_REQUEST__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&policy_check_request__descriptor) \
    , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0,NULL, 0,NULL, 0 }


struct  PolicyAcceptMessage
{
  ProtobufCMessage base;
  char *run_command;
  size_t n_run_argv;
  char **run_argv;
  size_t n_run_envp;
  char **run_envp;
};
#define POLICY_ACCEPT_MESSAGE__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&policy_accept_message__descriptor) \
    , (char *)protobuf_c_empty_string, 0,NULL, 0,NULL }


struct  PolicyRejectMessage
{
  ProtobufCMessage base;
  char *reject_message;
};
#define POLICY_REJECT_MESSAGE__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&policy_reject_message__descriptor) \
    , (char *)protobuf_c_empty_string }


struct  PolicyErrorMessage
{
  ProtobufCMessage base;
  char *error_message;
};
#define POLICY_ERROR_MESSAGE__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&policy_error_message__descriptor) \
    , (char *)protobuf_c_empty_string }


typedef enum {
  INTERCEPT_RESPONSE__TYPE__NOT_SET = 0,
  INTERCEPT_RESPONSE__TYPE_HELLO_RESP = 1,
  INTERCEPT_RESPONSE__TYPE_ACCEPT_MSG = 2,
  INTERCEPT_RESPONSE__TYPE_REJECT_MSG = 3,
  INTERCEPT_RESPONSE__TYPE_ERROR_MSG = 4
    PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(INTERCEPT_RESPONSE__TYPE__CASE)
} InterceptResponse__TypeCase;

/*
 * Response sent back to sudo_intercept.so.
 */
struct  InterceptResponse
{
  ProtobufCMessage base;
  InterceptResponse__TypeCase type_case;
  union {
    HelloResponse *hello_resp;
    PolicyAcceptMessage *accept_msg;
    PolicyRejectMessage *reject_msg;
    PolicyErrorMessage *error_msg;
  } u;
};
#define INTERCEPT_RESPONSE__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&intercept_response__descriptor) \
    , INTERCEPT_RESPONSE__TYPE__NOT_SET, {0} }


/* InterceptRequest methods */
void   intercept_request__init
                     (InterceptRequest         *message);
size_t intercept_request__get_packed_size
                     (const InterceptRequest   *message);
size_t intercept_request__pack
                     (const InterceptRequest   *message,
                      uint8_t             *out);
size_t intercept_request__pack_to_buffer
                     (const InterceptRequest   *message,
                      ProtobufCBuffer     *buffer);
InterceptRequest *
       intercept_request__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   intercept_request__free_unpacked
                     (InterceptRequest *message,
                      ProtobufCAllocator *allocator);
/* InterceptHello methods */
void   intercept_hello__init
                     (InterceptHello         *message);
size_t intercept_hello__get_packed_size
                     (const InterceptHello   *message);
size_t intercept_hello__pack
                     (const InterceptHello   *message,
                      uint8_t             *out);
size_t intercept_hello__pack_to_buffer
                     (const InterceptHello   *message,
                      ProtobufCBuffer     *buffer);
InterceptHello *
       intercept_hello__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   intercept_hello__free_unpacked
                     (InterceptHello *message,
                      ProtobufCAllocator *allocator);
/* HelloResponse methods */
void   hello_response__init
                     (HelloResponse         *message);
size_t hello_response__get_packed_size
                     (const HelloResponse   *message);
size_t hello_response__pack
                     (const HelloResponse   *message,
                      uint8_t             *out);
size_t hello_response__pack_to_buffer
                     (const HelloResponse   *message,
                      ProtobufCBuffer     *buffer);
HelloResponse *
       hello_response__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   hello_response__free_unpacked
                     (HelloResponse *message,
                      ProtobufCAllocator *allocator);
/* PolicyCheckRequest methods */
void   policy_check_request__init
                     (PolicyCheckRequest         *message);
size_t policy_check_request__get_packed_size
                     (const PolicyCheckRequest   *message);
size_t policy_check_request__pack
                     (const PolicyCheckRequest   *message,
                      uint8_t             *out);
size_t policy_check_request__pack_to_buffer
                     (const PolicyCheckRequest   *message,
                      ProtobufCBuffer     *buffer);
PolicyCheckRequest *
       policy_check_request__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   policy_check_request__free_unpacked
                     (PolicyCheckRequest *message,
                      ProtobufCAllocator *allocator);
/* PolicyAcceptMessage methods */
void   policy_accept_message__init
                     (PolicyAcceptMessage         *message);
size_t policy_accept_message__get_packed_size
                     (const PolicyAcceptMessage   *message);
size_t policy_accept_message__pack
                     (const PolicyAcceptMessage   *message,
                      uint8_t             *out);
size_t policy_accept_message__pack_to_buffer
                     (const PolicyAcceptMessage   *message,
                      ProtobufCBuffer     *buffer);
PolicyAcceptMessage *
       policy_accept_message__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   policy_accept_message__free_unpacked
                     (PolicyAcceptMessage *message,
                      ProtobufCAllocator *allocator);
/* PolicyRejectMessage methods */
void   policy_reject_message__init
                     (PolicyRejectMessage         *message);
size_t policy_reject_message__get_packed_size
                     (const PolicyRejectMessage   *message);
size_t policy_reject_message__pack
                     (const PolicyRejectMessage   *message,
                      uint8_t             *out);
size_t policy_reject_message__pack_to_buffer
                     (const PolicyRejectMessage   *message,
                      ProtobufCBuffer     *buffer);
PolicyRejectMessage *
       policy_reject_message__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   policy_reject_message__free_unpacked
                     (PolicyRejectMessage *message,
                      ProtobufCAllocator *allocator);
/* PolicyErrorMessage methods */
void   policy_error_message__init
                     (PolicyErrorMessage         *message);
size_t policy_error_message__get_packed_size
                     (const PolicyErrorMessage   *message);
size_t policy_error_message__pack
                     (const PolicyErrorMessage   *message,
                      uint8_t             *out);
size_t policy_error_message__pack_to_buffer
                     (const PolicyErrorMessage   *message,
                      ProtobufCBuffer     *buffer);
PolicyErrorMessage *
       policy_error_message__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   policy_error_message__free_unpacked
                     (PolicyErrorMessage *message,
                      ProtobufCAllocator *allocator);
/* InterceptResponse methods */
void   intercept_response__init
                     (InterceptResponse         *message);
size_t intercept_response__get_packed_size
                     (const InterceptResponse   *message);
size_t intercept_response__pack
                     (const InterceptResponse   *message,
                      uint8_t             *out);
size_t intercept_response__pack_to_buffer
                     (const InterceptResponse   *message,
                      ProtobufCBuffer     *buffer);
InterceptResponse *
       intercept_response__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   intercept_response__free_unpacked
                     (InterceptResponse *message,
                      ProtobufCAllocator *allocator);
/* --- per-message closures --- */

typedef void (*InterceptRequest_Closure)
                 (const InterceptRequest *message,
                  void *closure_data);
typedef void (*InterceptHello_Closure)
                 (const InterceptHello *message,
                  void *closure_data);
typedef void (*HelloResponse_Closure)
                 (const HelloResponse *message,
                  void *closure_data);
typedef void (*PolicyCheckRequest_Closure)
                 (const PolicyCheckRequest *message,
                  void *closure_data);
typedef void (*PolicyAcceptMessage_Closure)
                 (const PolicyAcceptMessage *message,
                  void *closure_data);
typedef void (*PolicyRejectMessage_Closure)
                 (const PolicyRejectMessage *message,
                  void *closure_data);
typedef void (*PolicyErrorMessage_Closure)
                 (const PolicyErrorMessage *message,
                  void *closure_data);
typedef void (*InterceptResponse_Closure)
                 (const InterceptResponse *message,
                  void *closure_data);

/* --- services --- */


/* --- descriptors --- */

extern const ProtobufCMessageDescriptor intercept_request__descriptor;
extern const ProtobufCMessageDescriptor intercept_hello__descriptor;
extern const ProtobufCMessageDescriptor hello_response__descriptor;
extern const ProtobufCMessageDescriptor policy_check_request__descriptor;
extern const ProtobufCMessageDescriptor policy_accept_message__descriptor;
extern const ProtobufCMessageDescriptor policy_reject_message__descriptor;
extern const ProtobufCMessageDescriptor policy_error_message__descriptor;
extern const ProtobufCMessageDescriptor intercept_response__descriptor;

PROTOBUF_C__END_DECLS


#endif  /* PROTOBUF_C_intercept_2eproto__INCLUDED */