Documentation ¶
Index ¶
- Constants
- func CheckHelper(log logging.Logger, helperName string) error
- func PrivilegedHelperNotAvailable(helperName string) *fault.Fault
- func PrivilegedHelperNotPrivileged(helperName string) *fault.Fault
- func PrivilegedHelperRequestFailed(message string) *fault.Fault
- func ReadMessage(conn io.Reader) ([]byte, error)
- type App
- func (a *App) AddHandler(method string, handler RequestHandler)
- func (a *App) Name() string
- func (a *App) Run() error
- func (a *App) WithAllowedCallers(callers ...string) *App
- func (a *App) WithInput(reader io.ReadCloser) *App
- func (a *App) WithLogFile(path string) *App
- func (a *App) WithOutput(writer io.WriteCloser) *App
- type ForwardChecker
- type ForwardableRequest
- type Forwarder
- type PingResp
- type Process
- type Request
- type RequestHandler
- type Response
- type StdioAddr
- type StdioConn
- func (sc *StdioConn) Close() error
- func (sc *StdioConn) CloseRead() error
- func (sc *StdioConn) CloseWrite() error
- func (sc *StdioConn) LocalAddr() net.Addr
- func (sc *StdioConn) Read(b []byte) (int, error)
- func (sc *StdioConn) RemoteAddr() net.Addr
- func (sc *StdioConn) SetDeadline(t time.Time) error
- func (sc *StdioConn) SetReadDeadline(t time.Time) error
- func (sc *StdioConn) SetWriteDeadline(t time.Time) error
- func (sc *StdioConn) String() string
- func (sc *StdioConn) Write(b []byte) (int, error)
- type StdioListener
Constants ¶
const ( // MessageBufferSize is the starting size of the receive buffer. If // the buffer must be grown to accommodate larger messages, it is // expanded in increments of this value. MessageBufferSize = 1024 // MaxMessageSize is the largest single message that can be written to // or read from the privileged binary. MaxMessageSize = MessageBufferSize * 1024 )
const ( // DaosPrivHelperName is the name of the privileged helper. DaosPrivHelperName = "daos_server_helper" // DaosPrivHelperLogFileEnvVar is the name of the environment variable which // can be set to enable non-ERROR logging in the privileged helper. DaosPrivHelperLogFileEnvVar = "DAOS_HELPER_LOG_FILE" // DaosFWName is the name of the firmware helper. DaosFWName = "daos_firmware_helper" // DaosFWLogFileEnvVar is the name of the environment variable that // can be set to enable non-ERROR logging in the firmware helper. DaosFWLogFileEnvVar = "DAOS_FIRMWARE_LOG_FILE" )
const PingMethod string = "Ping"
PingMethod is the string naming the ping method, which is universal to all privileged Apps.
Variables ¶
This section is empty.
Functions ¶
func CheckHelper ¶
CheckHelper attempts to invoke the helper to test for installation/setup problems. This function can be used to proactively identify problems and avoid console spam from multiple errors.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is a framework for a privileged external helper application to be invoked by one or more DAOS processes.
func (*App) AddHandler ¶
func (a *App) AddHandler(method string, handler RequestHandler)
AddHandler adds a new handler to the App for a given method. There is at most one handler per method.
func (*App) WithAllowedCallers ¶
WithAllowedCallers adds a list of process names allowed to call this application.
func (*App) WithInput ¶
func (a *App) WithInput(reader io.ReadCloser) *App
WithInput adds a custom input source to the App.
func (*App) WithLogFile ¶
WithLogFile sets up App logging to a file at a given path.
func (*App) WithOutput ¶
func (a *App) WithOutput(writer io.WriteCloser) *App
WithOutput adds a custom output sink to the App.
type ForwardChecker ¶
type ForwardChecker interface {
IsForwarded() bool
}
ForwardChecker defines an interface for any request that could have been forwarded.
type ForwardableRequest ¶
type ForwardableRequest struct {
Forwarded bool
}
ForwardableRequest is intended to be embedded into request types that can be forwarded to the privileged binary.
func (ForwardableRequest) IsForwarded ¶
func (r ForwardableRequest) IsForwarded() bool
IsForwarded implements the ForwardChecker interface.
type Forwarder ¶
type Forwarder struct { Disabled bool // contains filtered or unexported fields }
Forwarder provides a common implementation of a request forwarder.
func NewForwarder ¶
NewForwarder returns a configured *Forwarder.
func (*Forwarder) CanForward ¶
CanForward indicates whether commands can be forwarded to the forwarder's designated binary.
func (*Forwarder) GetBinaryName ¶
GetBinaryName returns the name of the binary requests will be forwarded to.
type Process ¶
type Process struct{}
Process is a mechanism to interact with the current process.
func (*Process) CurrentProcessName ¶
CurrentProcessName fetches the name of the running process.
func (*Process) ElevatePrivileges ¶
ElevatePrivileges raises the process privileges.
func (*Process) IsPrivileged ¶
IsPrivileged determines whether the process is running as a privileged user.
func (*Process) ParentProcessName ¶
ParentProcessName fetches the name of the parent process, or returns an error otherwise.
type Request ¶
type Request struct { Method string Payload json.RawMessage }
Request represents a request sent to the privileged binary. The payload field contains a JSON-encoded representation of the wrapped request.
type RequestHandler ¶
RequestHandler is an interface that handles a pbin.Request.
type Response ¶
type Response struct { Error *fault.Fault Payload json.RawMessage }
Response represents a response received from the privileged binary. The payload field contains a JSON-encoded representation of the wrapped response.
func ExecReq ¶
func ExecReq(parent context.Context, log logging.Logger, binPath string, req *Request) (res *Response, err error)
ExecReq executes the supplied Request by starting a child process to service the request. Returns a Response if successful.
func NewResponseWithError ¶
NewResponseWithError creates a new pbin.Response indicating a failure.
func NewResponseWithPayload ¶
func NewResponseWithPayload(payloadSrc interface{}) *Response
NewResponseWithPayload creates a new pbin.Response with a payload structure marshalled into JSON.
type StdioAddr ¶
type StdioAddr struct {
// contains filtered or unexported fields
}
StdioAddr implements net.Addr to provide an emulated network address for use with StdioConn.
type StdioConn ¶
StdioConn implements net.Conn to provide an emulated network connection between two processes over stdin/stdout.
func NewStdioConn ¶
func NewStdioConn(localID, remoteID string, in io.ReadCloser, out io.WriteCloser) *StdioConn
func (*StdioConn) CloseWrite ¶
func (*StdioConn) RemoteAddr ¶
type StdioListener ¶
type StdioListener struct {
// contains filtered or unexported fields
}
StdioListener wraps a *StdioConn to implement net.Listener.
func NewStdioListener ¶
func NewStdioListener(conn *StdioConn) *StdioListener
func (*StdioListener) Addr ¶
func (sl *StdioListener) Addr() net.Addr
func (*StdioListener) Close ¶
func (sl *StdioListener) Close() error