Commit 0797aa15 authored by Martin Pitt's avatar Martin Pitt
Browse files

sysv-generator: Handle .sh suffixes when translating Provides:

Patch sent to upstream, but not applied yet:

  http://lists.freedesktop.org/archives/systemd-devel/2015-January/027248.html

Test case removed from the patch as we don't have the sysv-generator test suite
in 215 yet.

Closes: #775889
parent 12be9c68
systemd (215-10) UNRELEASED; urgency=medium
[ Martin Pitt ]
* sysv-generator: Handle .sh suffixes when translating Provides:.
(Closes: #775889)
[ Christian Kastner ]
* Use common-session-noninteractive in systemd-user's PAM config, instead of
common-session. The latter can include PAM modules like libpam-mount which
......
......@@ -177,3 +177,4 @@ Prefer-etc-X11-default-display-manager-if-present.patch
core-Fix-bind-error-message.patch
core-Make-binding-notify-private-dbus-socket-more-ro.patch
Fix-usr-remount-failure-for-split-usr.patch
sysv-generator-Handle-.sh-suffixes-when-translating-.patch
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Tue, 20 Jan 2015 16:41:31 +0100
Subject: sysv-generator: Handle .sh suffixes when translating Provides:
When deciding whether the provided name equals the file name in
sysv_translate_facility(), also consider them equal if the file name has a
".sh" suffix.
This was uncovered by commit b7e7184 which then created a symlink
"<name>.service" to itself for ".sh" suffixed init.d scripts.
For additional robustness, refuse to create symlinks to itself in add_alias().
Bug-Debian: https://bugs.debian.org/775889
---
src/sysv-generator/sysv-generator.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 2f116fb..b7b62d6 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -125,6 +125,11 @@ static int add_alias(const char *service, const char *alias) {
assert(service);
assert(alias);
+ if (streq(service, alias)) {
+ log_error("Ignoring creation of an alias %s for itself", service);
+ return 0;
+ }
+
link = strjoin(arg_dest, "/", alias, NULL);
if (!link)
return log_oom();
@@ -283,6 +288,7 @@ static int sysv_translate_facility(const char *name, const char *filename, char
unsigned i;
char *r;
const char *n;
+ _cleanup_free_ char *filename_no_sh = NULL;
assert(name);
assert(_r);
@@ -304,6 +310,13 @@ static int sysv_translate_facility(const char *name, const char *filename, char
goto finish;
}
+ /* strip ".sh" suffix from file name for comparison */
+ filename_no_sh = strdup(filename);
+ if (!filename_no_sh)
+ return -ENOMEM;
+ if (endswith(filename, ".sh"))
+ filename_no_sh[strlen(filename)-3] = '\0';
+
/* If we don't know this name, fallback heuristics to figure
* out whether something is a target or a service alias. */
@@ -313,7 +326,7 @@ static int sysv_translate_facility(const char *name, const char *filename, char
/* Facilities starting with $ are most likely targets */
r = unit_name_build(n, NULL, ".target");
- } else if (filename && streq(name, filename))
+ } else if (filename && streq(name, filename_no_sh))
/* Names equaling the file name of the services are redundant */
return 0;
else
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