forked from pool/systemd
Marcus Meissner
5aeb3c6333
- Add 0001-acpi-fptd-fix-memory-leak-in-acpi_get_boot_usec.patch: fix acpi memleak. - Add 0002-fix-lingering-references-to-var-lib-backlight-random.patch: fix invalid path in documentation. - Add 0003-acpi-make-sure-we-never-free-an-uninitialized-pointe.patch: fix invalid memory free. - Add 0004-systemctl-fix-name-mangling-for-sysv-units.patch: fix name mangling for sysv units. - Add 0005-cryptsetup-fix-OOM-handling-when-parsing-mount-optio.patch: fix OOM handling. - Add 0006-journald-add-missing-error-check.patch: add missing error check. - Add 0007-bus-fix-potentially-uninitialized-memory-access.patch: fix uninitialized memory access. - Add 0008-dbus-fix-return-value-of-dispatch_rqueue.patch: fix return value. - Add 0009-modules-load-fix-error-handling.patch: fix error handling. - Add 0010-efi-never-call-qsort-on-potentially-NULL-arrays.patch: fix incorrect memory access. - Add 0011-strv-don-t-access-potentially-NULL-string-arrays.patch: fix incorrect memory access. - Add 0012-mkdir-pass-a-proper-function-pointer-to-mkdir_safe_i.patch: fix invalid pointer. - Add 0014-tmpfiles.d-include-setgid-perms-for-run-log-journal.patch: OBS-URL: https://build.opensuse.org/request/show/202117 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=452
135 lines
4.4 KiB
Diff
135 lines
4.4 KiB
Diff
From cbb13b2a538ece1c7ec3b210e2b36b47df2a13ea Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?V=C3=A1clav=20Pavl=C3=ADn?= <vpavlin@redhat.com>
|
|
Date: Wed, 2 Oct 2013 16:42:42 +0200
|
|
Subject: [PATCH 04/15] systemctl: fix name mangling for sysv units
|
|
|
|
---
|
|
src/systemctl/systemctl.c | 45 ++++++++++++++++++---------------------------
|
|
1 file changed, 18 insertions(+), 27 deletions(-)
|
|
|
|
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
|
|
index bb7ada9..d75281f 100644
|
|
--- a/src/systemctl/systemctl.c
|
|
+++ b/src/systemctl/systemctl.c
|
|
@@ -4218,11 +4218,10 @@ static int set_environment(DBusConnection *bus, char **args) {
|
|
return 0;
|
|
}
|
|
|
|
-static int enable_sysv_units(char **args) {
|
|
+static int enable_sysv_units(const char *verb, char **args) {
|
|
int r = 0;
|
|
|
|
#if defined(HAVE_SYSV_COMPAT) && defined(HAVE_CHKCONFIG)
|
|
- const char *verb = args[0];
|
|
unsigned f = 1, t = 1;
|
|
LookupPaths paths = {};
|
|
|
|
@@ -4242,7 +4241,7 @@ static int enable_sysv_units(char **args) {
|
|
return r;
|
|
|
|
r = 0;
|
|
- for (f = 1; args[f]; f++) {
|
|
+ for (f = 0; args[f]; f++) {
|
|
const char *name;
|
|
_cleanup_free_ char *p = NULL, *q = NULL;
|
|
bool found_native = false, found_sysv;
|
|
@@ -4365,7 +4364,7 @@ finish:
|
|
lookup_paths_free(&paths);
|
|
|
|
/* Drop all SysV units */
|
|
- for (f = 1, t = 1; args[f]; f++) {
|
|
+ for (f = 0, t = 0; args[f]; f++) {
|
|
|
|
if (isempty(args[f]))
|
|
continue;
|
|
@@ -4423,16 +4422,16 @@ static int enable_unit(DBusConnection *bus, char **args) {
|
|
|
|
dbus_error_init(&error);
|
|
|
|
- r = enable_sysv_units(args);
|
|
- if (r < 0)
|
|
- return r;
|
|
-
|
|
if (!args[1])
|
|
return 0;
|
|
|
|
r = mangle_names(args+1, &mangled_names);
|
|
if (r < 0)
|
|
- goto finish;
|
|
+ return r;
|
|
+
|
|
+ r = enable_sysv_units(verb, mangled_names);
|
|
+ if (r < 0)
|
|
+ return r;
|
|
|
|
if (!bus || avoid_bus()) {
|
|
if (streq(verb, "enable")) {
|
|
@@ -4624,11 +4623,15 @@ static int unit_is_enabled(DBusConnection *bus, char **args) {
|
|
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
|
|
bool enabled;
|
|
char **name;
|
|
- char *n;
|
|
+ _cleanup_strv_free_ char **mangled_names = NULL;
|
|
|
|
dbus_error_init(&error);
|
|
|
|
- r = enable_sysv_units(args);
|
|
+ r = mangle_names(args+1, &mangled_names);
|
|
+ if (r < 0)
|
|
+ return r;
|
|
+
|
|
+ r = enable_sysv_units(args[0], mangled_names);
|
|
if (r < 0)
|
|
return r;
|
|
|
|
@@ -4636,16 +4639,10 @@ static int unit_is_enabled(DBusConnection *bus, char **args) {
|
|
|
|
if (!bus || avoid_bus()) {
|
|
|
|
- STRV_FOREACH(name, args+1) {
|
|
+ STRV_FOREACH(name, mangled_names) {
|
|
UnitFileState state;
|
|
|
|
- n = unit_name_mangle(*name);
|
|
- if (!n)
|
|
- return log_oom();
|
|
-
|
|
- state = unit_file_get_state(arg_scope, arg_root, n);
|
|
-
|
|
- free(n);
|
|
+ state = unit_file_get_state(arg_scope, arg_root, *name);
|
|
|
|
if (state < 0)
|
|
return state;
|
|
@@ -4660,13 +4657,9 @@ static int unit_is_enabled(DBusConnection *bus, char **args) {
|
|
}
|
|
|
|
} else {
|
|
- STRV_FOREACH(name, args+1) {
|
|
+ STRV_FOREACH(name, mangled_names) {
|
|
const char *s;
|
|
|
|
- n = unit_name_mangle(*name);
|
|
- if (!n)
|
|
- return log_oom();
|
|
-
|
|
r = bus_method_call_with_reply (
|
|
bus,
|
|
"org.freedesktop.systemd1",
|
|
@@ -4675,11 +4668,9 @@ static int unit_is_enabled(DBusConnection *bus, char **args) {
|
|
"GetUnitFileState",
|
|
&reply,
|
|
NULL,
|
|
- DBUS_TYPE_STRING, &n,
|
|
+ DBUS_TYPE_STRING, name,
|
|
DBUS_TYPE_INVALID);
|
|
|
|
- free(n);
|
|
-
|
|
if (r)
|
|
return r;
|
|
|
|
--
|
|
1.8.4
|
|
|