~upstart-devel/upstart/trunk

« back to all changes in this revision

Viewing changes to init/control.c

  • Committer: Steve Langasek
  • Date: 2016-04-29 21:18:24 UTC
  • mfrom: (1666.1.2 upstart)
  • Revision ID: steve.langasek@canonical.com-20160429211824-tnh1lrhzfjd2gfv3
MergeĀ lp:~xnox/upstart/lp1433013

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
#include "xdg.h"
63
63
 
64
64
#include "com.ubuntu.Upstart.h"
 
65
#include "org.freedesktop.DBus.h"
65
66
 
66
67
#ifdef ENABLE_CGROUPS
67
68
#include "cgroup.h"
1421
1422
                        nih_assert (job->env);
1422
1423
 
1423
1424
                        NIH_MUST (environ_add (&job->env, job, NULL, replace, envvar));
1424
 
                } else if (job_class_environment_set (envvar, replace) < 0) {
1425
 
                        nih_return_no_memory_error (-1);
 
1425
                } else {
 
1426
                        if (job_class_environment_set (envvar, replace) < 0) {
 
1427
                                nih_return_no_memory_error (-1);
 
1428
                        }
 
1429
                        if (job_name == NULL && user_mode && control_bus ) {
 
1430
                                ControlDbusUpdateActivationEnvironmentVarsElement **dbus_vars = NULL;
 
1431
                                NihDBusProxy *dbus_proxy = NULL;
 
1432
                                char ** split_vars = NULL;
 
1433
                                dbus_vars = NIH_MUST (nih_alloc (NULL, sizeof (ControlDbusUpdateActivationEnvironmentVarsElement *) * 2));
 
1434
                                dbus_vars[0] = NIH_MUST (nih_new (dbus_vars, ControlDbusUpdateActivationEnvironmentVarsElement));
 
1435
                                dbus_vars[1] = NULL;
 
1436
                                split_vars = NIH_MUST (nih_str_split (dbus_vars[0], envvar, "=", FALSE));
 
1437
                                if (*split_vars && *split_vars[0]) {
 
1438
                                        dbus_vars[0]->item0 = *split_vars;
 
1439
                                } else {
 
1440
                                        dbus_vars[0]->item0 = nih_strdup (dbus_vars[0], "");
 
1441
                                }
 
1442
                                if (*(split_vars+1) && *(split_vars+1)[0]) {
 
1443
                                        dbus_vars[0]->item1 = *(split_vars+1);
 
1444
                                } else {
 
1445
                                        dbus_vars[0]->item1 = nih_strdup (dbus_vars[0], "");
 
1446
                                }
 
1447
 
 
1448
                                dbus_proxy = NIH_SHOULD (nih_dbus_proxy_new (dbus_vars, control_bus, "org.freedesktop.DBus", "/", NULL, NULL));
 
1449
                                if (! dbus_proxy) {
 
1450
                                        nih_warn (_("Failed to get dbus_proxy"));
 
1451
                                } else {
 
1452
                                        if (control_dbus_update_activation_environment_sync (dbus_vars, dbus_proxy, dbus_vars) != 0) {
 
1453
                                                NihDBusError *dbus_err;
 
1454
                                                dbus_err = (NihDBusError *)nih_error_get ();
 
1455
                                                nih_error ("%s", dbus_err->message);
 
1456
                                                nih_free (dbus_err);
 
1457
                                                nih_warn ("dbus_vars[0] item0: %s", dbus_vars[0]->item0);
 
1458
                                                nih_warn ("dbus_vars[0] item1: %s", dbus_vars[0]->item1);
 
1459
                                                nih_warn (_("Failed to update DBus activation environment"));
 
1460
                                        }
 
1461
                                }
 
1462
                                nih_free(dbus_vars);
 
1463
                        }
1426
1464
                }
1427
1465
        }
1428
1466