Merge lp:~xnox/upstart/lp1433013 into lp:upstart

Proposed by Dimitri John Ledkov on 2015-05-16
Status: Merged
Merged at revision: 1667
Proposed branch: lp:~xnox/upstart/lp1433013
Merge into: lp:upstart
Diff against target: 255 lines (+83/-2)
4 files modified
dbus/Makefile.am (+1/-0)
dbus/org.freedesktop.DBus.xml (+9/-0)
init/Makefile.am (+33/-0)
init/control.c (+40/-2)
To merge this branch: bzr merge lp:~xnox/upstart/lp1433013
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) (community) Approve on 2016-04-28
Upstart Reviewers 2015-05-16 Pending
Review via email: mp+259317@code.launchpad.net

Description of the change

This resolves the nasty https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/1433013

To test in Unity, check that environment variables are sane in the terminal started from the left launcher, application lense, and Alt-F2.

In principle, variables that are set with initctl set-env --global should propagate to the DBus activation environment and hence to processes that are dbus activated there after - i.e. all the unity shell components.

To post a comment you must log in.
Marco Trevisan (Treviño) (3v1n0) wrote :

Hey, any news on this?

Marco Trevisan (Treviño) (3v1n0) wrote :

It looks to fix at least one issue with GTK_MODULES not being properly set for dbus activation runner when loading unity-gtk-module.conf, so it's nice for me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dbus/Makefile.am'
2--- dbus/Makefile.am 2009-07-02 17:31:25 +0000
3+++ dbus/Makefile.am 2015-05-16 19:16:03 +0000
4@@ -7,6 +7,7 @@
5
6 EXTRA_DIST = \
7 upstart.h \
8+ org.freedesktop.DBus.xml \
9 com.ubuntu.Upstart.xml \
10 com.ubuntu.Upstart.Job.xml \
11 com.ubuntu.Upstart.Instance.xml
12
13=== added file 'dbus/org.freedesktop.DBus.xml'
14--- dbus/org.freedesktop.DBus.xml 1970-01-01 00:00:00 +0000
15+++ dbus/org.freedesktop.DBus.xml 2015-05-16 19:16:03 +0000
16@@ -0,0 +1,9 @@
17+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
18+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
19+<node>
20+ <interface name="org.freedesktop.DBus">
21+ <method name="UpdateActivationEnvironment">
22+ <arg name="vars" direction="in" type="a{ss}"/>
23+ </method>
24+ </interface>
25+</node>
26
27=== modified file 'init/Makefile.am'
28--- init/Makefile.am 2014-07-11 19:18:09 +0000
29+++ init/Makefile.am 2015-05-16 19:16:03 +0000
30@@ -64,6 +64,7 @@
31 errors.h \
32 apparmor.c apparmor.h
33 nodist_init_SOURCES = \
34+ $(org_freedesktop_DBus_OUTPUTS) \
35 $(com_ubuntu_Upstart_OUTPUTS) \
36 $(com_ubuntu_Upstart_Job_OUTPUTS) \
37 $(com_ubuntu_Upstart_Instance_OUTPUTS)
38@@ -125,14 +126,30 @@
39 --default-interface=com.ubuntu.Upstart0_6.Instance \
40 --output=$@ $<
41
42+org_freedesktop_DBus_OUTPUTS = \
43+ org.freedesktop.DBus.c \
44+ org.freedesktop.DBus.h
45+
46+org_freedesktop_DBus_XML = \
47+ ../dbus/org.freedesktop.DBus.xml
48+
49+$(org_freedesktop_DBus_OUTPUTS): $(org_freedesktop_DBus_XML)
50+ $(AM_V_GEN)$(NIH_DBUS_TOOL) \
51+ --package=$(PACKAGE) \
52+ --mode=proxy --prefix=control_dbus \
53+ --default-interface=org.freedesktop.DBus \
54+ --output=$@ $<
55+
56 # These have to be built sources because we can't compile object files
57 # without the header file existing first
58 BUILT_SOURCES = \
59+ $(org_freedesktop_DBus_OUTPUTS) \
60 $(com_ubuntu_Upstart_OUTPUTS) \
61 $(com_ubuntu_Upstart_Job_OUTPUTS) \
62 $(com_ubuntu_Upstart_Instance_OUTPUTS)
63
64 CLEANFILES = \
65+ $(org_freedesktop_DBus_OUTPUTS) \
66 $(com_ubuntu_Upstart_OUTPUTS) \
67 $(com_ubuntu_Upstart_Job_OUTPUTS) \
68 $(com_ubuntu_Upstart_Instance_OUTPUTS)
69@@ -231,6 +248,7 @@
70 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
71 parse_job.o parse_conf.o conf.o control.o quiesce.o \
72 session.o log.o state.o xdg.o apparmor.o \
73+ org.freedesktop.DBus.o \
74 com.ubuntu.Upstart.o \
75 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
76 $(top_builddir)/test/libtest_util_common.a \
77@@ -249,6 +267,7 @@
78 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
79 parse_job.o parse_conf.o conf.o control.o quiesce.o \
80 session.o log.o state.o xdg.o apparmor.o \
81+ org.freedesktop.DBus.o \
82 com.ubuntu.Upstart.o \
83 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
84 $(NIH_LIBS) \
85@@ -266,6 +285,7 @@
86 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
87 parse_job.o parse_conf.o conf.o control.o quiesce.o \
88 session.o log.o state.o xdg.o apparmor.o \
89+ org.freedesktop.DBus.o \
90 com.ubuntu.Upstart.o \
91 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
92 $(top_builddir)/test/libtest_util_common.a \
93@@ -284,6 +304,7 @@
94 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
95 parse_job.o parse_conf.o conf.o control.o quiesce.o \
96 session.o log.o state.o xdg.o apparmor.o \
97+ org.freedesktop.DBus.o \
98 com.ubuntu.Upstart.o \
99 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
100 $(top_builddir)/test/libtest_util_common.a \
101@@ -302,6 +323,7 @@
102 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
103 parse_job.o parse_conf.o conf.o control.o quiesce.o \
104 session.o log.o state.o xdg.o apparmor.o \
105+ org.freedesktop.DBus.o \
106 com.ubuntu.Upstart.o \
107 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
108 $(top_builddir)/test/libtest_util_common.a \
109@@ -320,6 +342,7 @@
110 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
111 parse_job.o parse_conf.o conf.o control.o quiesce.o \
112 session.o log.o state.o xdg.o apparmor.o \
113+ org.freedesktop.DBus.o \
114 com.ubuntu.Upstart.o \
115 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
116 $(top_builddir)/test/libtest_util_common.a \
117@@ -338,6 +361,7 @@
118 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
119 parse_job.o parse_conf.o conf.o control.o quiesce.o \
120 session.o log.o state.o xdg.o apparmor.o \
121+ org.freedesktop.DBus.o \
122 com.ubuntu.Upstart.o \
123 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
124 $(NIH_LIBS) \
125@@ -355,6 +379,7 @@
126 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
127 parse_job.o parse_conf.o conf.o control.o quiesce.o \
128 session.o log.o state.o xdg.o apparmor.o \
129+ org.freedesktop.DBus.o \
130 com.ubuntu.Upstart.o \
131 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
132 $(top_builddir)/test/libtest_util_common.a \
133@@ -373,6 +398,7 @@
134 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
135 parse_job.o parse_conf.o conf.o control.o quiesce.o \
136 session.o log.o state.o xdg.o apparmor.o \
137+ org.freedesktop.DBus.o \
138 com.ubuntu.Upstart.o \
139 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
140 $(NIH_LIBS) \
141@@ -390,6 +416,7 @@
142 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
143 parse_job.o parse_conf.o conf.o control.o quiesce.o \
144 session.o log.o state.o xdg.o apparmor.o \
145+ org.freedesktop.DBus.o \
146 com.ubuntu.Upstart.o \
147 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
148 $(top_builddir)/test/libtest_util_common.a \
149@@ -408,6 +435,7 @@
150 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
151 parse_job.o parse_conf.o conf.o control.o quiesce.o \
152 session.o log.o state.o xdg.o apparmor.o \
153+ org.freedesktop.DBus.o \
154 com.ubuntu.Upstart.o \
155 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
156 $(NIH_LIBS) \
157@@ -430,6 +458,7 @@
158 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
159 parse_job.o parse_conf.o conf.o control.o quiesce.o \
160 session.o log.o state.o xdg.o apparmor.o \
161+ org.freedesktop.DBus.o \
162 com.ubuntu.Upstart.o \
163 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
164 $(top_builddir)/test/libtest_util_common.a \
165@@ -448,6 +477,7 @@
166 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
167 parse_job.o parse_conf.o control.o quiesce.o \
168 session.o log.o state.o xdg.o apparmor.o \
169+ org.freedesktop.DBus.o \
170 com.ubuntu.Upstart.o \
171 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
172 $(NIH_LIBS) \
173@@ -479,6 +509,7 @@
174 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
175 parse_job.o parse_conf.o conf.o control.o quiesce.o \
176 session.o log.o state.o xdg.o apparmor.o cgroup.o \
177+ org.freedesktop.DBus.o \
178 com.ubuntu.Upstart.o \
179 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
180 $(top_builddir)/test/libtest_util_common.a \
181@@ -495,6 +526,7 @@
182 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
183 parse_job.o parse_conf.o conf.o control.o quiesce.o \
184 session.o log.o state.o xdg.o apparmor.o \
185+ org.freedesktop.DBus.o \
186 com.ubuntu.Upstart.o \
187 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
188 $(NIH_LIBS) \
189@@ -512,6 +544,7 @@
190 job_class.o job_process.o job.o event.o event_operator.o blocked.o \
191 parse_job.o parse_conf.o conf.o control.o quiesce.o \
192 session.o log.o state.o xdg.o apparmor.o \
193+ org.freedesktop.DBus.o \
194 com.ubuntu.Upstart.o \
195 com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
196 $(top_builddir)/test/libtest_util_common.a \
197
198=== modified file 'init/control.c'
199--- init/control.c 2014-08-14 11:19:43 +0000
200+++ init/control.c 2015-05-16 19:16:03 +0000
201@@ -62,6 +62,7 @@
202 #include "xdg.h"
203
204 #include "com.ubuntu.Upstart.h"
205+#include "org.freedesktop.DBus.h"
206
207 #ifdef ENABLE_CGROUPS
208 #include "cgroup.h"
209@@ -1421,8 +1422,45 @@
210 nih_assert (job->env);
211
212 NIH_MUST (environ_add (&job->env, job, NULL, replace, envvar));
213- } else if (job_class_environment_set (envvar, replace) < 0) {
214- nih_return_no_memory_error (-1);
215+ } else {
216+ if (job_class_environment_set (envvar, replace) < 0) {
217+ nih_return_no_memory_error (-1);
218+ }
219+ if (job_name == NULL && user_mode && control_bus ) {
220+ ControlDbusUpdateActivationEnvironmentVarsElement **dbus_vars = NULL;
221+ NihDBusProxy *dbus_proxy = NULL;
222+ char ** split_vars = NULL;
223+ dbus_vars = NIH_MUST (nih_alloc (NULL, sizeof (ControlDbusUpdateActivationEnvironmentVarsElement *) * 2));
224+ dbus_vars[0] = NIH_MUST (nih_new (dbus_vars, ControlDbusUpdateActivationEnvironmentVarsElement));
225+ dbus_vars[1] = NULL;
226+ split_vars = NIH_MUST (nih_str_split (dbus_vars[0], envvar, "=", FALSE));
227+ if (*split_vars && *split_vars[0]) {
228+ dbus_vars[0]->item0 = *split_vars;
229+ } else {
230+ dbus_vars[0]->item0 = nih_strdup (dbus_vars[0], "");
231+ }
232+ if (*(split_vars+1) && *(split_vars+1)[0]) {
233+ dbus_vars[0]->item1 = *(split_vars+1);
234+ } else {
235+ dbus_vars[0]->item1 = nih_strdup (dbus_vars[0], "");
236+ }
237+
238+ dbus_proxy = NIH_SHOULD (nih_dbus_proxy_new (dbus_vars, control_bus, "org.freedesktop.DBus", "/", NULL, NULL));
239+ if (! dbus_proxy) {
240+ nih_warn (_("Failed to get dbus_proxy"));
241+ } else {
242+ if (control_dbus_update_activation_environment_sync (dbus_vars, dbus_proxy, dbus_vars) != 0) {
243+ NihDBusError *dbus_err;
244+ dbus_err = (NihDBusError *)nih_error_get ();
245+ nih_error ("%s", dbus_err->message);
246+ nih_free (dbus_err);
247+ nih_warn ("dbus_vars[0] item0: %s", dbus_vars[0]->item0);
248+ nih_warn ("dbus_vars[0] item1: %s", dbus_vars[0]->item1);
249+ nih_warn (_("Failed to update DBus activation environment"));
250+ }
251+ }
252+ nih_free(dbus_vars);
253+ }
254 }
255 }
256

Subscribers

People subscribed via source and target branches