Commit fb254a20 authored by Martin Pitt's avatar Martin Pitt
Browse files

Revert "Handle multiple display managers which don't ship a systemd unit, part 2"

This reverts commits 9868be77 and 2e3f2d06.

This is still under dispute, a bit risky, and might get a different
implementation. Also, nodm really needs to be fixed properly, working around it
is both too risky and also too hard to get right.
parent 0c504dd6
......@@ -5,14 +5,10 @@ systemd (215-8) UNRELEASED; urgency=medium
the generator.
* Cherry-pick util-allow-strappenda-to-take-any-number-of-args.patch, we
will use that function in the generator.
* Handle multiple display managers which don't ship a systemd unit:
- Add a generator to ensure /etc/X11/default-display-manager is
controlling which display-manager is started.
- Modify insserv generator to mask sysvinit-only display managers (those
which refer to insserv's $x-display-manager tag) if they don't match
/etc/X11/default-display-manager. This avoids starting multiple DMs at
boot.
- (Closes: #771287)
* Handle multiple display managers which don't ship a systemd unit or the
corresponding postinst logic for updating display-manager.service: Add a
generator to ensure /etc/X11/default-display-manager is controlling which
display-manager is started. (Closes: #771287)
[ Sjoerd Simons ]
* d/p/core-Fix-bind-error-message.patch:
......
......@@ -12,18 +12,13 @@ It has the following modifications:
- it removes support for boot. and bool.localfs which is a SuSE specific
extension
- it ensures that targets do not start other targets or services
- it masks all sysvinit display managers (tagged with an insserv
$x-display-manager) not matching /etc/X11/default-display-manager, and
doesn't generate units having systemd system units already. Note that
it's a noop if /etc/X11/default-display-manager doesn't exist or don't
match an existing unit systemd file.
[0] https://build.opensuse.org/package/view_file/openSUSE:Factory/systemd/insserv-generator.patch
---
Makefile.am | 9 +
src/insserv-generator/Makefile | 28 +++
src/insserv-generator/insserv-generator.c | 377 ++++++++++++++++++++++++++++++
3 files changed, 414 insertions(+)
src/insserv-generator/insserv-generator.c | 324 ++++++++++++++++++++++++++++++
3 files changed, 361 insertions(+)
create mode 100644 src/insserv-generator/Makefile
create mode 100644 src/insserv-generator/insserv-generator.c
......@@ -90,10 +85,10 @@ index 0000000..9d07505
+.PHONY: all clean
diff --git a/src/insserv-generator/insserv-generator.c b/src/insserv-generator/insserv-generator.c
new file mode 100644
index 0000000..9d417f0
index 0000000..d86ee29
--- /dev/null
+++ b/src/insserv-generator/insserv-generator.c
@@ -0,0 +1,378 @@
@@ -0,0 +1,324 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
......@@ -130,8 +125,6 @@ index 0000000..9d417f0
+#include "strv.h"
+
+static const char *arg_dest = "/tmp";
+static const char *arg_override = "/tmp";
+static const char *default_dm = NULL;
+
+static char *sysv_translate_name(const char *name) {
+ char *r;
......@@ -218,53 +211,11 @@ index 0000000..9d417f0
+ return 1;
+}
+
+/* if we have a display-manager which doesn't match /etc/X11/default-display-manager, and don't have
+ an unit file, we mask it to simulate the init script behavior */
+static int mask_display_manager_init(const char *name) {
+ static const char *default_dm_file = "/etc/X11/default-display-manager";
+ _cleanup_free_ char *default_dm_path = NULL;
+ char *defaultdm_unit_path = NULL;;
+ const char *in_mem_symlink = NULL;
+ int r;
+
+ if (!default_dm) {
+ r = read_full_file(default_dm_file, &default_dm_path, NULL);
+ if (r >= 0)
+ default_dm = strstrip(basename((char *)default_dm_path));
+ else
+ /* ensure we won't match any non systemd init. The old init script won't have started anyway */
+ default_dm = "";
+ }
+
+ /* if default dm isn't a systemd service, we roll back to previous behavior: let all non systemd units starting */
+ defaultdm_unit_path = strappenda(SYSTEM_DATA_UNIT_PATH, "/", default_dm, ".service");
+ if (access(defaultdm_unit_path, F_OK) < 0 && (errno == ENOENT))
+ return 0;
+
+ /* init script is default dm, nothing to do */
+ if (streq(default_dm, name))
+ return 0;
+
+ in_mem_symlink = strappenda(arg_override, "/", name, ".service");
+ mkdir_parents_label(in_mem_symlink, 0755);
+ if (symlink("/dev/null", in_mem_symlink) < 0) {
+ log_error("Failed to create symlink %s: %m", in_mem_symlink);
+ return -errno;
+ }
+
+ return 0;
+}
+
+
+static int parse_insserv_conf(const char* filename) {
+ _cleanup_fclose_ FILE *f = NULL;
+ int r;
+ const char *target_unit_path = NULL;
+
+ /* skip if we have a system a corresponding unit file */
+ target_unit_path = strappenda(SYSTEM_DATA_UNIT_PATH, "/", basename(filename), ".service");
+ if (access(target_unit_path, F_OK) >= 0)
+ return 0;
+
+ if (!(f = fopen(filename, "re"))) {
+ log_debug("Failed to open file %s", filename);
......@@ -346,14 +297,6 @@ index 0000000..9d417f0
+ }
+ }
+
+ if (streq(parsed[0], "$x-display-manager")) {
+ r = mask_display_manager_init(name);
+ /* we couldn't create the override symlink, with some luck, nothing else than x-display-manager
+ will pull it in the dep chain */
+ if (r < 0)
+ continue;
+ }
+
+ unit = strjoin(arg_dest, "/", dep, ".d/50-",basename(filename),"-",parsed[0],".conf", NULL);
+ if (!unit)
+ return log_oom();
......@@ -457,10 +400,8 @@ index 0000000..9d417f0
+ return EXIT_FAILURE;
+ }
+
+ if (argc > 1) {
+ if (argc > 1)
+ arg_dest = argv[1];
+ arg_override = argv[2];
+ }
+
+ log_set_target(LOG_TARGET_SAFE);
+ log_parse_environment();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment