summaryrefslogtreecommitdiff
path: root/src/path-lookup.c
diff options
context:
space:
mode:
authorFabiano Fidencio <fidencio@profusion.mobi>2010-09-21 00:23:12 -0300
committerLennart Poettering <lennart@poettering.net>2010-09-27 03:25:05 +0200
commit07459bb6b92268beb2599f65cf195708d88c51cc (patch)
treef533168f2e656f3de37a53293b60b1a27b8580be /src/path-lookup.c
parent66d9b3b59551a33398b2201662af5c8c17a367c9 (diff)
sysv: optionally disable of SysV init/rcN.d support at compile time
This patch adds a cpp definition HAVE_SYSV_COMPAT that is used to isolate code dealing with /etc/init.d and /etc/rcN.d for systems where it does not make sense (one that does not use sysv or one that is fully systemd native). The patch tries to be as little intrusive as possible, however in order to minimize the number of #ifdef'ed regions I've reordered some code in path-lookup.c:lookup_paths_init() where all code dealing with sysv is now isolated under running_as == MANAGER_SYSTEM as well. Moreover, In struct Service, some fields were rearranged to reduce the number of ifdefs. Lennart's suggestions were fixed and squashed with the original patch, that was sent by Gustavo Sverzut Barbieri (barbieri@profusion.mobi).
Diffstat (limited to 'src/path-lookup.c')
-rw-r--r--src/path-lookup.c102
1 files changed, 55 insertions, 47 deletions
diff --git a/src/path-lookup.c b/src/path-lookup.c
index 28336ebf15..258252a564 100644
--- a/src/path-lookup.c
+++ b/src/path-lookup.c
@@ -191,7 +191,26 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
return -ENOMEM;
}
+ if (p->unit_path)
+ if (!strv_path_canonicalize(p->unit_path))
+ return -ENOMEM;
+
+ strv_uniq(p->unit_path);
+
+ if (!strv_isempty(p->unit_path)) {
+
+ if (!(t = strv_join(p->unit_path, "\n\t")))
+ return -ENOMEM;
+ log_debug("Looking for unit files in:\n\t%s", t);
+ free(t);
+ } else {
+ log_debug("Ignoring unit files.");
+ strv_free(p->unit_path);
+ p->unit_path = NULL;
+ }
+
if (running_as == MANAGER_SYSTEM) {
+#ifdef HAVE_SYSV_COMPAT
/* /etc/init.d/ compatibility does not matter to users */
if ((e = getenv("SYSTEMD_SYSVINIT_PATH")))
@@ -219,60 +238,46 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
NULL)))
return -ENOMEM;
}
- }
-
- if (p->unit_path)
- if (!strv_path_canonicalize(p->unit_path))
- return -ENOMEM;
-
- if (p->sysvinit_path)
- if (!strv_path_canonicalize(p->sysvinit_path))
- return -ENOMEM;
- if (p->sysvrcnd_path)
- if (!strv_path_canonicalize(p->sysvrcnd_path))
- return -ENOMEM;
-
- strv_uniq(p->unit_path);
- strv_uniq(p->sysvinit_path);
- strv_uniq(p->sysvrcnd_path);
+ if (p->sysvinit_path)
+ if (!strv_path_canonicalize(p->sysvinit_path))
+ return -ENOMEM;
- if (!strv_isempty(p->unit_path)) {
+ if (p->sysvrcnd_path)
+ if (!strv_path_canonicalize(p->sysvrcnd_path))
+ return -ENOMEM;
- if (!(t = strv_join(p->unit_path, "\n\t")))
- return -ENOMEM;
- log_debug("Looking for unit files in:\n\t%s", t);
- free(t);
- } else {
- log_debug("Ignoring unit files.");
- strv_free(p->unit_path);
- p->unit_path = NULL;
- }
+ strv_uniq(p->sysvinit_path);
+ strv_uniq(p->sysvrcnd_path);
- if (!strv_isempty(p->sysvinit_path)) {
+ if (!strv_isempty(p->sysvinit_path)) {
- if (!(t = strv_join(p->sysvinit_path, "\n\t")))
- return -ENOMEM;
+ if (!(t = strv_join(p->sysvinit_path, "\n\t")))
+ return -ENOMEM;
- log_debug("Looking for SysV init scripts in:\n\t%s", t);
- free(t);
- } else {
- log_debug("Ignoring SysV init scripts.");
- strv_free(p->sysvinit_path);
- p->sysvinit_path = NULL;
- }
+ log_debug("Looking for SysV init scripts in:\n\t%s", t);
+ free(t);
+ } else {
+ log_debug("Ignoring SysV init scripts.");
+ strv_free(p->sysvinit_path);
+ p->sysvinit_path = NULL;
+ }
- if (!strv_isempty(p->sysvrcnd_path)) {
+ if (!strv_isempty(p->sysvrcnd_path)) {
- if (!(t = strv_join(p->sysvrcnd_path, "\n\t")))
- return -ENOMEM;
+ if (!(t = strv_join(p->sysvrcnd_path, "\n\t")))
+ return -ENOMEM;
- log_debug("Looking for SysV rcN.d links in:\n\t%s", t);
- free(t);
- } else {
- log_debug("Ignoring SysV rcN.d links.");
- strv_free(p->sysvrcnd_path);
- p->sysvrcnd_path = NULL;
+ log_debug("Looking for SysV rcN.d links in:\n\t%s", t);
+ free(t);
+ } else {
+ log_debug("Ignoring SysV rcN.d links.");
+ strv_free(p->sysvrcnd_path);
+ p->sysvrcnd_path = NULL;
+ }
+#else
+ log_debug("Disabled SysV init scripts and rcN.d links support");
+#endif
}
return 0;
@@ -282,8 +287,11 @@ void lookup_paths_free(LookupPaths *p) {
assert(p);
strv_free(p->unit_path);
+ p->unit_path = NULL;
+
+#ifdef HAVE_SYSV_COMPAT
strv_free(p->sysvinit_path);
strv_free(p->sysvrcnd_path);
-
- p->unit_path = p->sysvinit_path = p->sysvrcnd_path = NULL;
+ p->sysvinit_path = p->sysvrcnd_path = NULL;
+#endif
}