~upstart-devel/upstart/trunk

« back to all changes in this revision

Viewing changes to init/control.c

  • Committer: Dimitri John Ledkov
  • Date: 2015-05-16 19:12:37 UTC
  • mto: This revision was merged to the branch mainline in revision 1667.
  • Revision ID: dimitri.j.ledkov@intel.com-20150516191237-tenab3vi3qygy21v
Handle empty assignments correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1427
1427
                                nih_return_no_memory_error (-1);
1428
1428
                        }
1429
1429
                        if (job_name == NULL && user_mode && control_bus ) {
1430
 
                                ControlDbusUpdateActivationEnvironmentVarsElement **dbus_vars = NULL;                           
 
1430
                                ControlDbusUpdateActivationEnvironmentVarsElement **dbus_vars = NULL;
1431
1431
                                NihDBusProxy *dbus_proxy = NULL;
1432
1432
                                char ** split_vars = NULL;
1433
1433
                                dbus_vars = NIH_MUST (nih_alloc (NULL, sizeof (ControlDbusUpdateActivationEnvironmentVarsElement *) * 2));
1434
 
                                dbus_vars[0] = NIH_MUST (nih_new (dbus_vars, ControlDbusUpdateActivationEnvironmentVarsElement));                               
 
1434
                                dbus_vars[0] = NIH_MUST (nih_new (dbus_vars, ControlDbusUpdateActivationEnvironmentVarsElement));
1435
1435
                                dbus_vars[1] = NULL;
1436
1436
                                split_vars = NIH_MUST (nih_str_split (dbus_vars[0], envvar, "=", FALSE));
1437
 
                                dbus_vars[0]->item0 = *split_vars;
1438
 
                                dbus_vars[0]->item1 = *(split_vars+1);
 
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
                                }
1439
1447
 
1440
1448
                                dbus_proxy = NIH_SHOULD (nih_dbus_proxy_new (dbus_vars, control_bus, "org.freedesktop.DBus", "/", NULL, NULL));
1441
1449
                                if (! dbus_proxy) {
1442
1450
                                        nih_warn (_("Failed to get dbus_proxy"));
1443
1451
                                } else {
1444
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);
1445
1459
                                                nih_warn (_("Failed to update DBus activation environment"));
1446
1460
                                        }
1447
1461
                                }
1448
1462
                                nih_free(dbus_vars);
1449
1463
                        }
1450
 
                }               
 
1464
                }
1451
1465
        }
1452
1466
 
1453
1467
        return 0;