Skip to content

Commit

Permalink
i/builtin: support polkitd path on core24
Browse files Browse the repository at this point in the history
  • Loading branch information
Meulengracht committed Feb 2, 2024
1 parent 935b84f commit 35923f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion interfaces/builtin/polkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,24 @@ func (iface *polkitInterface) BeforePreparePlug(plug *snap.PlugInfo) error {
return err
}

// hasPolkitDaemonExecutable checks known paths on core for the presence of
// the polkit daemon executable. This function can be shortened but keep it like
// this for readability.
func hasPolkitDaemonExecutable() bool {
// On core22(+core-desktop?) polkitd is at /usr/libexec/polkitd
if osutil.IsExecutable("/usr/libexec/polkitd") {
return true
}
// On core24 polkitd is at /usr/lib/polkit-1/polkitd
return osutil.IsExecutable("/usr/lib/polkit-1/polkitd")
}

func init() {
registerIface(&polkitInterface{
commonInterface{
name: "polkit",
summary: polkitSummary,
implicitOnCore: osutil.IsExecutable("/usr/libexec/polkitd"),
implicitOnCore: hasPolkitDaemonExecutable(),
implicitOnClassic: true,
baseDeclarationPlugs: polkitBaseDeclarationPlugs,
baseDeclarationSlots: polkitBaseDeclarationSlots,
Expand Down
2 changes: 1 addition & 1 deletion interfaces/builtin/polkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ apps:

func (s *polkitInterfaceSuite) TestStaticInfo(c *C) {
si := interfaces.StaticInfoOf(s.iface)
c.Check(si.ImplicitOnCore, Equals, osutil.IsExecutable("/usr/libexec/polkitd"))
c.Check(si.ImplicitOnCore, Equals, osutil.IsExecutable("/usr/libexec/polkitd") || osutil.IsExecutable("/usr/lib/polkit-1/polkitd"))
c.Check(si.ImplicitOnClassic, Equals, true)
c.Check(si.Summary, Equals, "allows access to polkitd to check authorisation")
c.Check(si.BaseDeclarationPlugs, testutil.Contains, "polkit")
Expand Down

0 comments on commit 35923f9

Please sign in to comment.