summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDebarshi Ray <debarshir@gnome.org>2019-08-12 22:19:19 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2019-08-16 09:13:43 +0000
commite82efa8603a375d5b136f363318230a735254754 (patch)
treef70e8b030a03d329d327db9f4f8b58edbc26c6fb
parent61d4316043ffbce60d358b5b35c466ddc0594c06 (diff)
downloadflatpak-e82efa8603a375d5b136f363318230a735254754.tar.gz
Trim unused shared library linkages from the session helper
The org.freedesktop.Flatpak user D-Bus service isn't just used by flatpak(1) or applications running as Flatpaks. It's also used by toolbox(1) for similar reasons: * To keep various configuration files inside the container synchronized with the host * To let the container request certain commands to be run on the host The org.freedesktop.Flatpak D-Bus service itself doesn't need much in the way of dependencies, but inherits a lot of unused shared library linkages through the libflatpak-common.la convenience library. Removing these unused shared libraries reduces the footprint of toolbox(1) for those who care about such things. eg., Fedora CoreOS. This commit brings down the number of shared libraries to 19 from 62. Closes: #3052 Approved by: alexlarsson
-rw-r--r--app/Makefile.am.inc3
-rw-r--r--app/flatpak-builtins-build-update-repo.c4
-rw-r--r--common/Makefile.am.inc29
-rw-r--r--common/flatpak-dir.c4
-rw-r--r--common/flatpak-exports.c4
-rw-r--r--common/flatpak-run.c4
-rw-r--r--common/flatpak-utils-base-private.h34
-rw-r--r--common/flatpak-utils-base.c100
-rw-r--r--common/flatpak-utils-private.h8
-rw-r--r--common/flatpak-utils.c74
-rw-r--r--session-helper/Makefile.am.inc4
-rw-r--r--session-helper/flatpak-session-helper.c5
-rw-r--r--system-helper/Makefile.am.inc2
-rw-r--r--tests/Makefile.am.inc7
14 files changed, 181 insertions, 101 deletions
diff --git a/app/Makefile.am.inc b/app/Makefile.am.inc
index 55806534..a561c1d0 100644
--- a/app/Makefile.am.inc
+++ b/app/Makefile.am.inc
@@ -49,8 +49,6 @@ libflatpak_app_la_LIBADD = \
$(APPSTREAM_GLIB_LIBS) \
$(SYSTEMD_LIBS) \
$(POLKIT_LIBS) \
- libglnx.la \
- libflatpak-common.la \
$(NULL)
libflatpak_app_la_CFLAGS = \
@@ -143,6 +141,7 @@ flatpak_LDADD = \
libglnx.la \
libflatpak-app.la \
libflatpak-common.la \
+ libflatpak-common-base.la \
$(NULL)
flatpak_CFLAGS = \
diff --git a/app/flatpak-builtins-build-update-repo.c b/app/flatpak-builtins-build-update-repo.c
index f106436d..6442da4e 100644
--- a/app/flatpak-builtins-build-update-repo.c
+++ b/app/flatpak-builtins-build-update-repo.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014 Red Hat, Inc
+ * Copyright © 2014-2019 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -30,7 +30,7 @@
#include "libglnx/libglnx.h"
#include "flatpak-builtins.h"
-#include "flatpak-utils-private.h"
+#include "flatpak-utils-base-private.h"
#include "flatpak-builtins-utils.h"
static char *opt_title;
diff --git a/common/Makefile.am.inc b/common/Makefile.am.inc
index 3019802f..867c9c05 100644
--- a/common/Makefile.am.inc
+++ b/common/Makefile.am.inc
@@ -1,5 +1,5 @@
lib_LTLIBRARIES += libflatpak.la
-noinst_LTLIBRARIES += libflatpak-common.la
+noinst_LTLIBRARIES += libflatpak-common-base.la libflatpak-common.la
noinst_PROGRAMS += test-libflatpak
flatpakincludedir = $(includedir)/flatpak
@@ -67,9 +67,30 @@ common/flatpak-systemd-dbus-generated.c: data/org.freedesktop.systemd1.xml Makef
common/%-dbus-generated.h: common/%-dbus-generated.c
@true # Built as a side-effect of the rules for the .c
+nodist_libflatpak_common_base_la_SOURCES = \
+ $(dbus_built_sources) \
+ $(NULL)
+
+BUILT_SOURCES += $(nodist_libflatpak_common_base_la_SOURCES)
+CLEANFILES += $(nodist_libflatpak_common_base_la_SOURCES)
+
+libflatpak_common_base_la_SOURCES = \
+ common/flatpak-utils-base.c \
+ common/flatpak-utils-base-private.h \
+ $(NULL)
+
+libflatpak_common_base_la_CFLAGS = \
+ -DFLATPAK_COMPILATION \
+ $(AM_CFLAGS) \
+ $(BASE_CFLAGS) \
+ $(HIDDEN_VISIBILITY_CFLAGS) \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ $(NULL)
+
+libflatpak_common_base_la_LIBADD = $(AM_LIBADD) $(BASE_LIBS)
+
nodist_libflatpak_common_la_SOURCES = \
$(nodist_flatpakinclude_HEADERS) \
- $(dbus_built_sources) \
$(systemd_dbus_built_sources) \
$(xdp_dbus_built_sources) \
common/flatpak-enum-types.c \
@@ -146,7 +167,7 @@ libflatpak_common_la_CFLAGS = \
-DLIBEXECDIR=\"$(libexecdir)\" \
-I$(srcdir)/dbus-proxy \
$(NULL)
-libflatpak_common_la_LIBADD = $(AM_LIBADD) libglnx.la $(ARCHIVE_LIBS) $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) $(JSON_LIBS) $(XAUTH_LIBS) $(XML_LIBS) $(LIBSECCOMP_LIBS) $(INTERNAL_GPGME_LIBS) $(SYSTEMD_LIBS) $(DCONF_LIBS)
+libflatpak_common_la_LIBADD = $(AM_LIBADD) $(ARCHIVE_LIBS) $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) $(JSON_LIBS) $(XAUTH_LIBS) $(XML_LIBS) $(LIBSECCOMP_LIBS) $(INTERNAL_GPGME_LIBS) $(SYSTEMD_LIBS) $(DCONF_LIBS)
libflatpak_la_SOURCES = \
@@ -175,6 +196,8 @@ libflatpak_la_LDFLAGS = \
libflatpak_la_LIBADD = \
$(AM_LIBADD) \
libflatpak-common.la \
+ libflatpak-common-base.la \
+ libglnx.la \
$(BASE_LIBS) \
$(OSTREE_LIBS) \
$(SOUP_LIBS) \
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
index cc3e9bf4..b91dadaa 100644
--- a/common/flatpak-dir.c
+++ b/common/flatpak-dir.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014 Red Hat, Inc
+ * Copyright © 2014-2019 Red Hat, Inc
* Copyright © 2017 Endless Mobile, Inc.
*
* This program is free software; you can redistribute it and/or
@@ -43,7 +43,7 @@
#include <ostree.h>
#include "flatpak-dir-private.h"
-#include "flatpak-utils-private.h"
+#include "flatpak-utils-base-private.h"
#include "flatpak-oci-registry-private.h"
#include "flatpak-run-private.h"
#include "flatpak-appdata-private.h"
diff --git a/common/flatpak-exports.c b/common/flatpak-exports.c
index 7a5694cc..8562712b 100644
--- a/common/flatpak-exports.c
+++ b/common/flatpak-exports.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014-2018 Red Hat, Inc
+ * Copyright © 2014-2019 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -43,7 +43,7 @@
#include "flatpak-exports-private.h"
#include "flatpak-run-private.h"
#include "flatpak-proxy.h"
-#include "flatpak-utils-private.h"
+#include "flatpak-utils-base-private.h"
#include "flatpak-dir-private.h"
#include "flatpak-systemd-dbus-generated.h"
#include "flatpak-error.h"
diff --git a/common/flatpak-run.c b/common/flatpak-run.c
index e1cf7153..77cbcf95 100644
--- a/common/flatpak-run.c
+++ b/common/flatpak-run.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014 Red Hat, Inc
+ * Copyright © 2014-2019 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -52,7 +52,7 @@
#include "flatpak-run-private.h"
#include "flatpak-proxy.h"
-#include "flatpak-utils-private.h"
+#include "flatpak-utils-base-private.h"
#include "flatpak-dir-private.h"
#include "flatpak-systemd-dbus-generated.h"
#include "flatpak-document-dbus-generated.h"
diff --git a/common/flatpak-utils-base-private.h b/common/flatpak-utils-base-private.h
new file mode 100644
index 00000000..d7a55273
--- /dev/null
+++ b/common/flatpak-utils-base-private.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2019 Red Hat, Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alexander Larsson <alexl@redhat.com>
+ */
+
+#ifndef __FLATPAK_UTILS_BASE_H__
+#define __FLATPAK_UTILS_BASE_H__
+
+#include <glib.h>
+
+char *flatpak_get_timezone (void);
+
+char * flatpak_readlink (const char *path,
+ GError **error);
+char * flatpak_resolve_link (const char *path,
+ GError **error);
+char * flatpak_canonicalize_filename (const char *path);
+
+#endif /* __FLATPAK_UTILS_BASE_H__ */
diff --git a/common/flatpak-utils-base.c b/common/flatpak-utils-base.c
new file mode 100644
index 00000000..07d7725e
--- /dev/null
+++ b/common/flatpak-utils-base.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright © 2019 Red Hat, Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alexander Larsson <alexl@redhat.com>
+ */
+
+#include "config.h"
+
+#include "flatpak-utils-base-private.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <gio/gio.h>
+#include "libglnx/libglnx.h"
+
+char *
+flatpak_get_timezone (void)
+{
+ g_autofree gchar *symlink = NULL;
+ gchar *etc_timezone = NULL;
+ const gchar *tzdir;
+
+ tzdir = getenv ("TZDIR");
+ if (tzdir == NULL)
+ tzdir = "/usr/share/zoneinfo";
+
+ symlink = flatpak_resolve_link ("/etc/localtime", NULL);
+ if (symlink != NULL)
+ {
+ /* Resolve relative path */
+ g_autofree gchar *canonical = flatpak_canonicalize_filename (symlink);
+ char *canonical_suffix;
+
+ /* Strip the prefix and slashes if possible. */
+ if (g_str_has_prefix (canonical, tzdir))
+ {
+ canonical_suffix = canonical + strlen (tzdir);
+ while (*canonical_suffix == '/')
+ canonical_suffix++;
+
+ return g_strdup (canonical_suffix);
+ }
+ }
+
+ if (g_file_get_contents ("/etc/timezeone", &etc_timezone,
+ NULL, NULL))
+ {
+ g_strchomp (etc_timezone);
+ return etc_timezone;
+ }
+
+ /* Final fall-back is UTC */
+ return g_strdup ("UTC");
+}
+
+char *
+flatpak_readlink (const char *path,
+ GError **error)
+{
+ return glnx_readlinkat_malloc (-1, path, NULL, error);
+}
+
+char *
+flatpak_resolve_link (const char *path,
+ GError **error)
+{
+ g_autofree char *link = flatpak_readlink (path, error);
+ g_autofree char *dirname = NULL;
+
+ if (link == NULL)
+ return NULL;
+
+ if (g_path_is_absolute (link))
+ return g_steal_pointer (&link);
+
+ dirname = g_path_get_dirname (path);
+ return g_build_filename (dirname, link, NULL);
+}
+
+char *
+flatpak_canonicalize_filename (const char *path)
+{
+ g_autoptr(GFile) file = g_file_new_for_path (path);
+ return g_file_get_path (file);
+}
diff --git a/common/flatpak-utils-private.h b/common/flatpak-utils-private.h
index 0151b525..bedeffd1 100644
--- a/common/flatpak-utils-private.h
+++ b/common/flatpak-utils-private.h
@@ -113,8 +113,6 @@ gboolean flatpak_extension_matches_reason (const char *extension_id,
const char * flatpak_get_bwrap (void);
-char *flatpak_get_timezone (void);
-
char **flatpak_strv_merge (char **strv1,
char **strv2);
char **flatpak_subpaths_merge (char **subpaths1,
@@ -603,12 +601,6 @@ gboolean flatpak_canonicalize_permissions (int parent_dfd,
int gid,
GError **error);
-char * flatpak_readlink (const char *path,
- GError **error);
-char * flatpak_resolve_link (const char *path,
- GError **error);
-char * flatpak_canonicalize_filename (const char *path);
-
gboolean flatpak_file_rename (GFile *from,
GFile *to,
GCancellable *cancellable,
diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c
index 0521b049..ed32ac30 100644
--- a/common/flatpak-utils.c
+++ b/common/flatpak-utils.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014 Red Hat, Inc
+ * Copyright © 2014-2019 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -25,6 +25,7 @@
#include "flatpak-dir-private.h"
#include "flatpak-oci-registry-private.h"
#include "flatpak-run-private.h"
+#include "flatpak-utils-base-private.h"
#include "valgrind-private.h"
#include <glib/gi18n-lib.h>
@@ -638,46 +639,6 @@ flatpak_get_bwrap (void)
return HELPER;
}
-char *
-flatpak_get_timezone (void)
-{
- g_autofree gchar *symlink = NULL;
- gchar *etc_timezone = NULL;
- const gchar *tzdir;
-
- tzdir = getenv ("TZDIR");
- if (tzdir == NULL)
- tzdir = "/usr/share/zoneinfo";
-
- symlink = flatpak_resolve_link ("/etc/localtime", NULL);
- if (symlink != NULL)
- {
- /* Resolve relative path */
- g_autofree gchar *canonical = flatpak_canonicalize_filename (symlink);
- char *canonical_suffix;
-
- /* Strip the prefix and slashes if possible. */
- if (g_str_has_prefix (canonical, tzdir))
- {
- canonical_suffix = canonical + strlen (tzdir);
- while (*canonical_suffix == '/')
- canonical_suffix++;
-
- return g_strdup (canonical_suffix);
- }
- }
-
- if (g_file_get_contents ("/etc/timezeone", &etc_timezone,
- NULL, NULL))
- {
- g_strchomp (etc_timezone);
- return etc_timezone;
- }
-
- /* Final fall-back is UTC */
- return g_strdup ("UTC");
-}
-
static gboolean
is_valid_initial_name_character (gint c, gboolean allow_dash)
{
@@ -2441,37 +2402,6 @@ flatpak_rm_rf (GFile *dir,
cancellable, error);
}
-char *
-flatpak_readlink (const char *path,
- GError **error)
-{
- return glnx_readlinkat_malloc (-1, path, NULL, error);
-}
-
-char *
-flatpak_resolve_link (const char *path,
- GError **error)
-{
- g_autofree char *link = flatpak_readlink (path, error);
- g_autofree char *dirname = NULL;
-
- if (link == NULL)
- return NULL;
-
- if (g_path_is_absolute (link))
- return g_steal_pointer (&link);
-
- dirname = g_path_get_dirname (path);
- return g_build_filename (dirname, link, NULL);
-}
-
-char *
-flatpak_canonicalize_filename (const char *path)
-{
- g_autoptr(GFile) file = g_file_new_for_path (path);
- return g_file_get_path (file);
-}
-
gboolean
flatpak_file_rename (GFile *from,
GFile *to,
diff --git a/session-helper/Makefile.am.inc b/session-helper/Makefile.am.inc
index 7ea49bf0..f56c94b1 100644
--- a/session-helper/Makefile.am.inc
+++ b/session-helper/Makefile.am.inc
@@ -12,5 +12,5 @@ flatpak_session_helper_SOURCES = \
session-helper/flatpak-session-helper.c \
$(NULL)
-flatpak_session_helper_LDADD = $(AM_LDADD) $(BASE_LIBS) libflatpak-common.la
-flatpak_session_helper_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(SOUP_CFLAGS) $(OSTREE_CFLAGS) $(GSYSTEM_CFLAGS) $(JSON_CFLAGS) -DFLATPAK_COMPILATION
+flatpak_session_helper_LDADD = $(AM_LDADD) $(BASE_LIBS) libflatpak-common-base.la libglnx.la
+flatpak_session_helper_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) -DFLATPAK_COMPILATION
diff --git a/session-helper/flatpak-session-helper.c b/session-helper/flatpak-session-helper.c
index 0fbac666..26e83fc6 100644
--- a/session-helper/flatpak-session-helper.c
+++ b/session-helper/flatpak-session-helper.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014 Red Hat, Inc
+ * Copyright © 2014-2019 Red Hat, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,6 +20,7 @@
#include "config.h"
+#include <errno.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
@@ -28,7 +29,7 @@
#include <gio/gio.h>
#include <gio/gunixfdlist.h>
#include "flatpak-dbus-generated.h"
-#include "flatpak-utils-private.h"
+#include "flatpak-utils-base-private.h"
typedef enum {
FLATPAK_HOST_COMMAND_FLAGS_CLEAR_ENV = 1 << 0,
diff --git a/system-helper/Makefile.am.inc b/system-helper/Makefile.am.inc
index cce749ce..6152ec99 100644
--- a/system-helper/Makefile.am.inc
+++ b/system-helper/Makefile.am.inc
@@ -18,7 +18,7 @@ flatpak_system_helper_SOURCES = \
system-helper/flatpak-system-helper.c \
$(NULL)
-flatpak_system_helper_LDADD = $(BASE_LIBS) $(OSTREE_LIBS) $(JSON_LIBS) $(POLKIT_LIBS) libflatpak-common.la
+flatpak_system_helper_LDADD = $(BASE_LIBS) $(OSTREE_LIBS) $(JSON_LIBS) $(POLKIT_LIBS) libflatpak-common.la libflatpak-common-base.la libglnx.la
flatpak_system_helper_CFLAGS = $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(APPSTREAM_GLIB_CFLAGS) $(SOUP_CFLAGS) $(JSON_CFLAGS) $(POLKIT_CFLAGS) -DFLATPAK_COMPILATION -DLIBEXECDIR=\"$(libexecdir)\"
system-helper/org.freedesktop.Flatpak.rules: system-helper/org.freedesktop.Flatpak.rules.in
diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc
index 28c18837..9039c1ed 100644
--- a/tests/Makefile.am.inc
+++ b/tests/Makefile.am.inc
@@ -53,9 +53,10 @@ testcommon_LDADD = \
$(SOUP_LIBS) \
$(JSON_LIBS) \
$(APPSTREAM_GLIB_LIBS) \
- libglnx.la \
- libflatpak-common.la \
libflatpak-app.la \
+ libflatpak-common.la \
+ libflatpak-common-base.la \
+ libglnx.la \
$(NULL)
testcommon_SOURCES = tests/testcommon.c
@@ -63,7 +64,7 @@ tests_httpcache_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(SOUP_CFL
-DFLATPAK_COMPILATION \
-DLOCALEDIR=\"$(localedir)\"
tests_httpcache_LDADD = $(AM_LDADD) $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) $(JSON_LIBS) $(APPSTREAM_GLIB_LIBS) \
- libglnx.la libflatpak-common.la
+ libflatpak-common.la libflatpak-common-base.la libglnx.la
tests/services/org.freedesktop.Flatpak.service: session-helper/org.freedesktop.Flatpak.service.in
mkdir -p tests/services