Documentation
¶
Overview ¶
Package polkit is polkitd's Authority (org.freedesktop.PolicyKit1) on the system bus as every lys process uses it: its names declared once, typed subjects, the authorization check with its cancellation, the calls an authentication agent makes, and one context-bounded call path whose errors name the action and the subject.
Index ¶
- Constants
- Variables
- func ChangedMatch() []dbus.MatchOption
- func Dial(ctx context.Context) (*dbus.Conn, error)
- type Action
- type ActionDescription
- type Authority
- func (a Authority) CheckAuthorization(ctx context.Context, subject Subject, action Action, flags CheckFlags) (AuthorizationResult, error)
- func (a Authority) EnumerateActions(ctx context.Context, locale string) ([]ActionDescription, error)
- func (a Authority) EnumerateTemporaryAuthorizations(ctx context.Context, subject Subject) ([]TemporaryAuthorization, error)
- func (a Authority) RegisterAuthenticationAgent(ctx context.Context, subject Subject, locale string, path dbus.ObjectPath) (dbus.Sequence, error)
- func (a Authority) RevokeTemporaryAuthorizationByID(ctx context.Context, id string) error
- func (a Authority) RevokeTemporaryAuthorizations(ctx context.Context, subject Subject) error
- func (a Authority) UnregisterAuthenticationAgent(ctx context.Context, subject Subject, path dbus.ObjectPath) error
- type AuthorityChanged
- type AuthorizationResult
- type CheckFlags
- type Subject
- type TemporaryAuthorization
- type UnixProcess
- type UnixSession
- type Verdict
- type WireSubject
Constants ¶
const ( BusName = "org.freedesktop.PolicyKit1" AuthorityPath = dbus.ObjectPath("/org/freedesktop/PolicyKit1/Authority") AuthorityInterface = BusName + ".Authority" AgentInterface = BusName + ".AuthenticationAgent" )
The polkit service, its Authority object, and the interfaces of the Authority and of the agent that authenticates for it.
const ( ErrFailed = BusName + ".Error.Failed" ErrCancelled = BusName + ".Error.Cancelled" )
The polkit errors lys tells apart (polkiterror.c): what the Authority answers a refused call and a cancelled check with, and what an agent answers a failed and a cancelled authentication with.
const CallTimeout = 5 * time.Second
CallTimeout bounds every call to polkitd but CheckAuthorization, whatever the caller's context allows: a polkitd that does not answer never hangs its caller. A check may wait for a person to authenticate and is bounded by its context alone.
const DismissedDetail = "polkit.dismissed"
DismissedDetail is the detail polkitd sets to "true" when the person asked to authenticate dismissed the dialog.
Variables ¶
var Changed = dbusx.NewSignal[AuthorityChanged](AuthorityInterface, "Changed")
Changed is the Authority's signal that actions, authorizations or agents changed.
Functions ¶
func ChangedMatch ¶
func ChangedMatch() []dbus.MatchOption
ChangedMatch matches Changed from polkitd's Authority.
Types ¶
type Action ¶
type Action string
Action is the id of a polkit action, such as org.freedesktop.policykit.exec.
type ActionDescription ¶
type ActionDescription struct {
ActionID string
Description string
Message string
VendorName string
VendorURL string
IconName string
ImplicitAny uint32
ImplicitInactive uint32
ImplicitActive uint32
Annotations map[string]string
}
ActionDescription is one registered action as EnumerateActions describes it, (ssssssuuua{ss}): its texts in the locale asked for, and the implicit authorizations of any, inactive and active sessions.
type Authority ¶
type Authority struct {
// contains filtered or unexported fields
}
Authority is polkitd's Authority object on one connection.
func NewAuthority ¶
NewAuthority is polkitd's Authority on conn, the system bus.
func (Authority) CheckAuthorization ¶
func (a Authority) CheckAuthorization(ctx context.Context, subject Subject, action Action, flags CheckFlags) (AuthorizationResult, error)
CheckAuthorization asks polkitd whether subject may perform action. With AllowUserInteraction the call lasts as long as the person takes to authenticate, so it is bounded by ctx alone; when ctx ends first the check is cancelled at polkitd, which takes its dialog down.
func (Authority) EnumerateActions ¶
func (a Authority) EnumerateActions(ctx context.Context, locale string) ([]ActionDescription, error)
EnumerateActions describes every action registered with polkitd, its texts translated to locale.
func (Authority) EnumerateTemporaryAuthorizations ¶
func (a Authority) EnumerateTemporaryAuthorizations(ctx context.Context, subject Subject) ([]TemporaryAuthorization, error)
EnumerateTemporaryAuthorizations lists the authorizations polkitd retains for subject.
func (Authority) RegisterAuthenticationAgent ¶
func (a Authority) RegisterAuthenticationAgent(ctx context.Context, subject Subject, locale string, path dbus.ObjectPath) (dbus.Sequence, error)
RegisterAuthenticationAgent registers the caller's agent, exported at path with AgentInterface, as the one that authenticates for subject, its messages in locale. It returns the sequence of polkitd's reply: a NameOwnerChanged of BusName sequenced before it happened before the registration, one after it is a polkitd that has not seen the agent.
func (Authority) RevokeTemporaryAuthorizationByID ¶
RevokeTemporaryAuthorizationByID revokes the one retained authorization id.
func (Authority) RevokeTemporaryAuthorizations ¶
RevokeTemporaryAuthorizations revokes every authorization polkitd retains for subject.
func (Authority) UnregisterAuthenticationAgent ¶
func (a Authority) UnregisterAuthenticationAgent(ctx context.Context, subject Subject, path dbus.ObjectPath) error
UnregisterAuthenticationAgent takes back the registration of the caller's agent at path for subject.
type AuthorityChanged ¶
type AuthorityChanged struct{}
AuthorityChanged is what Changed carries: nothing.
type AuthorizationResult ¶
AuthorizationResult is polkitd's answer to a check, (bba{ss}).
func (AuthorizationResult) Verdict ¶
func (r AuthorizationResult) Verdict() Verdict
Verdict reads the result.
type CheckFlags ¶
type CheckFlags uint32
CheckFlags are CheckAuthorization's flags.
const AllowUserInteraction CheckFlags = 1
AllowUserInteraction lets polkitd have the subject's authentication agent ask a person to authenticate, and wait for the answer, before it answers the check.
type Subject ¶
type Subject interface {
fmt.Stringer
// Wire is the subject as it travels to polkitd.
Wire() (WireSubject, error)
// contains filtered or unexported methods
}
Subject is who polkitd decides about, and whom an agent authenticates for: a UnixSession or a UnixProcess.
type TemporaryAuthorization ¶
type TemporaryAuthorization struct {
ID string
ActionID string
Subject WireSubject
Obtained uint64
Expires uint64
}
TemporaryAuthorization is one authorization polkitd retains for a while after an authentication, (ss(sa{sv})tt). Obtained is on the monotonic clock and Expires on the wall clock, both in seconds.
type UnixProcess ¶
UnixProcess is the unix-process subject: a process by its pid, the start time that tells it from a later process with the same pid, and the uid it runs as. PIDFD, when not nil, names the process itself: polkit 124 and later decide about that process, whatever its pid is reused for, and an older polkitd ignores it. It stays the caller's to close, after the calls that send the subject.
func ProcessOf ¶
func ProcessOf(c peercred.Credentials) (UnixProcess, error)
ProcessOf is the unix-process subject for the peer of a socket, by the pid and uid the kernel recorded when it connected and the start time /proc gives that pid now. Between the two the pid may have been reused: ProcessOfPIDFD closes that window where the kernel has SO_PEERPIDFD.
func ProcessOfPIDFD ¶
func ProcessOfPIDFD(pidfd *peercred.PIDFD) (UnixProcess, error)
ProcessOfPIDFD is the unix-process subject for the peer pidfd names, carrying pidfd. The peer was still running after its start time was read, so that start time is its own and not a later process's with its pid; a peer that has exited is an error.
func (UnixProcess) String ¶
func (p UnixProcess) String() string
String names the process and its user.
func (UnixProcess) Wire ¶
func (p UnixProcess) Wire() (WireSubject, error)
Wire is the process as it travels to polkitd, its pidfd included when it has one.
type UnixSession ¶
UnixSession is the unix-session subject: a logind session.
func (UnixSession) Wire ¶
func (s UnixSession) Wire() (WireSubject, error)
Wire is the session as it travels to polkitd.
type Verdict ¶
type Verdict uint8
Verdict is what an AuthorizationResult says.
The verdicts. Challenge says authentication is needed and nobody was asked: the check did not allow interaction, or no agent is registered for the subject.
type WireSubject ¶
WireSubject is a subject as it travels on the bus, (sa{sv}): its kind and that kind's details. It is what an Authority receives, and what polkitd's replies carry.
func (WireSubject) PIDFD ¶
func (w WireSubject) PIDFD() (fd dbus.UnixFD, ok bool)
PIDFD is the pidfd a received unix-process subject carries: a descriptor of the receiver's own, for it to close. ok is false for a subject that carries none.
func (WireSubject) Subject ¶
func (w WireSubject) Subject() (Subject, error)
Subject reads a received subject. A unix-process subject's pidfd is not part of what it returns: PIDFD hands that over.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package polkittest is a fake polkitd Authority for tests: it answers CheckAuthorization with the result the test sets and records every check and cancel, records agent registrations and refuses a second agent for a subject, as polkit 127 does, describes the actions it is given, keeps temporary authorizations, and counts the calls it answers.
|
Package polkittest is a fake polkitd Authority for tests: it answers CheckAuthorization with the result the test sets and records every check and cancel, records agent registrations and refuses a second agent for a subject, as polkit 127 does, describes the actions it is given, keeps temporary authorizations, and counts the calls it answers. |