apparmorprompting

package
v0.0.0-...-263a040 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InterfacesRequestsManager

type InterfacesRequestsManager struct {
	// contains filtered or unexported fields
}

func New

func New(s *state.State) (m *InterfacesRequestsManager, retErr error)

func (*InterfacesRequestsManager) AddRule

func (m *InterfacesRequestsManager) AddRule(userID uint32, snap string, iface string, constraints *prompting.Constraints, outcome prompting.OutcomeType, lifespan prompting.LifespanType, duration string) (*requestrules.Rule, error)

AddRule creates a new rule with the given contents and then checks it against outstanding prompts, resolving any prompts which it satisfies.

func (*InterfacesRequestsManager) HandleReply

func (m *InterfacesRequestsManager) HandleReply(userID uint32, promptID prompting.IDType, constraints *prompting.Constraints, outcome prompting.OutcomeType, lifespan prompting.LifespanType, duration string) (satisfiedPromptIDs []prompting.IDType, retErr error)

HandleReply checks that the given reply contents are valid, satisfies the original request, and does not conflict with any existing rules (if lifespan is not "single"). If all of these are true, sends a reply for the prompt with the given ID, and both creates a new rule and checks any outstanding prompts against it, if the lifespan is not "single".

func (*InterfacesRequestsManager) PatchRule

func (m *InterfacesRequestsManager) PatchRule(userID uint32, ruleID prompting.IDType, constraints *prompting.Constraints, outcome prompting.OutcomeType, lifespan prompting.LifespanType, duration string) (*requestrules.Rule, error)

PatchRule updates the rule with the given ID using the provided contents. Any of the given fields which are empty/nil are not updated in the rule.

func (*InterfacesRequestsManager) PromptWithID

func (m *InterfacesRequestsManager) PromptWithID(userID uint32, promptID prompting.IDType) (*requestprompts.Prompt, error)

PromptWithID returns the prompt with the given ID for the given user.

func (*InterfacesRequestsManager) Prompts

func (m *InterfacesRequestsManager) Prompts(userID uint32) ([]*requestprompts.Prompt, error)

Prompts returns all prompts for the user with the given user ID.

func (*InterfacesRequestsManager) RemoveRule

func (m *InterfacesRequestsManager) RemoveRule(userID uint32, ruleID prompting.IDType) (*requestrules.Rule, error)

func (*InterfacesRequestsManager) RemoveRules

func (m *InterfacesRequestsManager) RemoveRules(userID uint32, snap string, iface string) ([]*requestrules.Rule, error)

RemoveRules removes all rules for the user with the given user ID and the given snap and/or interface. Snap and iface can't both be unspecified.

func (*InterfacesRequestsManager) RuleWithID

func (m *InterfacesRequestsManager) RuleWithID(userID uint32, ruleID prompting.IDType) (*requestrules.Rule, error)

RuleWithID returns the rule with the given ID for the given user.

func (*InterfacesRequestsManager) Rules

func (m *InterfacesRequestsManager) Rules(userID uint32, snap string, iface string) ([]*requestrules.Rule, error)

Rules returns all rules for the user with the given user ID and, optionally, only those for the given snap and/or interface.

func (*InterfacesRequestsManager) Stop

func (m *InterfacesRequestsManager) Stop() error

Stop closes the listener, prompt DB, and rule DB. Stop is idempotent, and the receiver cannot be started or used after it has been stopped.

type Manager

type Manager interface {
	Prompts(userID uint32) ([]*requestprompts.Prompt, error)
	PromptWithID(userID uint32, promptID prompting.IDType) (*requestprompts.Prompt, error)
	HandleReply(userID uint32, promptID prompting.IDType, constraints *prompting.Constraints, outcome prompting.OutcomeType, lifespan prompting.LifespanType, duration string) ([]prompting.IDType, error)
	Rules(userID uint32, snap string, iface string) ([]*requestrules.Rule, error)
	AddRule(userID uint32, snap string, iface string, constraints *prompting.Constraints, outcome prompting.OutcomeType, lifespan prompting.LifespanType, duration string) (*requestrules.Rule, error)
	RemoveRules(userID uint32, snap string, iface string) ([]*requestrules.Rule, error)
	RuleWithID(userID uint32, ruleID prompting.IDType) (*requestrules.Rule, error)
	PatchRule(userID uint32, ruleID prompting.IDType, constraints *prompting.Constraints, outcome prompting.OutcomeType, lifespan prompting.LifespanType, duration string) (*requestrules.Rule, error)
	RemoveRule(userID uint32, ruleID prompting.IDType) (*requestrules.Rule, error)
}

A Manager holds outstanding prompts and mediates their replies, further it stores and applies persistent rules.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL