File 0002-syscheck-account-for-differences-in-openSUSE-16.0-16.patch of Package snapd
From eedd4069e78e8018e41758c00b63fc2bb4838c2c Mon Sep 17 00:00:00 2001
Message-ID: <eedd4069e78e8018e41758c00b63fc2bb4838c2c.1760444283.git.maciej.borzecki@canonical.com>
From: Maciej Borzecki <maciej.borzecki@canonical.com>
Date: Tue, 14 Oct 2025 10:29:49 +0200
Subject: [PATCH] syscheck: account for differences in openSUSE 16.0+ (#16139)
Upstream: merged
Since openSUSE 16.0, the libexecdir is the same as on Tumbleweed and
Slworoll, i.e. /usr/libexec/.
Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
---
syscheck/dirs.go | 11 ++++++++++-
syscheck/dirs_test.go | 4 ++--
syscheck/export_test.go | 1 +
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/syscheck/dirs.go b/syscheck/dirs.go
index 893a8f0dce55292e304cc0bdfdcb345fdea1485e..017913cb7f14d53e682b51f3cdd512fbe9b17f28 100644
--- a/syscheck/dirs.go
+++ b/syscheck/dirs.go
@@ -78,7 +78,6 @@ var (
"ubuntu-core",
"ubuntucoreinitramfs",
"debian",
- "opensuse-leap",
"yocto",
"altlinux",
"antergos",
@@ -95,11 +94,21 @@ var (
"opensuse-tumbleweed",
"opensuse-slowroll",
}
+
+ bothLibExecDirDistros = []string{
+ "opensuse-leap", // openSUSE Leap uses /usr/libexec/snapd
+ // starting from 16.0, but used /usr/lib/snapd
+ // in earlier versions
+ }
)
func checkLibExecDir() error {
d := dirs.StripRootDir(dirs.DistroLibExecDir)
switch {
+ case release.DistroLike(bothLibExecDirDistros...):
+ // Distributions which use either location, likely depending on their
+ // version, but doing version check is too much a hassle. openSUSE Leap is
+ // one of those cases.
case release.DistroLike(altLibExecDirDistros...) && d != dirs.AltDistroLibexecDir:
// RHEL, CentOS, Fedora and derivatives, openSUSE Tumbleweed (since
// snapshot 20200826) and Slowroll; both RHEL and CentOS list "fedora"
diff --git a/syscheck/dirs_test.go b/syscheck/dirs_test.go
index d6f0874310d15a3e1f9292417f4c004397a927bc..d6a1c29502ce35935bccf921d5d64601ae95b1b2 100644
--- a/syscheck/dirs_test.go
+++ b/syscheck/dirs_test.go
@@ -158,7 +158,7 @@ func (s *dirsSuite) TestMountDirKnownDistroSpecial(c *C) {
func (s *dirsSuite) TestLibExecDirDefault(c *C) {
defer dirs.SetRootDir("")
- for _, tc := range syscheck.DefaultLibExecDirDistros {
+ for _, tc := range append(syscheck.DefaultLibExecDirDistros, syscheck.BothLibExecDirDistros...) {
c.Logf("distro libexecdir default case %+v", tc)
func() {
defer release.MockReleaseInfo(&release.OS{ID: tc})()
@@ -174,7 +174,7 @@ func (s *dirsSuite) TestLibExecDirDefault(c *C) {
func (s *dirsSuite) TestLibExecDirAlt(c *C) {
defer dirs.SetRootDir("")
- for _, tc := range syscheck.AltLibExecDirDistros {
+ for _, tc := range append(syscheck.AltLibExecDirDistros, syscheck.BothLibExecDirDistros...) {
c.Logf("distro libexecdir alt case %+v", tc)
func() {
defer release.MockReleaseInfo(&release.OS{ID: tc})()
diff --git a/syscheck/export_test.go b/syscheck/export_test.go
index 820d462048c7083d08045b801bb706983e686b41..ae5eef399f7027c28210bb9ebfae8612fe6d87c4 100644
--- a/syscheck/export_test.go
+++ b/syscheck/export_test.go
@@ -32,6 +32,7 @@ var (
DefaultLibExecDirDistros = defaulLibExectDirDistros
AltLibExecDirDistros = altLibExecDirDistros
+ BothLibExecDirDistros = bothLibExecDirDistros
)
func Checks() []func() error {
--
2.51.0