Merge daemon binary into main binary
The actual problem I am trying to fix with this is fallout from the introduction of `/usr/libexec/rpm-ostreed`, which required a SELinux policy change. Specifically for CentOS, the base policy is rev'd slowly. My hope was that by merging the daemon code back into `/usr/bin/rpm-ostree` which is labeled `install_exec_t`, starting via systemd would do the right thing. It turns out that doesn't happen. Now later, I'm picking this patch back up because I want to do multprocessing in the daemon (and in the core), and it makes sense to share code between them, because multiprocessing will need to go through a re-exec path. Another benefit is we avoid duplicated text (libglnx, internal helpers) between the two binaries. Closes: #292 Approved by: jlebon
This commit is contained in:
parent
7887c5a923
commit
687567d3ee
@ -1,5 +1,3 @@
|
||||
libexec_PROGRAMS += rpm-ostreed
|
||||
|
||||
dbus_built_sources = rpm-ostreed-generated.h rpm-ostreed-generated.c
|
||||
|
||||
rpm-ostreed-generated.h: rpm-ostreed-generated.c
|
||||
@ -64,24 +62,6 @@ librpmostreed_la_LIBADD = \
|
||||
$(CAP_LIBS)
|
||||
$(NULL)
|
||||
|
||||
rpm_ostreed_SOURCES = \
|
||||
src/daemon/main.c \
|
||||
$(NULL)
|
||||
|
||||
rpm_ostreed_CFLAGS = \
|
||||
$(AM_CFLAGS) \
|
||||
-DPKGLIBDIR=\"$(pkglibdir)\" \
|
||||
$(PKGDEP_RPMOSTREE_CFLAGS) \
|
||||
-I$(srcdir)/src/daemon \
|
||||
-I$(srcdir)/libglnx \
|
||||
-DG_LOG_DOMAIN=\"rpm-ostreed\" \
|
||||
$(NULL)
|
||||
|
||||
rpm_ostreed_LDADD = \
|
||||
librpmostreed.la \
|
||||
$(PKGDEP_RPMOSTREE_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
dbusconf_DATA = $(srcdir)/src/daemon/org.projectatomic.rpmostree1.conf
|
||||
dbusconfdir = ${sysconfdir}/dbus-1/system.d
|
||||
|
||||
@ -96,9 +76,13 @@ endif
|
||||
$(systemdunit_DATA): Makefile
|
||||
$(SED_SUBST) $(daemon_asan_options) $@.in > $@
|
||||
|
||||
# We keep this stub script around to have SELinux labeling work,
|
||||
# plus some backwards compatibility.
|
||||
libexec_SCRIPTS = rpm-ostreed
|
||||
rpm-ostreed: $(srcdir)/src/daemon/rpm-ostreed-stub.sh.in Makefile
|
||||
$(SED_SUBST) $< > $@.tmp && mv $@.tmp $@
|
||||
|
||||
install-daemon-altname-hook:
|
||||
mv $(DESTDIR)$(libexecdir)/rpm-ostreed $(DESTDIR)$(libexecdir)/$(primaryname)d
|
||||
ln -sf $(primaryname)d $(DESTDIR)$(libexecdir)/rpm-ostreed
|
||||
mv $(DESTDIR)$(systemdunitdir)/rpm-ostreed.service $(DESTDIR)$(systemdunitdir)/$(primaryname)d.service
|
||||
ln -sf $(primaryname)d.service $(DESTDIR)$(systemdunitdir)/rpm-ostreed.service
|
||||
if BUILDOPT_NEW_NAME
|
||||
@ -109,8 +93,8 @@ endif
|
||||
service_in_files = $(srcdir)/src/daemon/org.projectatomic.rpmostree1.service.in
|
||||
service_DATA = $(service_in_files:.service.in=.service)
|
||||
servicedir = $(dbusservicedir)
|
||||
$(service_DATA):
|
||||
$(SED_SUBST) $@.in > $@
|
||||
%.service: %.service.in Makefile
|
||||
$(SED_SUBST) $@.in > $@.tmp && mv $@.tmp $@
|
||||
|
||||
EXTRA_DIST += \
|
||||
$(dbusservice_DATA) \
|
||||
|
@ -41,6 +41,7 @@ rpm_ostree_SOURCES = src/app/main.c \
|
||||
src/app/rpmostree-container-builtins.h \
|
||||
src/app/rpmostree-container-builtins.c \
|
||||
src/app/rpmostree-internals-builtin-unpack.c \
|
||||
src/app/rpmostree-internals-builtin-start-daemon.c \
|
||||
src/app/rpmostree-libbuiltin.c \
|
||||
src/app/rpmostree-libbuiltin.h \
|
||||
$(NULL)
|
||||
@ -53,8 +54,10 @@ rpm_ostree_SOURCES += \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
rpm_ostree_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src/app -I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS)
|
||||
rpm_ostree_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la librpmostree-1.la
|
||||
rpm_ostree_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src/app -I$(srcdir)/src/daemon \
|
||||
-I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) \
|
||||
-DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS)
|
||||
rpm_ostree_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la librpmostree-1.la librpmostreed.la
|
||||
|
||||
privdatadir=$(pkglibdir)
|
||||
privdata_DATA = src/app/rpm-ostree-0-integration.conf
|
||||
|
@ -50,6 +50,7 @@ GITIGNOREFILES += build-aux/ gtk-doc.make config.h.in aclocal.m4 insttree/
|
||||
SED_SUBST = sed \
|
||||
-e 's,[@]libexecdir[@],$(libexecdir),g' \
|
||||
-e 's,[@]primaryname[@],$(primaryname),g' \
|
||||
-e 's,[@]bindir[@],$(bindir),g' \
|
||||
$(NULL)
|
||||
|
||||
libglnx_srcpath := $(srcdir)/libglnx
|
||||
|
@ -30,6 +30,7 @@ typedef struct {
|
||||
|
||||
static RpmOstreeInternalsCommand internals_subcommands[] = {
|
||||
{ "unpack", rpmostree_internals_builtin_unpack },
|
||||
{ "start-daemon", rpmostree_internals_builtin_start_daemon },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,9 @@ get_connection_for_path (gchar *sysroot,
|
||||
gboolean ret = FALSE;
|
||||
|
||||
const gchar *args[] = {
|
||||
"rpm-ostreed",
|
||||
"rpm-ostree",
|
||||
"internals",
|
||||
"start-daemon",
|
||||
"--sysroot", sysroot,
|
||||
"--dbus-peer", buffer,
|
||||
NULL
|
||||
|
@ -1,33 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2010 David Zeuthen <zeuthen@gmail.com>
|
||||
* Copyright (C) 2013-2015 Red Hat, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
*
|
||||
* Copyright (C) 2016 Colin Walters <walters@verbum.org>
|
||||
*
|
||||
* 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 of the licence 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, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "rpmostreed-daemon.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <string.h>
|
||||
#include <glib-unix.h>
|
||||
#include <gio/gio.h>
|
||||
#include <gio/gunixoutputstream.h>
|
||||
#include <stdio.h>
|
||||
#include <libglnx.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <syslog.h>
|
||||
#include "libglnx.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
#include "rpmostree-internals-builtins.h"
|
||||
#include "rpmostree-util.h"
|
||||
#include "rpmostreed-daemon.h"
|
||||
#include "rpmostree-libbuiltin.h"
|
||||
|
||||
static GMainLoop *loop = NULL;
|
||||
static gboolean opt_debug = FALSE;
|
||||
static char *opt_sysroot = "/";
|
||||
@ -292,38 +298,23 @@ out:
|
||||
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
rpmostree_internals_builtin_start_daemon (int argc,
|
||||
char **argv,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GError *error;
|
||||
g_autoptr(GOptionContext) opt_context = NULL;
|
||||
int ret = 1;
|
||||
g_autoptr(GMainLoop) loop = NULL;
|
||||
g_autoptr(GOptionContext) opt_context = g_option_context_new ("rpm-ostreed -- rpm-ostree daemon");
|
||||
GIOChannel *channel;
|
||||
guint name_owner_id = 0;
|
||||
gint ret;
|
||||
|
||||
ret = 1;
|
||||
loop = NULL;
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,36,0)
|
||||
g_type_init ();
|
||||
#endif
|
||||
|
||||
/* See glib/gio/gsocket.c */
|
||||
signal (SIGPIPE, SIG_IGN);
|
||||
|
||||
/* avoid gvfs and gsettings: https://bugzilla.gnome.org/show_bug.cgi?id=767183 */
|
||||
g_assert (g_setenv ("GIO_USE_VFS", "local", TRUE));
|
||||
g_assert (g_setenv ("GSETTINGS_BACKEND", "memory", TRUE));
|
||||
|
||||
opt_context = g_option_context_new ("rpm-ostreed -- rpm-ostree daemon");
|
||||
g_option_context_add_main_entries (opt_context, opt_entries, NULL);
|
||||
error = NULL;
|
||||
if (!g_option_context_parse (opt_context, &argc, &argv, &error))
|
||||
{
|
||||
g_printerr ("Error parsing options: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!g_option_context_parse (opt_context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
if (opt_debug)
|
||||
{
|
||||
@ -371,10 +362,7 @@ main (int argc,
|
||||
NULL, (GDestroyNotify) NULL);
|
||||
}
|
||||
else if (!connect_to_peer (service_dbus_fd))
|
||||
{
|
||||
ret = 1;
|
||||
goto out;
|
||||
}
|
||||
goto out;
|
||||
|
||||
g_debug ("Entering main event loop");
|
||||
|
||||
@ -391,10 +379,5 @@ main (int argc,
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
if (loop != NULL)
|
||||
g_main_loop_unref (loop);
|
||||
|
||||
g_info ("rpm-ostreed exiting");
|
||||
|
||||
return ret;
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean rpmostree_internals_builtin_unpack (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
gboolean rpmostree_internals_builtin_start_daemon (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
[D-BUS Service]
|
||||
Name=org.projectatomic.rpmostree1
|
||||
Exec=@libexecdir@/@primaryname@d
|
||||
Exec=@bindir@/rpm-ostree internals start-daemon
|
||||
User=root
|
||||
SystemdService=@primaryname@d.service
|
||||
|
2
src/daemon/rpm-ostreed-stub.sh.in
Normal file
2
src/daemon/rpm-ostreed-stub.sh.in
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec @bindir@/rpm-ostree internals start-daemon "$@"
|
@ -6,4 +6,4 @@ ConditionPathExists=/ostree
|
||||
Type=dbus
|
||||
BusName=org.projectatomic.rpmostree1
|
||||
@SYSTEMD_ENVIRON@
|
||||
ExecStart=@libexecdir@/@primaryname@d
|
||||
ExecStart=@bindir@/rpm-ostree internals start-daemon
|
||||
|
@ -25,7 +25,7 @@ set -e
|
||||
|
||||
# libtest.sh should have added the builddir which contains rpm-ostreed to our
|
||||
# path
|
||||
exec_binary="$(which rpm-ostreed)"
|
||||
exec_binary="$(which rpm-ostree)"
|
||||
|
||||
mkdir -p sysroot
|
||||
mkdir -p session-services
|
||||
@ -56,7 +56,7 @@ EOF
|
||||
cat > session-services/rpmostree.service <<EOF
|
||||
[D-BUS Service]
|
||||
Name=org.projectatomic.rpmostree1
|
||||
Exec=${exec_binary} --debug --sysroot=${test_tmpdir}/sysroot
|
||||
Exec=${exec_binary} internals start-daemon --debug --sysroot=${test_tmpdir}/sysroot
|
||||
EOF
|
||||
|
||||
# Tell rpm-ostree to connect to the session bus instead of system
|
||||
|
@ -18,7 +18,7 @@ if test -z "${INSIDE_VM:-}"; then
|
||||
DESTDIR=$(pwd)/insttree
|
||||
make install DESTDIR=${DESTDIR}
|
||||
for san in a t ub; do
|
||||
if eu-readelf -d ${DESTDIR}/usr/libexec/rpm-ostreed | grep -q "NEEDED.*lib${san}san"; then
|
||||
if eu-readelf -d ${DESTDIR}/usr/bin/rpm-ostree | grep -q "NEEDED.*lib${san}san"; then
|
||||
echo "Installing extra sanitizier: lib${san}san"
|
||||
cp /usr/lib64/lib${san}san*.so.* ${DESTDIR}/usr/lib64
|
||||
fi
|
||||
|
@ -27,6 +27,7 @@ else
|
||||
set -x
|
||||
ostree admin unlock || :
|
||||
rsync -rlv /var/roothome/sync/insttree/usr/ /usr/
|
||||
restorecon /usr/libexec/rpm-ostreed
|
||||
restorecon -v /usr/bin/rpm-ostree
|
||||
restorecon -v /usr/libexec/rpm-ostreed
|
||||
systemctl restart rpm-ostreed
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user