|
NAMEsudo_logsrv.proto —
Sudo log server protocol
DESCRIPTIONStarting with version 1.9.0,sudo supports sending event
and I/O logs to a log server. The protocol used is written in Google's
Protocol Buffers domain specific language. The
EXAMPLES section includes a complete
description of the protocol in Protocol Buffers format.
Because there is no way to determine message boundaries when using Protocol Buffers, the wire size of each message is sent immediately preceding the message itself as a 32-bit unsigned integer in network byte order. This is referred to as “length-prefix framing” and is how Google suggests handling the lack of message delimiters. The protocol is made up of two basic messages, ClientMessage and ServerMessage, described below. The server must accept messages up to two megabytes in size. The server may return an error if the client tries to send a message larger than two megabytes. Client MessagesA ClientMessage is a container used to encapsulate all the possible message types a client may send to the server.message ClientMessage { oneof type { AcceptMessage accept_msg = 1; RejectMessage reject_msg = 2; ExitMessage exit_msg = 3; RestartMessage restart_msg = 4; AlertMessage alert_msg = 5; IoBuffer ttyin_buf = 6; IoBuffer ttyout_buf = 7; IoBuffer stdin_buf = 8; IoBuffer stdout_buf = 9; IoBuffer stderr_buf = 10; ChangeWindowSize winsize_event = 11; CommandSuspend suspend_event = 12; ClientHello hello_msg = 13; } } The different ClientMessage sub-messages the client may sent to the server are described below. TimeSpecmessage TimeSpec { int64 tv_sec = 1; int32 tv_nsec = 2; } A TimeSpec is the equivalent of a POSIX
InfoMessagemessage InfoMessage { message StringList { repeated string strings = 1; } message NumberList { repeated int64 numbers = 1; } string key = 1; oneof value { int64 numval = 2; string strval = 3; StringList strlistval = 4; NumberList numlistval = 5; } } An InfoMessage is used to represent information about the invoking user as well as the execution environment the command runs in the form of key-value pairs. The key is always a string but the value may be a 64-bit integer, a string, an array of strings, or an array of 64-bit integers. The event log data is composed of InfoMessage entries. See the EVENT LOG VARIABLES section for more information. ClientHello hello_msgmessage ClientHello { string client_id = 1; } A ClientHello message consists of client information that may be sent to the server when the client first connects.
AcceptMessage accept_msgmessage AcceptMessage { TimeSpec submit_time = 1; repeated InfoMessage info_msgs = 2; bool expect_iobufs = 3; } An AcceptMessage is sent by the client when a command is allowed by the security policy. It contains the following members:
If an AcceptMessage is sent, the client must not send a RejectMessage or RestartMessage. RejectMessage reject_msgmessage RejectMessage { TimeSpec submit_time = 1; string reason = 2; repeated InfoMessage info_msgs = 3; } A RejectMessage is sent by the client when a command is denied by the security policy. It contains the following members:
If a RejectMessage is sent, the client must not send an AcceptMessage or RestartMessage. ExitMessage exit_msgmessage ExitMessage { TimeSpec run_time = 1; int32 exit_value = 2; bool dumped_core = 3; string signal = 4; string error = 5; }
When performing I/O logging, the client should wait for a commit_point corresponding to the final IoBuffer before closing the connection unless the final commit_point has already been received. RestartMessage restart_msgmessage RestartMessage { string log_id = 1; TimeSpec resume_point = 2; } A RestartMessage is sent by the client to resume sending an existing I/O log that was previously interrupted. It contains the following members:
If a RestartMessage is sent, the client must not send an AcceptMessage or RejectMessage. AlertMessage alert_msgmessage AlertMessage { TimeSpec alert_time = 1; string reason = 2; repeated InfoMessage info_msgs = 3; } An AlertMessage is sent by the client to indicate a problem detected by the security policy while the command is running that should be stored in the event log. It contains the following members:
IoBuffer ttyin_buf | ttyout_buf | stdin_buf | stdout_buf | stderr_bufmessage IoBuffer { TimeSpec delay = 1; bytes data = 2; } An IoBuffer is used to represent data from terminal input, terminal output, standard input, standard output, or standard error. It contains the following members:
ChangeWindowSize winsize_eventmessage ChangeWindowSize { TimeSpec delay = 1; int32 rows = 2; int32 cols = 3; } A ChangeWindowSize message is sent by the client when the terminal running the command changes size. It contains the following members:
CommandSuspend suspend_eventmessage CommandSuspend { TimeSpec delay = 1; string signal = 2; } A CommandSuspend message is sent by the client when the command is either suspended or resumed. It contains the following members:
Server MessagesA ServerMessage is a container used to encapsulate all the possible message types the server may send to a client.message ServerMessage { oneof type { ServerHello hello = 1; TimeSpec commit_point = 2; string log_id = 3; string error = 4; string abort = 5; } } The different ServerMessage sub-messages the server may sent to the client are described below. ServerHello hellomessage ServerHello { string server_id = 1; string redirect = 2; repeated string servers = 3; bool subcommands = 4; } The ServerHello message consists of server information sent when the client first connects. It contains the following members:
TimeSpec commit_pointA periodic time stamp sent by the server to indicate when I/O log buffers have been committed to storage. This message is not sent after every IoBuffer but rather at a server-configurable interval. When the server receives an ExitMessage, it will respond with a commit_point corresponding to the last received IoBuffer before closing the connection.string log_idThe server-side ID of the I/O log being stored, sent in response to an AcceptMessage where expect_iobufs is true.string errorA fatal server-side error. The server will close the connection after sending the error message.string abortAn abort message from the server indicates that the client should kill the command and terminate the session. It may be used to implement simple server-side policy. The server will close the connection after sending the abort message.Protocol flow of controlThe expected protocol flow is as follows:
At any point, the server may send an error or abort message to the client at which point the server will close the connection. If an abort message is received, the client should terminate the running command. EVENT LOG VARIABLESAcceptMessage, AlertMessage and RejectMessage classes contain an array of InfoMessage that should contain information about the user who submitted the command as well as information about the execution environment of the command if it was accepted.Some variables have a client,
run, or submit prefix. These prefixes
are used to eliminate ambiguity for variables that could apply to the client
program, the user submitting the command, or the command being run.
Variables with a client prefix pertain to the program
performing the connection to the log server, for example
The following InfoMessage entries are required:
The following InfoMessage entries are recognized, but not required:
The server must accept other variables not listed above but may ignore them. EXAMPLESThe Protocol Buffers description of the log server protocol, using “proto3” syntax, is included in full below.syntax = "proto3"; /* * Client message to the server. Messages on the wire are * prefixed with a 32-bit size in network byte order. */ message ClientMessage { oneof type { AcceptMessage accept_msg = 1; RejectMessage reject_msg = 2; ExitMessage exit_msg = 3; RestartMessage restart_msg = 4; AlertMessage alert_msg = 5; IoBuffer ttyin_buf = 6; IoBuffer ttyout_buf = 7; IoBuffer stdin_buf = 8; IoBuffer stdout_buf = 9; IoBuffer stderr_buf = 10; ChangeWindowSize winsize_event = 11; CommandSuspend suspend_event = 12; } } /* Equivalent of POSIX struct timespec */ message TimeSpec { int64 tv_sec = 1; /* seconds */ int32 tv_nsec = 2; /* nanoseconds */ } /* I/O buffer with keystroke data */ message IoBuffer { TimeSpec delay = 1; /* elapsed time since last record */ bytes data = 2; /* keystroke data */ } /* * Key/value pairs, like Privilege Manager struct info. * The value may be a number, a string, or a list of strings. */ message InfoMessage { message StringList { repeated string strings = 1; } message NumberList { repeated int64 numbers = 1; } string key = 1; oneof value { int64 numval = 2; string strval = 3; StringList strlistval = 4; NumberList numlistval = 5; } } /* * Event log data for command accepted by the policy. */ message AcceptMessage { TimeSpec submit_time = 1; /* when command was submitted */ repeated InfoMessage info_msgs = 2; /* key,value event log data */ bool expect_iobufs = 3; /* true if I/O logging enabled */ } /* * Event log data for command rejected by the policy. */ message RejectMessage { TimeSpec submit_time = 1; /* when command was submitted */ string reason = 2; /* reason command was rejected */ repeated InfoMessage info_msgs = 3; /* key,value event log data */ } /* Message sent by client when command exits. */ /* Might revisit runtime and use end_time instead */ message ExitMessage { TimeSpec run_time = 1; /* total elapsed run time */ int32 exit_value = 2; /* 0-255 */ bool dumped_core = 3; /* true if command dumped core */ string signal = 4; /* signal name if killed by signal */ string error = 5; /* if killed due to other error */ } /* Alert message, policy module-specific. */ message AlertMessage { TimeSpec alert_time = 1; /* time alert message occurred */ string reason = 2; /* policy alert error string */ repeated InfoMessage info_msgs = 3; /* key,value event log data */ } /* Used to restart an existing I/O log on the server. */ message RestartMessage { string log_id = 1; /* ID of log being restarted */ TimeSpec resume_point = 2; /* resume point (elapsed time) */ } /* Window size change event. */ message ChangeWindowSize { TimeSpec delay = 1; /* elapsed time since last record */ int32 rows = 2; /* new number of rows */ int32 cols = 3; /* new number of columns */ } /* Command suspend/resume event. */ message CommandSuspend { TimeSpec delay = 1; /* elapsed time since last record */ string signal = 2; /* signal that caused suspend/resume */ } /* * Server messages to the client. Messages on the wire are * prefixed with a 32-bit size in network byte order. */ message ServerMessage { oneof type { ServerHello hello = 1; /* server hello message */ TimeSpec commit_point = 2; /* cumulative time of records stored */ string log_id = 3; /* ID of server-side I/O log */ string error = 4; /* error message from server */ string abort = 5; /* abort message, kill command */ } } /* Hello message from server when client connects. */ message ServerHello { string server_id = 1; /* free-form server description */ string redirect = 2; /* optional redirect if busy */ repeated string servers = 3; /* optional list of known servers */ } SEE ALSOsudo_logsrvd.conf(5), sudoers(5), sudo(8), sudo_logsrvd(8)Protocol Buffers, https://developers.google.com/protocol-buffers/. AUTHORSMany people have worked onsudo over the years; this
version consists of code written primarily by:
Todd C. Miller
See the CONTRIBUTORS.md file in the BUGSIf you believe you have found a bug insudo , you can
submit a bug report at https://bugzilla.sudo.ws/
SUPPORTLimited free support is available via the sudo-users mailing list, see https://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search the archives.DISCLAIMERsudo is provided “AS IS” and any express
or implied warranties, including, but not limited to, the implied warranties
of merchantability and fitness for a particular purpose are disclaimed. See
the LICENSE.md file distributed with sudo or
https://www.sudo.ws/about/license/ for complete details.
Visit the GSP FreeBSD Man Page Interface. |