Add NumberList to InfoMessage.

Also make comments fit in 80 columns when formatted as a man page.
This commit is contained in:
Todd C. Miller
2019-10-24 20:04:32 -06:00
parent 6c6f0567ba
commit 3b8011ea9e
3 changed files with 126 additions and 44 deletions

View File

@@ -148,6 +148,12 @@ void info_message__string_list__init
static const InfoMessage__StringList init_value = INFO_MESSAGE__STRING_LIST__INIT; static const InfoMessage__StringList init_value = INFO_MESSAGE__STRING_LIST__INIT;
*message = init_value; *message = init_value;
} }
void info_message__number_list__init
(InfoMessage__NumberList *message)
{
static const InfoMessage__NumberList init_value = INFO_MESSAGE__NUMBER_LIST__INIT;
*message = init_value;
}
void info_message__init void info_message__init
(InfoMessage *message) (InfoMessage *message)
{ {
@@ -919,7 +925,45 @@ const ProtobufCMessageDescriptor info_message__string_list__descriptor =
(ProtobufCMessageInit) info_message__string_list__init, (ProtobufCMessageInit) info_message__string_list__init,
NULL,NULL,NULL /* reserved[123] */ NULL,NULL,NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor info_message__field_descriptors[4] = static const ProtobufCFieldDescriptor info_message__number_list__field_descriptors[1] =
{
{
"numbers",
1,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_INT64,
offsetof(InfoMessage__NumberList, n_numbers),
offsetof(InfoMessage__NumberList, numbers),
NULL,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned info_message__number_list__field_indices_by_name[] = {
0, /* field[0] = numbers */
};
static const ProtobufCIntRange info_message__number_list__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor info_message__number_list__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"InfoMessage.NumberList",
"NumberList",
"InfoMessage__NumberList",
"",
sizeof(InfoMessage__NumberList),
1,
info_message__number_list__field_descriptors,
info_message__number_list__field_indices_by_name,
1, info_message__number_list__number_ranges,
(ProtobufCMessageInit) info_message__number_list__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor info_message__field_descriptors[5] =
{ {
{ {
"key", "key",
@@ -969,9 +1013,22 @@ static const ProtobufCFieldDescriptor info_message__field_descriptors[4] =
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */ 0,NULL,NULL /* reserved1,reserved2, etc */
}, },
{
"numlistval",
5,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(InfoMessage, value_case),
offsetof(InfoMessage, numlistval),
&info_message__number_list__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
}; };
static const unsigned info_message__field_indices_by_name[] = { static const unsigned info_message__field_indices_by_name[] = {
0, /* field[0] = key */ 0, /* field[0] = key */
4, /* field[4] = numlistval */
1, /* field[1] = numval */ 1, /* field[1] = numval */
3, /* field[3] = strlistval */ 3, /* field[3] = strlistval */
2, /* field[2] = strval */ 2, /* field[2] = strval */
@@ -979,7 +1036,7 @@ static const unsigned info_message__field_indices_by_name[] = {
static const ProtobufCIntRange info_message__number_ranges[1 + 1] = static const ProtobufCIntRange info_message__number_ranges[1 + 1] =
{ {
{ 1, 0 }, { 1, 0 },
{ 0, 4 } { 0, 5 }
}; };
const ProtobufCMessageDescriptor info_message__descriptor = const ProtobufCMessageDescriptor info_message__descriptor =
{ {
@@ -989,7 +1046,7 @@ const ProtobufCMessageDescriptor info_message__descriptor =
"InfoMessage", "InfoMessage",
"", "",
sizeof(InfoMessage), sizeof(InfoMessage),
4, 5,
info_message__field_descriptors, info_message__field_descriptors,
info_message__field_indices_by_name, info_message__field_indices_by_name,
1, info_message__number_ranges, 1, info_message__number_ranges,

View File

@@ -20,6 +20,7 @@ typedef struct _TimeSpec TimeSpec;
typedef struct _IoBuffer IoBuffer; typedef struct _IoBuffer IoBuffer;
typedef struct _InfoMessage InfoMessage; typedef struct _InfoMessage InfoMessage;
typedef struct _InfoMessage__StringList InfoMessage__StringList; typedef struct _InfoMessage__StringList InfoMessage__StringList;
typedef struct _InfoMessage__NumberList InfoMessage__NumberList;
typedef struct _AcceptMessage AcceptMessage; typedef struct _AcceptMessage AcceptMessage;
typedef struct _RejectMessage RejectMessage; typedef struct _RejectMessage RejectMessage;
typedef struct _ExitMessage ExitMessage; typedef struct _ExitMessage ExitMessage;
@@ -54,8 +55,8 @@ typedef enum {
} ClientMessage__TypeCase; } ClientMessage__TypeCase;
/* /*
* Client message to the server. * Client message to the server. Messages on the wire are
* Messages on the wire are prefixed with a 16-bit size in network byte order. * prefixed with a 32-bit size in network byte order.
*/ */
struct _ClientMessage struct _ClientMessage
{ {
@@ -108,7 +109,7 @@ struct _IoBuffer
{ {
ProtobufCMessage base; ProtobufCMessage base;
/* /*
* elapsed time since last record (monotonic) * elapsed time since last record
*/ */
TimeSpec *delay; TimeSpec *delay;
/* /*
@@ -132,11 +133,23 @@ struct _InfoMessage__StringList
, 0,NULL } , 0,NULL }
struct _InfoMessage__NumberList
{
ProtobufCMessage base;
size_t n_numbers;
int64_t *numbers;
};
#define INFO_MESSAGE__NUMBER_LIST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&info_message__number_list__descriptor) \
, 0,NULL }
typedef enum { typedef enum {
INFO_MESSAGE__VALUE__NOT_SET = 0, INFO_MESSAGE__VALUE__NOT_SET = 0,
INFO_MESSAGE__VALUE_NUMVAL = 2, INFO_MESSAGE__VALUE_NUMVAL = 2,
INFO_MESSAGE__VALUE_STRVAL = 3, INFO_MESSAGE__VALUE_STRVAL = 3,
INFO_MESSAGE__VALUE_STRLISTVAL = 4 INFO_MESSAGE__VALUE_STRLISTVAL = 4,
INFO_MESSAGE__VALUE_NUMLISTVAL = 5
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(INFO_MESSAGE__VALUE) PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(INFO_MESSAGE__VALUE)
} InfoMessage__ValueCase; } InfoMessage__ValueCase;
@@ -153,6 +166,7 @@ struct _InfoMessage
int64_t numval; int64_t numval;
char *strval; char *strval;
InfoMessage__StringList *strlistval; InfoMessage__StringList *strlistval;
InfoMessage__NumberList *numlistval;
}; };
}; };
#define INFO_MESSAGE__INIT \ #define INFO_MESSAGE__INIT \
@@ -167,7 +181,7 @@ struct _AcceptMessage
{ {
ProtobufCMessage base; ProtobufCMessage base;
/* /*
* time when command was submitted * when command was submitted
*/ */
TimeSpec *submit_time; TimeSpec *submit_time;
/* /*
@@ -176,7 +190,7 @@ struct _AcceptMessage
size_t n_info_msgs; size_t n_info_msgs;
InfoMessage **info_msgs; InfoMessage **info_msgs;
/* /*
* true if I/O logging is enabled * true if I/O logging enabled
*/ */
protobuf_c_boolean expect_iobufs; protobuf_c_boolean expect_iobufs;
}; };
@@ -192,11 +206,11 @@ struct _RejectMessage
{ {
ProtobufCMessage base; ProtobufCMessage base;
/* /*
* time when command was submitted * when command was submitted
*/ */
TimeSpec *submit_time; TimeSpec *submit_time;
/* /*
* reason commamd was rejected * reason command was rejected
*/ */
char *reason; char *reason;
/* /*
@@ -217,7 +231,7 @@ struct _ExitMessage
{ {
ProtobufCMessage base; ProtobufCMessage base;
/* /*
* total elapsed run time (monotonic) * total elapsed run time
*/ */
TimeSpec *run_time; TimeSpec *run_time;
/* /*
@@ -249,7 +263,7 @@ struct _AlertMessage
{ {
ProtobufCMessage base; ProtobufCMessage base;
/* /*
* time alert message ocurred * time alert message occurred
*/ */
TimeSpec *alert_time; TimeSpec *alert_time;
/* /*
@@ -273,7 +287,7 @@ struct _RestartMessage
*/ */
char *log_id; char *log_id;
/* /*
* resume point in ellaped time (monotonic) * resume point (elapsed time)
*/ */
TimeSpec *resume_point; TimeSpec *resume_point;
}; };
@@ -289,7 +303,7 @@ struct _ChangeWindowSize
{ {
ProtobufCMessage base; ProtobufCMessage base;
/* /*
* elapsed time since last record (monotonic) * elapsed time since last record
*/ */
TimeSpec *delay; TimeSpec *delay;
/* /*
@@ -313,11 +327,11 @@ struct _CommandSuspend
{ {
ProtobufCMessage base; ProtobufCMessage base;
/* /*
* elapsed time since last record (monotonic) * elapsed time since last record
*/ */
TimeSpec *delay; TimeSpec *delay;
/* /*
* signal that caused the suspend/resume * signal that caused suspend/resume
*/ */
char *signal; char *signal;
}; };
@@ -337,8 +351,8 @@ typedef enum {
} ServerMessage__TypeCase; } ServerMessage__TypeCase;
/* /*
* Server messages to the client. * Server messages to the client. Messages on the wire are
* Messages on the wire are prefixed with a 16-bit size in network byte order. * prefixed with a 32-bit size in network byte order.
*/ */
struct _ServerMessage struct _ServerMessage
{ {
@@ -354,15 +368,15 @@ struct _ServerMessage
*/ */
TimeSpec *commit_point; TimeSpec *commit_point;
/* /*
* ID of new I/O log (AcceptMessage ACK) * ID of server-side I/O log
*/ */
char *log_id; char *log_id;
/* /*
* error message from server (restartable) * error message from server
*/ */
char *error; char *error;
/* /*
* abort message from server (kill session) * abort message, kill command
*/ */
char *abort; char *abort;
}; };
@@ -383,11 +397,11 @@ struct _ServerHello
*/ */
char *server_id; char *server_id;
/* /*
* optional redirect to other server if busy * optional redirect if busy
*/ */
char *redirect; char *redirect;
/* /*
* optional list of known audit servers * optional list of known servers
*/ */
size_t n_servers; size_t n_servers;
char **servers; char **servers;
@@ -457,6 +471,9 @@ void io_buffer__free_unpacked
/* InfoMessage__StringList methods */ /* InfoMessage__StringList methods */
void info_message__string_list__init void info_message__string_list__init
(InfoMessage__StringList *message); (InfoMessage__StringList *message);
/* InfoMessage__NumberList methods */
void info_message__number_list__init
(InfoMessage__NumberList *message);
/* InfoMessage methods */ /* InfoMessage methods */
void info_message__init void info_message__init
(InfoMessage *message); (InfoMessage *message);
@@ -661,6 +678,9 @@ typedef void (*IoBuffer_Closure)
typedef void (*InfoMessage__StringList_Closure) typedef void (*InfoMessage__StringList_Closure)
(const InfoMessage__StringList *message, (const InfoMessage__StringList *message,
void *closure_data); void *closure_data);
typedef void (*InfoMessage__NumberList_Closure)
(const InfoMessage__NumberList *message,
void *closure_data);
typedef void (*InfoMessage_Closure) typedef void (*InfoMessage_Closure)
(const InfoMessage *message, (const InfoMessage *message,
void *closure_data); void *closure_data);
@@ -702,6 +722,7 @@ extern const ProtobufCMessageDescriptor time_spec__descriptor;
extern const ProtobufCMessageDescriptor io_buffer__descriptor; extern const ProtobufCMessageDescriptor io_buffer__descriptor;
extern const ProtobufCMessageDescriptor info_message__descriptor; extern const ProtobufCMessageDescriptor info_message__descriptor;
extern const ProtobufCMessageDescriptor info_message__string_list__descriptor; extern const ProtobufCMessageDescriptor info_message__string_list__descriptor;
extern const ProtobufCMessageDescriptor info_message__number_list__descriptor;
extern const ProtobufCMessageDescriptor accept_message__descriptor; extern const ProtobufCMessageDescriptor accept_message__descriptor;
extern const ProtobufCMessageDescriptor reject_message__descriptor; extern const ProtobufCMessageDescriptor reject_message__descriptor;
extern const ProtobufCMessageDescriptor exit_message__descriptor; extern const ProtobufCMessageDescriptor exit_message__descriptor;

View File

@@ -1,8 +1,8 @@
syntax = "proto3"; syntax = "proto3";
/* /*
* Client message to the server. * Client message to the server. Messages on the wire are
* Messages on the wire are prefixed with a 16-bit size in network byte order. * prefixed with a 32-bit size in network byte order.
*/ */
message ClientMessage { message ClientMessage {
oneof type { oneof type {
@@ -29,7 +29,7 @@ message TimeSpec {
/* I/O buffer with keystroke data */ /* I/O buffer with keystroke data */
message IoBuffer { message IoBuffer {
TimeSpec delay = 1; /* elapsed time since last record (monotonic) */ TimeSpec delay = 1; /* elapsed time since last record */
bytes data = 2; /* keystroke data */ bytes data = 2; /* keystroke data */
} }
@@ -41,11 +41,15 @@ message InfoMessage {
message StringList { message StringList {
repeated string strings = 1; repeated string strings = 1;
} }
message NumberList {
repeated int64 numbers = 1;
}
string key = 1; string key = 1;
oneof value { oneof value {
int64 numval = 2; int64 numval = 2;
string strval = 3; string strval = 3;
StringList strlistval = 4; StringList strlistval = 4;
NumberList numlistval = 5;
} }
} }
@@ -53,24 +57,24 @@ message InfoMessage {
* Event log data for command accepted by the policy. * Event log data for command accepted by the policy.
*/ */
message AcceptMessage { message AcceptMessage {
TimeSpec submit_time = 1; /* time when command was submitted */ TimeSpec submit_time = 1; /* when command was submitted */
repeated InfoMessage info_msgs = 2; /* key,value event log data */ repeated InfoMessage info_msgs = 2; /* key,value event log data */
bool expect_iobufs = 3; /* true if I/O logging is enabled */ bool expect_iobufs = 3; /* true if I/O logging enabled */
} }
/* /*
* Event log data for command rejected by the policy. * Event log data for command rejected by the policy.
*/ */
message RejectMessage { message RejectMessage {
TimeSpec submit_time = 1; /* time when command was submitted */ TimeSpec submit_time = 1; /* when command was submitted */
string reason = 2; /* reason commamd was rejected */ string reason = 2; /* reason command was rejected */
repeated InfoMessage info_msgs = 3; /* key,value event log data */ repeated InfoMessage info_msgs = 3; /* key,value event log data */
} }
/* Message sent by client when command exits. */ /* Message sent by client when command exits. */
/* Might revisit runtime and use end_time instead */ /* Might revisit runtime and use end_time instead */
message ExitMessage { message ExitMessage {
TimeSpec run_time = 1; /* total elapsed run time (monotonic) */ TimeSpec run_time = 1; /* total elapsed run time */
int32 exit_value = 2; /* 0-255 */ int32 exit_value = 2; /* 0-255 */
bool dumped_core = 3; /* true if command dumped core */ bool dumped_core = 3; /* true if command dumped core */
string signal = 4; /* signal name if killed by signal */ string signal = 4; /* signal name if killed by signal */
@@ -79,46 +83,46 @@ message ExitMessage {
/* Alert message, policy module-specific. */ /* Alert message, policy module-specific. */
message AlertMessage { message AlertMessage {
TimeSpec alert_time = 1; /* time alert message ocurred */ TimeSpec alert_time = 1; /* time alert message occurred */
string reason = 2; /* description of policy violation */ string reason = 2; /* description of policy violation */
} }
/* Used to restart an existing I/O log on the server. */ /* Used to restart an existing I/O log on the server. */
message RestartMessage { message RestartMessage {
string log_id = 1; /* ID of log being restarted */ string log_id = 1; /* ID of log being restarted */
TimeSpec resume_point = 2; /* resume point in ellaped time (monotonic) */ TimeSpec resume_point = 2; /* resume point (elapsed time) */
} }
/* Window size change event. */ /* Window size change event. */
message ChangeWindowSize { message ChangeWindowSize {
TimeSpec delay = 1; /* elapsed time since last record (monotonic) */ TimeSpec delay = 1; /* elapsed time since last record */
int32 rows = 2; /* new number of rows */ int32 rows = 2; /* new number of rows */
int32 cols = 3; /* new number of columns */ int32 cols = 3; /* new number of columns */
} }
/* Command suspend/resume event. */ /* Command suspend/resume event. */
message CommandSuspend { message CommandSuspend {
TimeSpec delay = 1; /* elapsed time since last record (monotonic) */ TimeSpec delay = 1; /* elapsed time since last record */
string signal = 2; /* signal that caused the suspend/resume */ string signal = 2; /* signal that caused suspend/resume */
} }
/* /*
* Server messages to the client. * Server messages to the client. Messages on the wire are
* Messages on the wire are prefixed with a 16-bit size in network byte order. * prefixed with a 32-bit size in network byte order.
*/ */
message ServerMessage { message ServerMessage {
oneof type { oneof type {
ServerHello hello = 1; /* server hello message */ ServerHello hello = 1; /* server hello message */
TimeSpec commit_point = 2; /* cumulative time of records stored */ TimeSpec commit_point = 2; /* cumulative time of records stored */
string log_id = 3; /* ID of new I/O log (AcceptMessage ACK) */ string log_id = 3; /* ID of server-side I/O log */
string error = 4; /* error message from server (restartable) */ string error = 4; /* error message from server */
string abort = 5; /* abort message from server (kill session) */ string abort = 5; /* abort message, kill command */
} }
} }
/* Hello message from server when client connects. */ /* Hello message from server when client connects. */
message ServerHello { message ServerHello {
string server_id = 1; /* free-form server description */ string server_id = 1; /* free-form server description */
string redirect = 2; /* optional redirect to other server if busy */ string redirect = 2; /* optional redirect if busy */
repeated string servers = 3; /* optional list of known audit servers */ repeated string servers = 3; /* optional list of known servers */
} }