chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
logger: when passing on PID info, fall back to our own if originating process is...
[elogind.git]
/
src
/
service.c
diff --git
a/src/service.c
b/src/service.c
index ca0db8e7f181e06b5a8bdf65656d67e0c3a46b4b..a28eb8a6b91156e2501c6674aeb544eaf2ed671f 100644
(file)
--- a/
src/service.c
+++ b/
src/service.c
@@
-237,19
+237,23
@@
static char *sysv_translate_name(const char *name) {
if (!(r = new(char, strlen(name) + sizeof(".service"))))
return NULL;
if (!(r = new(char, strlen(name) + sizeof(".service"))))
return NULL;
+#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU)
+ if (endswith(name, ".sh"))
+ /* Drop Debian-style .sh suffix */
+ strcpy(stpcpy(r, name) - 3, ".service");
+#endif
+#ifdef TARGET_SUSE
if (startswith(name, "boot."))
/* Drop SuSE-style boot. prefix */
strcpy(stpcpy(r, name + 5), ".service");
if (startswith(name, "boot."))
/* Drop SuSE-style boot. prefix */
strcpy(stpcpy(r, name + 5), ".service");
- else if (endswith(name, ".sh"))
- /* Drop Debian-style .sh suffix */
- strcpy(stpcpy(r, name) - 3, ".service");
+#endif
#ifdef TARGET_ARCH
#ifdef TARGET_ARCH
-
else
if (startswith(name, "@"))
+ if (startswith(name, "@"))
/* Drop Arch-style background prefix */
strcpy(stpcpy(r, name + 1), ".service");
#endif
#ifdef TARGET_FRUGALWARE
/* Drop Arch-style background prefix */
strcpy(stpcpy(r, name + 1), ".service");
#endif
#ifdef TARGET_FRUGALWARE
-
else
if (startswith(name, "rc."))
+ if (startswith(name, "rc."))
/* Drop Frugalware-style rc. prefix */
strcpy(stpcpy(r, name + 3), ".service");
#endif
/* Drop Frugalware-style rc. prefix */
strcpy(stpcpy(r, name + 3), ".service");
#endif
@@
-324,10
+328,13
@@
static int sysv_translate_facility(const char *name, const char *filename, char
/* If we don't know this name, fallback heuristics to figure
* out whether something is a target or a service alias. */
/* If we don't know this name, fallback heuristics to figure
* out whether something is a target or a service alias. */
- if (*name == '$')
+ if (*name == '$') {
+ if (!unit_prefix_is_valid(n))
+ return -EINVAL;
+
/* Facilities starting with $ are most likely targets */
r = unit_name_build(n, NULL, ".target");
/* 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))
/* Names equalling the file name of the services are redundant */
return 0;
else
/* Names equalling the file name of the services are redundant */
return 0;
else
@@
-680,10
+687,14
@@
static int service_load_sysv_path(Service *s, const char *path) {
}
r = sysv_translate_facility(n, file_name_from_path(path), &m);
}
r = sysv_translate_facility(n, file_name_from_path(path), &m);
- free(n);
- if (r < 0)
- goto finish;
+ if (r < 0) {
+ log_error("[%s:%u] Failed to translate LSB dependency %s, ignoring: %s", path, line, n, strerror(-r));
+ free(n);
+ continue;
+ }
+
+ free(n);
if (r == 0)
continue;
if (r == 0)
continue;
@@
-857,10
+868,20
@@
static int service_load_sysv_name(Service *s, const char *name) {
/* For SysV services we strip the boot.*, rc.* and *.sh
* prefixes/suffixes. */
/* For SysV services we strip the boot.*, rc.* and *.sh
* prefixes/suffixes. */
- if (startswith(name, "boot.") ||
- startswith(name, "rc.") ||
- endswith(name, ".sh.service"))
+#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU)
+ if (endswith(name, ".sh.service"))
return -ENOENT;
return -ENOENT;
+#endif
+
+#ifdef TARGET_SUSE
+ if (startswith(name, "boot."))
+ return -ENOENT;
+#endif
+
+#ifdef TARGET_FRUGALWARE
+ if (startswith(name, "rc."))
+ return -ENOENT;
+#endif
STRV_FOREACH(p, s->meta.manager->lookup_paths.sysvinit_path) {
char *path;
STRV_FOREACH(p, s->meta.manager->lookup_paths.sysvinit_path) {
char *path;