Skip to content

common/flatpak-dir.c: fix build when HAVE_LIBSYSTEMD but not USE_SYSTEM_HELPER - #6652

Merged
bbhtt merged 1 commit into
flatpak:mainfrom
heitbaum:fix
May 9, 2026
Merged

bbhtt merged 1 commit into
flatpak:mainfrom
heitbaum:fix

Conversation

@heitbaum

@heitbaum heitbaum commented May 9, 2026

Copy link
Copy Markdown
Contributor

polkit_subject_to_string() is called inside the HAVE_LIBSYSTEMD guard in flatpak_dir_log(), but <polkit/polkit.h> is only included when USE_SYSTEM_HELPER is defined. This causes a build failure on configurations that have libsystemd but no system helper.

Guard the polkit call with USE_SYSTEM_HELPER and fall back to "(none)" so the subject string is always valid for the sd_journal_send() call.

fixes:

[1/9] Compiling C object common/libflatpak-common.a.p/flatpak-dir.c.o
FAILED: [code=1] common/libflatpak-common.a.p/flatpak-dir.c.o
/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc -Icommon/libflatpak-common.a.p -Icommon -I../common -I. -I.. -Isubprojects/libglnx -I../subprojects/libglnx -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/glib-2.0 -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/lib/glib-2.0/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/libmount -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/blkid -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/gio-unix-2.0 -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/libassuan-3.0.2/usr/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/json-glib-1.0 -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/ostree-2026.1/usr/include/ostree-1 -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/xz-5.8.3/usr/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/libxml2 -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/gpgme-2.0.1/usr/include -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -include config.h -Werror=shadow -Werror=empty-body -Werror=strict-prototypes -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=missing-declarations -Werror=return-type -Werror=overflow -Werror=int-conversion -Werror=incompatible-pointer-types -Werror=misleading-indentation -Werror=missing-include-dirs -Wno-sign-compare -Wno-error=sign-compare -Wno-cast-function-type -Wno-error=cast-function-type -Wno-missing-field-initializers -Wno-error=missing-field-initializers -Wno-unused-parameter -Wno-error=unused-parameter -fvisibility=hidden -Werror=format=2 -Werror=format-security -Werror=format-nonliteral -march=x86-64-v3 -Wall -pipe -O2 -fomit-frame-pointer -DNDEBUG -fPIC -pthread -DPCRE2_STATIC -MD -MQ common/libflatpak-common.a.p/flatpak-dir.c.o -MF common/libflatpak-common.a.p/flatpak-dir.c.o.d -o common/libflatpak-common.a.p/flatpak-dir.c.o -c ../common/flatpak-dir.c
../common/flatpak-dir.c: In function 'flatpak_dir_log':
../common/flatpak-dir.c:17466:29: error: implicit declaration of function 'polkit_subject_to_string'; did you mean 'ostree_object_to_string'? [-Wimplicit-function-declaration]
17466 |   subject = self->subject ? polkit_subject_to_string (self->subject) : g_strdup ("(none)");
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~
      |                             ostree_object_to_string
../common/flatpak-dir.c:17466:70: error: pointer/integer type mismatch in conditional expression [-Wint-conversion]
17466 |   subject = self->subject ? polkit_subject_to_string (self->subject) : g_strdup ("(none)");
      |                                                                      ^

@bbhtt

bbhtt commented May 9, 2026 •

Copy link
Copy Markdown
Collaborator

prefix should be dir then you can fit in <=72 or 80. Also can you put a Fixes: f9d5c5c ("dir: Free result of polkit_subject_to_string")?

@heitbaum

heitbaum commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

prefix should be dir then you can fit in <=72 or 80. Also can you put a Fixes: f9d5c5c ("dir: Free result of polkit_subject_to_string")?

thanks for the review. updated.

@bbhtt

bbhtt commented May 9, 2026 •

Copy link
Copy Markdown
Collaborator

It should be dir: as I said. common is for when the commit touches multiple files in here. Sorry it's a bit pedantic but I mentioned it already before.

polkit_subject_to_string() is called inside the HAVE_LIBSYSTEMD guard
in flatpak_dir_log(), but <polkit/polkit.h> is only included when
USE_SYSTEM_HELPER is defined. This causes a build failure on
configurations that have libsystemd but no system helper.

Guard the polkit call with USE_SYSTEM_HELPER and fall back to "(none)"
so the subject string is always valid for the sd_journal_send() call.

Fixes: f9d5c5c ("dir: Free result of polkit_subject_to_string")
Signed-off-by: Rudi Heitbaum <[email protected]>
@heitbaum

heitbaum commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

It should be dir: as I said. common is for when the commit touches multiple files in here. Sorry it's a bit pedantic but I mentioned it already before.

Fixed. sorry it wasn't clear - dir = directory / _dir. but happy to get it right. Thanks for the review.

@bbhtt bbhtt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@bbhtt
bbhtt merged commit 68ffa48 into flatpak:main May 9, 2026
11 checks passed
@heitbaum
heitbaum deleted the fix branch May 9, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants