File systemctl-options.patch of Package systemd

Index: systemd-195/src/systemctl/systemctl.c
===================================================================
--- systemd-195.orig/src/systemctl/systemctl.c
+++ systemd-195/src/systemctl/systemctl.c
@@ -5239,6 +5239,7 @@ static int runlevel_main(void) {
 
 int main(int argc, char*argv[]) {
         int r, retval = EXIT_FAILURE;
+        char **to_free = NULL;
         DBusConnection *bus = NULL;
         DBusError error;
 
@@ -5247,6 +5248,27 @@ int main(int argc, char*argv[]) {
         log_parse_environment();
         log_open();
 
+        if (secure_getenv("SYSTEMCTL_OPTIONS")) {
+                char **parsed_systemctl_options = strv_split_quoted(getenv("SYSTEMCTL_OPTIONS"));
+
+                if (*parsed_systemctl_options && **parsed_systemctl_options) {
+                        char **k,**a;
+                        char **new_argv = new(char*, strv_length(argv) + strv_length(parsed_systemctl_options) + 1);
+                        new_argv[0] = strdup(argv[0]);
+                        for (k = new_argv+1, a = parsed_systemctl_options; *a; k++, a++) {
+                                *k = strdup(*a);
+                        }
+                        for (a = argv+1; *a; k++, a++) {
+                                *k = strdup(*a);
+                        }
+                        *k = NULL;
+                        argv = new_argv;
+                        argc = strv_length(new_argv);
+                        strv_free (parsed_systemctl_options);
+                        to_free = new_argv;
+                }
+        }
+
         r = parse_argv(argc, argv);
         if (r < 0)
                 goto finish;
@@ -5348,6 +5370,8 @@ finish:
 
         strv_free(arg_property);
 
+        strv_free(to_free);
+
         pager_close();
         ask_password_agent_close();
         polkit_agent_close();
openSUSE Build Service is sponsored by