Merge lp:~ted/ubuntu-app-launch/install-root into lp:ubuntu-app-launch
- install-root
- Merge into trunk.17.04
Status: | Merged |
---|---|
Approved by: | Ted Gould |
Approved revision: | 328 |
Merged at revision: | 282 |
Proposed branch: | lp:~ted/ubuntu-app-launch/install-root |
Merge into: | lp:ubuntu-app-launch |
Prerequisite: | lp:~ted/ubuntu-app-launch/jobs-systemd |
Diff against target: |
869 lines (+598/-20) 21 files modified
CMakeLists.txt (+25/-0) debian/ubuntu-app-launch.install (+1/-0) docs/index.rst (+50/-0) libubuntu-app-launch/application-impl-legacy.cpp (+23/-8) libubuntu-app-launch/application-impl-snap.cpp (+3/-1) libubuntu-app-launch/jobs-systemd.cpp (+48/-3) libubuntu-app-launch/registry-impl.cpp (+11/-0) libubuntu-app-launch/registry-impl.h (+8/-0) libubuntu-app-launch/ubuntu-app-launch.cpp (+5/-1) snappy-xmir-envvars.c (+112/-0) snappy-xmir.c (+212/-0) tests/CMakeLists.txt (+5/-0) tests/snappy-xmir-test-check.sh (+32/-0) tests/snappy-xmir-test-helper-long.sh (+12/-0) tests/snappy-xmir-test-helper.sh (+12/-0) tests/snappy-xmir-test-libertine-launch.sh (+5/-0) tests/snappy-xmir-test.sh.in (+30/-0) upstart-jobs/application-click.conf.in (+0/-1) upstart-jobs/application-snap.conf.in (+0/-1) upstart-jobs/untrusted-helper.conf.in (+0/-1) xmir-helper.c (+4/-4) |
To merge this branch: | bzr merge lp:~ted/ubuntu-app-launch/install-root |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Approve | ||
unity-api-1-bot | continuous-integration | Needs Fixing | |
dobey | Pending | ||
Ted Gould | Pending | ||
Marcus Tomlinson | Pending | ||
Review via email: mp+316036@code.launchpad.net |
Commit message
Adjust UAL for working inside a snap
Description of the change
This branch is various changes that make it so that UAL works well inside the Unity8 Session Snap.
The majority of the changes are basically adjustments to the environment variables and other tweaks to the various calls to look for the SNAP environment variable and change how UAL behaves in those cases. There are also some cases where variables have been removed as they were determined to not be needed when testing in the unity8-session snap.
A bigger change that exists in this branch is the addition of the snappy helpers for setting up xmir. This works a little bit different in that it gives a small utility to the XMir setup functions that then sends the environment over a socket to the helper. This allows us to go in and out of the snap confinement for X11. These utilities are written in conservative low-level C to ensure they'll work on ubuntu-core with a minimal set of libraries.
Ted Gould (ted) wrote : | # |
Ted Gould (ted) wrote : | # |
Resubmitted this with a better description of what the branch actually does today.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:316
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Charles Kerr (charlesk) wrote : | # |
Mostly looks good. A handful of little tweaks + one more serious issue w/easy fix. Comments inline.
Ted Gould (ted) : | # |
- 317. By Ted Gould
-
Fix docs to include default path for LEGACY_EXEC
- 318. By Ted Gould
-
Cache snap env var
- 319. By Ted Gould
-
Make sure we only use references in loops
- 320. By Ted Gould
-
Don't store if we have the variable
- 321. By Ted Gould
-
Return const pointer
- 322. By Ted Gould
-
Handle larger possible pids
- 323. By Ted Gould
-
Make sure we're gettin' data
- 324. By Ted Gould
-
Move debug outside of the print loop
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:324
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:325
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Charles Kerr (charlesk) wrote : | # |
Approving these changes, feel free to top-approve when Jenkins is happy or if the Jenkins failure is a red herring
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2017-01-23 21:32:16 +0000 | |||
3 | +++ CMakeLists.txt 2017-02-02 15:08:16 +0000 | |||
4 | @@ -111,6 +111,7 @@ | |||
5 | 111 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") | 111 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") |
6 | 112 | 112 | ||
7 | 113 | add_definitions( -DXMIR_HELPER="${pkglibexecdir}/xmir-helper" ) | 113 | add_definitions( -DXMIR_HELPER="${pkglibexecdir}/xmir-helper" ) |
8 | 114 | add_definitions( -DSNAPPY_XMIR="${CMAKE_INSTALL_FULL_BINDIR}/snappy-xmir" ) | ||
9 | 114 | 115 | ||
10 | 115 | #################### | 116 | #################### |
11 | 116 | # Helpers | 117 | # Helpers |
12 | @@ -210,6 +211,30 @@ | |||
13 | 210 | install(TARGETS socket-demangler-helper RUNTIME DESTINATION "${pkglibexecdir}") | 211 | install(TARGETS socket-demangler-helper RUNTIME DESTINATION "${pkglibexecdir}") |
14 | 211 | 212 | ||
15 | 212 | #################### | 213 | #################### |
16 | 214 | # snappy-xmir | ||
17 | 215 | #################### | ||
18 | 216 | |||
19 | 217 | #################### | ||
20 | 218 | # NOTE: This only can link to libraries that are in | ||
21 | 219 | # the base UBUNTU CORE image. Which is basically libc | ||
22 | 220 | # and not much else. Don't add libs. | ||
23 | 221 | #################### | ||
24 | 222 | |||
25 | 223 | add_executable(snappy-xmir snappy-xmir.c) | ||
26 | 224 | set_target_properties(snappy-xmir PROPERTIES OUTPUT_NAME "snappy-xmir") | ||
27 | 225 | install(TARGETS snappy-xmir RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") | ||
28 | 226 | |||
29 | 227 | #################### | ||
30 | 228 | # snappy-xmir-envvars | ||
31 | 229 | #################### | ||
32 | 230 | |||
33 | 231 | add_executable(snappy-xmir-envvars snappy-xmir-envvars.c) | ||
34 | 232 | set_target_properties(snappy-xmir-envvars PROPERTIES OUTPUT_NAME "snappy-xmir-envvars") | ||
35 | 233 | # No libs, otherwise we have to worry about how to handle finding them | ||
36 | 234 | install(TARGETS snappy-xmir-envvars RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") | ||
37 | 235 | |||
38 | 236 | |||
39 | 237 | #################### | ||
40 | 213 | # ubuntu-app-launch-desktop.click-hook | 238 | # ubuntu-app-launch-desktop.click-hook |
41 | 214 | #################### | 239 | #################### |
42 | 215 | 240 | ||
43 | 216 | 241 | ||
44 | === modified file 'debian/ubuntu-app-launch.install' | |||
45 | --- debian/ubuntu-app-launch.install 2014-04-30 15:14:26 +0000 | |||
46 | +++ debian/ubuntu-app-launch.install 2017-02-02 15:08:16 +0000 | |||
47 | @@ -1,2 +1,3 @@ | |||
48 | 1 | usr/share/upstart/sessions/* | 1 | usr/share/upstart/sessions/* |
49 | 2 | usr/lib/*/ubuntu-app-launch/* | 2 | usr/lib/*/ubuntu-app-launch/* |
50 | 3 | usr/bin/snappy-xmir* | ||
51 | 3 | 4 | ||
52 | === modified file 'docs/index.rst' | |||
53 | --- docs/index.rst 2016-09-30 20:46:07 +0000 | |||
54 | +++ docs/index.rst 2017-02-02 15:08:16 +0000 | |||
55 | @@ -18,6 +18,56 @@ | |||
56 | 18 | 18 | ||
57 | 19 | .. _Upstart: http://upstart.ubuntu.com/ | 19 | .. _Upstart: http://upstart.ubuntu.com/ |
58 | 20 | 20 | ||
59 | 21 | |||
60 | 22 | Environment Variables | ||
61 | 23 | ===================== | ||
62 | 24 | |||
63 | 25 | There are a few environment variables that can effect the behavior of UAL while | ||
64 | 26 | it is running. | ||
65 | 27 | |||
66 | 28 | UBUNTU_APP_LAUNCH_CG_MANAGER_NAME | ||
67 | 29 | The DBus name that CG Manager registers under if it is on the session bus. | ||
68 | 30 | |||
69 | 31 | UBUNTU_APP_LAUNCH_CG_MANAGER_SESSION_BUS | ||
70 | 32 | Tell UAL to look on the session bus for CG Manager. | ||
71 | 33 | |||
72 | 34 | UBUNTU_APP_LAUNCH_DEMANGLER | ||
73 | 35 | Path to the UAL demangler tool that will get the Mir FD for trusted prompt session. | ||
74 | 36 | |||
75 | 37 | UBUNTU_APP_LAUNCH_DISABLE_SNAPD_TIMEOUT | ||
76 | 38 | Wait as long as Snapd wants to return data instead of erroring after 100ms. | ||
77 | 39 | |||
78 | 40 | UBUNTU_APP_LAUNCH_LEGACY_ROOT | ||
79 | 41 | Set the path that represents the root for legacy applications. | ||
80 | 42 | |||
81 | 43 | UBUNTU_APP_LAUNCH_LIBERTINE_LAUNCH | ||
82 | 44 | Path to the libertine launch utility for setting up libertine containers and XMir based legacy apps. | ||
83 | 45 | |||
84 | 46 | UBUNTU_APP_LAUNCH_LINK_FARM | ||
85 | 47 | Path to the link farm that is created by Click of all the installed Click applications. | ||
86 | 48 | |||
87 | 49 | UBUNTU_APP_LAUNCH_OOM_HELPER | ||
88 | 50 | Path to the setuid helper that configures OOM values on application processes that we otherwise couldn't, mostly this is for Oxide. | ||
89 | 51 | |||
90 | 52 | UBUNTU_APP_LAUNCH_OOM_PROC_PATH | ||
91 | 53 | Path to look for the files to set OOM values, defaults to `/proc`. | ||
92 | 54 | |||
93 | 55 | UBUNTU_APP_LAUNCH_SNAP_BASEDIR | ||
94 | 56 | The place where snaps are installed in the system, `/snap` is the default. | ||
95 | 57 | |||
96 | 58 | UBUNTU_APP_LAUNCH_SNAP_LEGACY_EXEC | ||
97 | 59 | A snappy command that is used to launch legacy applications in the current snap, to ensure the environment gets configured correctly, defaults to `/snap/bin/unity8-session.legacy-exec` | ||
98 | 60 | |||
99 | 61 | UBUNTU_APP_LAUNCH_SNAPD_SOCKET | ||
100 | 62 | Path to the snapd socket. | ||
101 | 63 | |||
102 | 64 | UBUNTU_APP_LAUNCH_XMIR_HELPER | ||
103 | 65 | Tool that helps to start XMir and sets the DISPLAY variable for applications | ||
104 | 66 | |||
105 | 67 | UBUNTU_APP_LAUNCH_XMIR_PATH | ||
106 | 68 | Specifies the location of the XMir binary to use | ||
107 | 69 | |||
108 | 70 | |||
109 | 21 | API Documentation | 71 | API Documentation |
110 | 22 | ================= | 72 | ================= |
111 | 23 | 73 | ||
112 | 24 | 74 | ||
113 | === modified file 'libubuntu-app-launch/application-impl-legacy.cpp' | |||
114 | --- libubuntu-app-launch/application-impl-legacy.cpp 2017-02-02 15:08:16 +0000 | |||
115 | +++ libubuntu-app-launch/application-impl-legacy.cpp 2017-02-02 15:08:16 +0000 | |||
116 | @@ -299,7 +299,25 @@ | |||
117 | 299 | info(); | 299 | info(); |
118 | 300 | 300 | ||
119 | 301 | retval.emplace_back(std::make_pair("APP_XMIR_ENABLE", appinfo_->xMirEnable().value() ? "1" : "0")); | 301 | retval.emplace_back(std::make_pair("APP_XMIR_ENABLE", appinfo_->xMirEnable().value() ? "1" : "0")); |
121 | 302 | if (appinfo_->xMirEnable()) | 302 | auto execline = appinfo_->execLine().value(); |
122 | 303 | |||
123 | 304 | auto snappath = getenv("SNAP"); | ||
124 | 305 | if (snappath != nullptr) | ||
125 | 306 | { | ||
126 | 307 | /* This means we're inside a snap, and if we're in a snap then | ||
127 | 308 | the legacy application is in a snap. We need to try and set | ||
128 | 309 | up the proper environment for that app */ | ||
129 | 310 | retval.emplace_back(std::make_pair("SNAP", snappath)); | ||
130 | 311 | |||
131 | 312 | const char* legacyexec = getenv("UBUNTU_APP_LAUNCH_SNAP_LEGACY_EXEC"); | ||
132 | 313 | if (legacyexec == nullptr) | ||
133 | 314 | { | ||
134 | 315 | legacyexec = "/snap/bin/unity8-session.legacy-exec"; | ||
135 | 316 | } | ||
136 | 317 | |||
137 | 318 | execline = std::string{legacyexec} + " " + execline; | ||
138 | 319 | } | ||
139 | 320 | else if (appinfo_->xMirEnable().value()) | ||
140 | 303 | { | 321 | { |
141 | 304 | /* If we're setting up XMir we also need the other helpers | 322 | /* If we're setting up XMir we also need the other helpers |
142 | 305 | that libertine is helping with */ | 323 | that libertine is helping with */ |
143 | @@ -309,13 +327,10 @@ | |||
144 | 309 | libertine_launch = LIBERTINE_LAUNCH; | 327 | libertine_launch = LIBERTINE_LAUNCH; |
145 | 310 | } | 328 | } |
146 | 311 | 329 | ||
154 | 312 | retval.emplace_back( | 330 | execline = std::string{libertine_launch} + " " + execline; |
155 | 313 | std::make_pair("APP_EXEC", std::string(libertine_launch) + " " + appinfo_->execLine().value())); | 331 | } |
156 | 314 | } | 332 | |
157 | 315 | else | 333 | retval.emplace_back(std::make_pair("APP_EXEC", execline)); |
151 | 316 | { | ||
152 | 317 | retval.emplace_back(std::make_pair("APP_EXEC", appinfo_->execLine().value())); | ||
153 | 318 | } | ||
158 | 319 | 334 | ||
159 | 320 | /* Honor the 'Path' key if it is in the desktop file */ | 335 | /* Honor the 'Path' key if it is in the desktop file */ |
160 | 321 | if (g_key_file_has_key(_keyfile.get(), "Desktop Entry", "Path", nullptr)) | 336 | if (g_key_file_has_key(_keyfile.get(), "Desktop Entry", "Path", nullptr)) |
161 | 322 | 337 | ||
162 | === modified file 'libubuntu-app-launch/application-impl-snap.cpp' | |||
163 | --- libubuntu-app-launch/application-impl-snap.cpp 2017-02-02 15:08:16 +0000 | |||
164 | +++ libubuntu-app-launch/application-impl-snap.cpp 2017-02-02 15:08:16 +0000 | |||
165 | @@ -441,7 +441,7 @@ | |||
166 | 441 | std::list<std::pair<std::string, std::string>> retval; | 441 | std::list<std::pair<std::string, std::string>> retval; |
167 | 442 | 442 | ||
168 | 443 | retval.emplace_back(std::make_pair("APP_XMIR_ENABLE", info_->xMirEnable().value() ? "1" : "0")); | 443 | retval.emplace_back(std::make_pair("APP_XMIR_ENABLE", info_->xMirEnable().value() ? "1" : "0")); |
170 | 444 | if (info_->xMirEnable()) | 444 | if (info_->xMirEnable() && getenv("SNAP") == nullptr) |
171 | 445 | { | 445 | { |
172 | 446 | /* If we're setting up XMir we also need the other helpers | 446 | /* If we're setting up XMir we also need the other helpers |
173 | 447 | that libertine is helping with */ | 447 | that libertine is helping with */ |
174 | @@ -456,6 +456,8 @@ | |||
175 | 456 | } | 456 | } |
176 | 457 | else | 457 | else |
177 | 458 | { | 458 | { |
178 | 459 | /* If we're in a snap the libertine helpers are setup by | ||
179 | 460 | the snap stuff */ | ||
180 | 459 | retval.emplace_back(std::make_pair("APP_EXEC", info_->execLine().value())); | 461 | retval.emplace_back(std::make_pair("APP_EXEC", info_->execLine().value())); |
181 | 460 | } | 462 | } |
182 | 461 | 463 | ||
183 | 462 | 464 | ||
184 | === modified file 'libubuntu-app-launch/jobs-systemd.cpp' | |||
185 | --- libubuntu-app-launch/jobs-systemd.cpp 2017-02-02 15:08:16 +0000 | |||
186 | +++ libubuntu-app-launch/jobs-systemd.cpp 2017-02-02 15:08:16 +0000 | |||
187 | @@ -441,7 +441,28 @@ | |||
188 | 441 | if (findEnv("APP_XMIR_ENABLE", env) == "1" && getenv("DISPLAY") == nullptr) | 441 | if (findEnv("APP_XMIR_ENABLE", env) == "1" && getenv("DISPLAY") == nullptr) |
189 | 442 | { | 442 | { |
190 | 443 | retval.emplace(retval.begin(), findEnv("APP_ID", env)); | 443 | retval.emplace(retval.begin(), findEnv("APP_ID", env)); |
192 | 444 | retval.emplace(retval.begin(), XMIR_HELPER); | 444 | |
193 | 445 | auto snapenv = getenv("SNAP"); | ||
194 | 446 | if (snapenv == nullptr) | ||
195 | 447 | { | ||
196 | 448 | auto xmirenv = getenv("UBUNTU_APP_LAUNCH_XMIR_HELPER"); | ||
197 | 449 | if (xmirenv == nullptr) | ||
198 | 450 | { | ||
199 | 451 | retval.emplace(retval.begin(), XMIR_HELPER); | ||
200 | 452 | } | ||
201 | 453 | else | ||
202 | 454 | { | ||
203 | 455 | retval.emplace(retval.begin(), xmirenv); | ||
204 | 456 | } | ||
205 | 457 | } | ||
206 | 458 | else | ||
207 | 459 | { | ||
208 | 460 | /* If we're in a snap we need to use the utility which | ||
209 | 461 | gets us back into the snap */ | ||
210 | 462 | std::string snappath{snapenv}; | ||
211 | 463 | |||
212 | 464 | retval.emplace(retval.begin(), snappath + SNAPPY_XMIR); | ||
213 | 465 | } | ||
214 | 445 | } | 466 | } |
215 | 446 | 467 | ||
216 | 447 | /* See if we're doing apparmor by hand */ | 468 | /* See if we're doing apparmor by hand */ |
217 | @@ -588,11 +609,35 @@ | |||
218 | 588 | env.emplace_back(std::make_pair("APP_LAUNCHER_PID", std::to_string(getpid()))); /* Who we are, for bugs */ | 609 | env.emplace_back(std::make_pair("APP_LAUNCHER_PID", std::to_string(getpid()))); /* Who we are, for bugs */ |
219 | 589 | 610 | ||
220 | 590 | copyEnv("DISPLAY", env); | 611 | copyEnv("DISPLAY", env); |
222 | 591 | for (const auto prefix : {"DBUS_", "MIR_", "QT_", "UBUNTU_", "UNITY_", "XDG_"}) | 612 | |
223 | 613 | for (const auto& prefix : {"DBUS_", "MIR_", "UBUNTU_APP_LAUNCH_"}) | ||
224 | 592 | { | 614 | { |
225 | 593 | copyEnvByPrefix(prefix, env); | 615 | copyEnvByPrefix(prefix, env); |
226 | 594 | } | 616 | } |
227 | 595 | 617 | ||
228 | 618 | /* If we're in deb mode and launching legacy apps, they're gonna need | ||
229 | 619 | * more context, they really have no other way to get it. */ | ||
230 | 620 | if (g_getenv("SNAP") == nullptr && appId.package.value().empty()) | ||
231 | 621 | { | ||
232 | 622 | copyEnvByPrefix("QT_", env); | ||
233 | 623 | copyEnvByPrefix("XDG_", env); | ||
234 | 624 | copyEnv("UBUNTU_APP_LAUNCH_XMIR_PATH", env); | ||
235 | 625 | |||
236 | 626 | /* If we're in Unity8 we don't want to pass it's platform, we want | ||
237 | 627 | * an application platform. */ | ||
238 | 628 | if (findEnv("QT_QPA_PLATFORM", env) == "mirserver") | ||
239 | 629 | { | ||
240 | 630 | removeEnv("QT_QPA_PLATFORM", env); | ||
241 | 631 | env.emplace_back(std::make_pair("QT_QPA_PLATFORM", "ubuntumirclient")); | ||
242 | 632 | } | ||
243 | 633 | } | ||
244 | 634 | |||
245 | 635 | /* Mir socket if we don't have one in our env */ | ||
246 | 636 | if (findEnv("MIR_SOCKET", env).empty()) | ||
247 | 637 | { | ||
248 | 638 | env.emplace_back(std::make_pair("MIR_SOCKET", g_get_user_runtime_dir() + std::string{"/mir_socket"})); | ||
249 | 639 | } | ||
250 | 640 | |||
251 | 596 | if (!urls.empty()) | 641 | if (!urls.empty()) |
252 | 597 | { | 642 | { |
253 | 598 | auto accumfunc = [](const std::string& prev, Application::URL thisurl) -> std::string { | 643 | auto accumfunc = [](const std::string& prev, Application::URL thisurl) -> std::string { |
254 | @@ -702,7 +747,7 @@ | |||
255 | 702 | } | 747 | } |
256 | 703 | 748 | ||
257 | 704 | /* Clean up env before shipping it */ | 749 | /* Clean up env before shipping it */ |
259 | 705 | for (const auto rmenv : | 750 | for (const auto& rmenv : |
260 | 706 | {"APP_XMIR_ENABLE", "APP_DIR", "APP_URIS", "APP_EXEC", "APP_EXEC_POLICY", "APP_LAUNCHER_PID", | 751 | {"APP_XMIR_ENABLE", "APP_DIR", "APP_URIS", "APP_EXEC", "APP_EXEC_POLICY", "APP_LAUNCHER_PID", |
261 | 707 | "INSTANCE_ID", "MIR_SERVER_PLATFORM_PATH", "MIR_SERVER_PROMPT_FILE", "MIR_SERVER_HOST_SOCKET", | 752 | "INSTANCE_ID", "MIR_SERVER_PLATFORM_PATH", "MIR_SERVER_PROMPT_FILE", "MIR_SERVER_HOST_SOCKET", |
262 | 708 | "UBUNTU_APP_LAUNCH_DEMANGLER", "UBUNTU_APP_LAUNCH_OOM_HELPER", "UBUNTU_APP_LAUNCH_LEGACY_ROOT", | 753 | "UBUNTU_APP_LAUNCH_DEMANGLER", "UBUNTU_APP_LAUNCH_OOM_HELPER", "UBUNTU_APP_LAUNCH_LEGACY_ROOT", |
263 | 709 | 754 | ||
264 | === modified file 'libubuntu-app-launch/registry-impl.cpp' | |||
265 | --- libubuntu-app-launch/registry-impl.cpp 2017-02-02 15:08:16 +0000 | |||
266 | +++ libubuntu-app-launch/registry-impl.cpp 2017-02-02 15:08:16 +0000 | |||
267 | @@ -48,6 +48,17 @@ | |||
268 | 48 | return std::shared_ptr<GDBusConnection>(g_bus_get_sync(G_BUS_TYPE_SESSION, cancel.get(), nullptr), | 48 | return std::shared_ptr<GDBusConnection>(g_bus_get_sync(G_BUS_TYPE_SESSION, cancel.get(), nullptr), |
269 | 49 | [](GDBusConnection* bus) { g_clear_object(&bus); }); | 49 | [](GDBusConnection* bus) { g_clear_object(&bus); }); |
270 | 50 | }); | 50 | }); |
271 | 51 | |||
272 | 52 | /* Determine where we're getting the helper from */ | ||
273 | 53 | auto goomHelper = g_getenv("UBUNTU_APP_LAUNCH_OOM_HELPER"); | ||
274 | 54 | if (goomHelper != nullptr) | ||
275 | 55 | { | ||
276 | 56 | oomHelper_ = goomHelper; | ||
277 | 57 | } | ||
278 | 58 | else | ||
279 | 59 | { | ||
280 | 60 | oomHelper_ = OOM_HELPER; | ||
281 | 61 | } | ||
282 | 51 | } | 62 | } |
283 | 52 | 63 | ||
284 | 53 | void Registry::Impl::initClick() | 64 | void Registry::Impl::initClick() |
285 | 54 | 65 | ||
286 | === modified file 'libubuntu-app-launch/registry-impl.h' | |||
287 | --- libubuntu-app-launch/registry-impl.h 2017-01-11 22:38:42 +0000 | |||
288 | +++ libubuntu-app-launch/registry-impl.h 2017-02-02 15:08:16 +0000 | |||
289 | @@ -84,6 +84,11 @@ | |||
290 | 84 | static void watchingAppStarting(bool rWatching); | 84 | static void watchingAppStarting(bool rWatching); |
291 | 85 | static bool isWatchingAppStarting(); | 85 | static bool isWatchingAppStarting(); |
292 | 86 | 86 | ||
293 | 87 | const std::string& oomHelper() const | ||
294 | 88 | { | ||
295 | 89 | return oomHelper_; | ||
296 | 90 | } | ||
297 | 91 | |||
298 | 87 | private: | 92 | private: |
299 | 88 | Registry* _registry; /**< The Registry that we're spawned from */ | 93 | Registry* _registry; /**< The Registry that we're spawned from */ |
300 | 89 | 94 | ||
301 | @@ -98,6 +103,9 @@ | |||
302 | 98 | /** All of our icon finders based on the path that they're looking | 103 | /** All of our icon finders based on the path that they're looking |
303 | 99 | into */ | 104 | into */ |
304 | 100 | std::unordered_map<std::string, std::shared_ptr<IconFinder>> _iconFinders; | 105 | std::unordered_map<std::string, std::shared_ptr<IconFinder>> _iconFinders; |
305 | 106 | |||
306 | 107 | /** Path to the OOM Helper */ | ||
307 | 108 | std::string oomHelper_; | ||
308 | 101 | }; | 109 | }; |
309 | 102 | 110 | ||
310 | 103 | } // namespace app_launch | 111 | } // namespace app_launch |
311 | 104 | 112 | ||
312 | === modified file 'libubuntu-app-launch/ubuntu-app-launch.cpp' | |||
313 | --- libubuntu-app-launch/ubuntu-app-launch.cpp 2017-01-23 22:43:47 +0000 | |||
314 | +++ libubuntu-app-launch/ubuntu-app-launch.cpp 2017-02-02 15:08:16 +0000 | |||
315 | @@ -1608,7 +1608,11 @@ | |||
316 | 1608 | /* The exec value */ | 1608 | /* The exec value */ |
317 | 1609 | gchar * envstr = NULL; | 1609 | gchar * envstr = NULL; |
318 | 1610 | if (demangler) { | 1610 | if (demangler) { |
320 | 1611 | envstr = g_strdup_printf("APP_EXEC=%s %s", DEMANGLER_PATH, execline); | 1611 | const gchar * demangler_path = g_getenv("UBUNTU_APP_LAUNCH_DEMANGLER"); |
321 | 1612 | if (demangler_path == nullptr) { | ||
322 | 1613 | demangler_path = DEMANGLER_PATH; | ||
323 | 1614 | } | ||
324 | 1615 | envstr = g_strdup_printf("APP_EXEC=%s %s", demangler_path, execline); | ||
325 | 1612 | } else { | 1616 | } else { |
326 | 1613 | envstr = g_strdup_printf("APP_EXEC=%s", execline); | 1617 | envstr = g_strdup_printf("APP_EXEC=%s", execline); |
327 | 1614 | } | 1618 | } |
328 | 1615 | 1619 | ||
329 | === added file 'snappy-xmir-envvars.c' | |||
330 | --- snappy-xmir-envvars.c 1970-01-01 00:00:00 +0000 | |||
331 | +++ snappy-xmir-envvars.c 2017-02-02 15:08:16 +0000 | |||
332 | @@ -0,0 +1,112 @@ | |||
333 | 1 | /* | ||
334 | 2 | * Copyright © 2016 Canonical Ltd. | ||
335 | 3 | * | ||
336 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
337 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
338 | 6 | * by the Free Software Foundation. | ||
339 | 7 | * | ||
340 | 8 | * This program is distributed in the hope that it will be useful, but | ||
341 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
342 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
343 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
344 | 12 | * | ||
345 | 13 | * You should have received a copy of the GNU General Public License along | ||
346 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
347 | 15 | * | ||
348 | 16 | * Authors: | ||
349 | 17 | * Ted Gould <ted.gould@canonical.com> | ||
350 | 18 | */ | ||
351 | 19 | |||
352 | 20 | #define _POSIX_C_SOURCE 200212L | ||
353 | 21 | |||
354 | 22 | #include <unistd.h> | ||
355 | 23 | #include <stdio.h> | ||
356 | 24 | #include <stdlib.h> | ||
357 | 25 | #include <sys/types.h> | ||
358 | 26 | #include <sys/socket.h> | ||
359 | 27 | #include <sys/un.h> | ||
360 | 28 | #include <sys/wait.h> | ||
361 | 29 | #include <signal.h> | ||
362 | 30 | #include <string.h> | ||
363 | 31 | |||
364 | 32 | void | ||
365 | 33 | copyenv (int fd, const char * envname, const char * envval) | ||
366 | 34 | { | ||
367 | 35 | if (envval == NULL) { | ||
368 | 36 | fprintf(stderr, "Unable to get environment variable '%s'\n", envname); | ||
369 | 37 | exit(EXIT_FAILURE); | ||
370 | 38 | } | ||
371 | 39 | |||
372 | 40 | int writesize; | ||
373 | 41 | |||
374 | 42 | writesize = write(fd, envname, strlen(envname) + 1); | ||
375 | 43 | |||
376 | 44 | if (writesize <= 0) { | ||
377 | 45 | fprintf(stderr, "Unable to write to socket '%s'\n", envname); | ||
378 | 46 | exit(EXIT_FAILURE); | ||
379 | 47 | } | ||
380 | 48 | |||
381 | 49 | writesize = write(fd, envval, strlen(envval) + 1); | ||
382 | 50 | |||
383 | 51 | if (writesize <= 0) { | ||
384 | 52 | fprintf(stderr, "Unable to write to socket '%s'\n", envval); | ||
385 | 53 | exit(EXIT_FAILURE); | ||
386 | 54 | } | ||
387 | 55 | |||
388 | 56 | if (getenv("G_MESSAGES_DEBUG") != NULL) | ||
389 | 57 | printf("Wrote envvar '%s=%s'\n", envname, envval); | ||
390 | 58 | } | ||
391 | 59 | |||
392 | 60 | void | ||
393 | 61 | termhandler (int sig) | ||
394 | 62 | { | ||
395 | 63 | exit(EXIT_SUCCESS); | ||
396 | 64 | } | ||
397 | 65 | |||
398 | 66 | int | ||
399 | 67 | main (int argc, char * argv[]) | ||
400 | 68 | { | ||
401 | 69 | /* Grab socket */ | ||
402 | 70 | if (argc != 2) { | ||
403 | 71 | fprintf(stderr, "Usage: %s <socket name>\n", argv[0]); | ||
404 | 72 | return(EXIT_FAILURE); | ||
405 | 73 | } | ||
406 | 74 | |||
407 | 75 | char * socketname = argv[1]; | ||
408 | 76 | |||
409 | 77 | int socketfd = socket(AF_UNIX, SOCK_STREAM, 0); | ||
410 | 78 | if (socketfd <= 0) { | ||
411 | 79 | fprintf(stderr, "%s: Unable to create socket\n", argv[0]); | ||
412 | 80 | return EXIT_FAILURE; | ||
413 | 81 | } | ||
414 | 82 | |||
415 | 83 | struct sockaddr_un socketaddr = {0}; | ||
416 | 84 | socketaddr.sun_family = AF_UNIX; | ||
417 | 85 | strncpy(socketaddr.sun_path, socketname, sizeof(socketaddr.sun_path) - 1); | ||
418 | 86 | socketaddr.sun_path[0] = 0; | ||
419 | 87 | |||
420 | 88 | if (connect(socketfd, (const struct sockaddr *)&socketaddr, sizeof(struct sockaddr_un)) < 0) { | ||
421 | 89 | fprintf(stderr, "Unable to connect socket\n"); | ||
422 | 90 | return EXIT_FAILURE; | ||
423 | 91 | } | ||
424 | 92 | |||
425 | 93 | /* Dump envvars to socket */ | ||
426 | 94 | copyenv(socketfd, "DISPLAY", getenv("DISPLAY")); | ||
427 | 95 | copyenv(socketfd, "DBUS_SESSION_BUS_ADDRESS", getenv("DBUS_SESSION_BUS_ADDRESS")); | ||
428 | 96 | |||
429 | 97 | char mypid[16]; | ||
430 | 98 | snprintf(mypid, 16, "%ld", (long)getpid()); | ||
431 | 99 | copyenv(socketfd, "UBUNTU_APP_LAUNCH_SNAPPY_XMIR_ENVVARS_PID", mypid); | ||
432 | 100 | |||
433 | 101 | /* Close the socket */ | ||
434 | 102 | close(socketfd); | ||
435 | 103 | |||
436 | 104 | /* Wait for sigterm */ | ||
437 | 105 | signal(SIGTERM, termhandler); | ||
438 | 106 | |||
439 | 107 | for (;;) { | ||
440 | 108 | sleep(24 * 60 * 60); // taking things one day at a time | ||
441 | 109 | } | ||
442 | 110 | |||
443 | 111 | return EXIT_FAILURE; | ||
444 | 112 | } | ||
445 | 0 | 113 | ||
446 | === added file 'snappy-xmir.c' | |||
447 | --- snappy-xmir.c 1970-01-01 00:00:00 +0000 | |||
448 | +++ snappy-xmir.c 2017-02-02 15:08:16 +0000 | |||
449 | @@ -0,0 +1,212 @@ | |||
450 | 1 | /* | ||
451 | 2 | * Copyright © 2016 Canonical Ltd. | ||
452 | 3 | * | ||
453 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
454 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
455 | 6 | * by the Free Software Foundation. | ||
456 | 7 | * | ||
457 | 8 | * This program is distributed in the hope that it will be useful, but | ||
458 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
459 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
460 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
461 | 12 | * | ||
462 | 13 | * You should have received a copy of the GNU General Public License along | ||
463 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
464 | 15 | * | ||
465 | 16 | * Authors: | ||
466 | 17 | * Ted Gould <ted.gould@canonical.com> | ||
467 | 18 | */ | ||
468 | 19 | |||
469 | 20 | #define _POSIX_C_SOURCE 200212L | ||
470 | 21 | |||
471 | 22 | #include <errno.h> | ||
472 | 23 | #include <unistd.h> | ||
473 | 24 | #include <stdio.h> | ||
474 | 25 | #include <stdlib.h> | ||
475 | 26 | #include <sys/types.h> | ||
476 | 27 | #include <sys/socket.h> | ||
477 | 28 | #include <sys/un.h> | ||
478 | 29 | #include <signal.h> | ||
479 | 30 | #include <string.h> | ||
480 | 31 | #include <fcntl.h> | ||
481 | 32 | #include <time.h> | ||
482 | 33 | |||
483 | 34 | #define ENVVAR_SIZE 4096 | ||
484 | 35 | #define SOCKETNAME_SIZE 256 | ||
485 | 36 | #define ENVNAME_SIZE 64 | ||
486 | 37 | |||
487 | 38 | void | ||
488 | 39 | sigchild_handler (int signal) | ||
489 | 40 | { | ||
490 | 41 | fprintf(stderr, "XMir has closed unexpectedly\n"); | ||
491 | 42 | exit(EXIT_FAILURE); | ||
492 | 43 | } | ||
493 | 44 | |||
494 | 45 | struct sigaction sigchild_action = { | ||
495 | 46 | .sa_handler = sigchild_handler, | ||
496 | 47 | .sa_flags = SA_NOCLDWAIT | ||
497 | 48 | }; | ||
498 | 49 | |||
499 | 50 | int | ||
500 | 51 | main (int argc, char * argv[]) | ||
501 | 52 | { | ||
502 | 53 | if (argc < 3) { | ||
503 | 54 | fprintf(stderr, "%s: Usage: [appid] [command to execute...]\n", argv[0]); | ||
504 | 55 | return EXIT_FAILURE; | ||
505 | 56 | } | ||
506 | 57 | |||
507 | 58 | char * appid = argv[1]; | ||
508 | 59 | |||
509 | 60 | /* Build Socket Name */ | ||
510 | 61 | srand(time(NULL)); | ||
511 | 62 | char socketname[SOCKETNAME_SIZE] = {0}; | ||
512 | 63 | snprintf(socketname, sizeof(socketname), "/ual-socket-%08X-%s", rand(), appid); | ||
513 | 64 | |||
514 | 65 | /* Setup abstract socket */ | ||
515 | 66 | int socketfd = socket(AF_UNIX, SOCK_STREAM, 0); | ||
516 | 67 | if (socketfd <= 0) { | ||
517 | 68 | fprintf(stderr, "%s: Unable to create socket\n", argv[0]); | ||
518 | 69 | return EXIT_FAILURE; | ||
519 | 70 | } | ||
520 | 71 | |||
521 | 72 | struct sockaddr_un socketaddr = {0}; | ||
522 | 73 | socketaddr.sun_family = AF_UNIX; | ||
523 | 74 | strncpy(socketaddr.sun_path, socketname, sizeof(socketaddr.sun_path) - 1); | ||
524 | 75 | socketaddr.sun_path[0] = 0; | ||
525 | 76 | |||
526 | 77 | if (bind(socketfd, (const struct sockaddr *)&socketaddr, sizeof(struct sockaddr_un)) < 0) { | ||
527 | 78 | fprintf(stderr, "%s: Unable to bind socket '%s'\n", argv[0], socketname); | ||
528 | 79 | return EXIT_FAILURE; | ||
529 | 80 | } | ||
530 | 81 | |||
531 | 82 | /* Fork and exec the x11 setup under it's confiment */ | ||
532 | 83 | if (sigaction(SIGCHLD, &sigchild_action, NULL) != 0) { | ||
533 | 84 | fprintf(stderr, "Unable to setup child signal handler\n"); | ||
534 | 85 | return EXIT_FAILURE; | ||
535 | 86 | } | ||
536 | 87 | |||
537 | 88 | if (fork() == 0) { | ||
538 | 89 | /* XMir start here */ | ||
539 | 90 | /* GOAL: /snap/bin/unity8-session.xmir-helper $appid libertine-launch /snap/unity8-session/current/usr/bin/snappy-xmir-envvars socketname */ | ||
540 | 91 | |||
541 | 92 | char * snappyhelper = getenv("UBUNTU_APP_LAUNCH_SNAPPY_XMIR_HELPER"); | ||
542 | 93 | if (snappyhelper == NULL) { | ||
543 | 94 | snappyhelper = "xmir-helper"; | ||
544 | 95 | } | ||
545 | 96 | |||
546 | 97 | char * libertinelaunch = getenv("UBUNTU_APP_LAUNCH_LIBERTINE_LAUNCH"); | ||
547 | 98 | if (libertinelaunch == NULL) { | ||
548 | 99 | libertinelaunch = "libertine-launch"; | ||
549 | 100 | } | ||
550 | 101 | |||
551 | 102 | /* envvar is like us, but a little more */ | ||
552 | 103 | char envvars[256] = {0}; | ||
553 | 104 | snprintf(envvars, sizeof(envvars), "%s-envvars", argv[0]); | ||
554 | 105 | |||
555 | 106 | char * xmirexec[6] = { | ||
556 | 107 | snappyhelper, | ||
557 | 108 | appid, | ||
558 | 109 | libertinelaunch, | ||
559 | 110 | envvars, | ||
560 | 111 | socketname, | ||
561 | 112 | NULL | ||
562 | 113 | }; | ||
563 | 114 | |||
564 | 115 | printf("Executing xmir-helper on PID: %d\n", getpid()); | ||
565 | 116 | |||
566 | 117 | fflush(stdout); | ||
567 | 118 | |||
568 | 119 | return execv(xmirexec[0], xmirexec); | ||
569 | 120 | } | ||
570 | 121 | |||
571 | 122 | listen(socketfd, 1); /* 1 is the number of people who can connect */ | ||
572 | 123 | int readsocket = accept(socketfd, NULL, NULL); | ||
573 | 124 | |||
574 | 125 | if (getenv("G_MESSAGES_DEBUG") != NULL) { | ||
575 | 126 | printf("Got a socket connection on: %s\n", socketname); | ||
576 | 127 | } | ||
577 | 128 | |||
578 | 129 | /* Read our socket until we get all of the environment */ | ||
579 | 130 | char readbuf[ENVVAR_SIZE] = {0}; | ||
580 | 131 | int amountread = 0; | ||
581 | 132 | int thisread = 0; | ||
582 | 133 | while ((thisread = read(readsocket, readbuf + amountread, ENVVAR_SIZE - amountread)) > 0) { | ||
583 | 134 | amountread += thisread; | ||
584 | 135 | |||
585 | 136 | if (amountread == ENVVAR_SIZE) { | ||
586 | 137 | fprintf(stderr, "Environment is too large, abort!\n"); | ||
587 | 138 | exit(EXIT_FAILURE); | ||
588 | 139 | } | ||
589 | 140 | } | ||
590 | 141 | |||
591 | 142 | if (thisread < 0) { | ||
592 | 143 | fprintf(stderr, "Error reading environment variables from Xmir utilities: %s", strerror(errno)); | ||
593 | 144 | exit(EXIT_FAILURE); | ||
594 | 145 | } | ||
595 | 146 | |||
596 | 147 | close(readsocket); | ||
597 | 148 | close(socketfd); | ||
598 | 149 | |||
599 | 150 | /* Parse the environment into variables we can insert */ | ||
600 | 151 | if (amountread > 0) { | ||
601 | 152 | char * startvar = readbuf; | ||
602 | 153 | int debug = (getenv("G_MESSAGES_DEBUG") != NULL); | ||
603 | 154 | |||
604 | 155 | do { | ||
605 | 156 | char * startval = startvar + strlen(startvar) + 1; | ||
606 | 157 | setenv(startvar, startval, 1); | ||
607 | 158 | |||
608 | 159 | if (debug) { | ||
609 | 160 | printf("Got env: %s=%s\n", startvar, startval); | ||
610 | 161 | } | ||
611 | 162 | |||
612 | 163 | startvar = startval + strlen(startval) + 1; | ||
613 | 164 | } | ||
614 | 165 | while (startvar < readbuf + amountread); | ||
615 | 166 | } | ||
616 | 167 | |||
617 | 168 | /* Clear MIR_* variables from the environment */ | ||
618 | 169 | /* Unfortunately calling unsetenv resets the environ array so | ||
619 | 170 | it can become invalid. So we need to start over, though this | ||
620 | 171 | is fast */ | ||
621 | 172 | int unset = 1; | ||
622 | 173 | while (unset) { | ||
623 | 174 | unset = 0; | ||
624 | 175 | |||
625 | 176 | unsigned int i; | ||
626 | 177 | for (i = 0; __environ[i] != NULL; i++) { | ||
627 | 178 | const char * env = __environ[i]; | ||
628 | 179 | /* Not checking the length becasue imagining that block | ||
629 | 180 | size will always be larger than 4 bytes on 32-bit systems. | ||
630 | 181 | Compiler should fold this into one comparison. */ | ||
631 | 182 | if (env[0] == 'M' && env[1] == 'I' && env[2] == 'R' && env[3] == '_') { | ||
632 | 183 | char envname[ENVNAME_SIZE] = {0}; | ||
633 | 184 | unset = 1; | ||
634 | 185 | |||
635 | 186 | strncpy(envname, env, ENVNAME_SIZE - 1); | ||
636 | 187 | unsigned int j; | ||
637 | 188 | for (j = 0; j < ENVNAME_SIZE && envname[j] != '\0'; j++) { | ||
638 | 189 | if (envname[j] == '=') { | ||
639 | 190 | envname[j] = '\0'; | ||
640 | 191 | |||
641 | 192 | if (unsetenv(envname) != 0) { | ||
642 | 193 | /* Shouldn't happen unless we're out of memory, | ||
643 | 194 | might as well bail now if that's the case. */ | ||
644 | 195 | fprintf(stderr, "Unable to unset '%s' environment variable\n", envname); | ||
645 | 196 | exit(EXIT_FAILURE); | ||
646 | 197 | } | ||
647 | 198 | |||
648 | 199 | break; | ||
649 | 200 | } | ||
650 | 201 | } | ||
651 | 202 | |||
652 | 203 | break; | ||
653 | 204 | } | ||
654 | 205 | } | ||
655 | 206 | } | ||
656 | 207 | |||
657 | 208 | fflush(stdout); | ||
658 | 209 | |||
659 | 210 | /* Exec the application with the new environment under its confinement */ | ||
660 | 211 | return execv(argv[2], &(argv[2])); | ||
661 | 212 | } | ||
662 | 0 | 213 | ||
663 | === modified file 'tests/CMakeLists.txt' | |||
664 | --- tests/CMakeLists.txt 2017-02-02 15:08:16 +0000 | |||
665 | +++ tests/CMakeLists.txt 2017-02-02 15:08:16 +0000 | |||
666 | @@ -165,6 +165,11 @@ | |||
667 | 165 | configure_file ("xmir-helper-test.in" "${CMAKE_CURRENT_BINARY_DIR}/xmir-helper-test" @ONLY) | 165 | configure_file ("xmir-helper-test.in" "${CMAKE_CURRENT_BINARY_DIR}/xmir-helper-test" @ONLY) |
668 | 166 | add_test (xmir-helper-test xmir-helper-test) | 166 | add_test (xmir-helper-test xmir-helper-test) |
669 | 167 | 167 | ||
670 | 168 | # Snappy XMir Wrapper Test | ||
671 | 169 | |||
672 | 170 | configure_file("snappy-xmir-test.sh.in" "${CMAKE_CURRENT_BINARY_DIR}/snappy-xmir-test.sh" @ONLY) | ||
673 | 171 | add_test (NAME snappy-xmir-test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snappy-xmir-test.sh) | ||
674 | 172 | |||
675 | 168 | # Formatted code | 173 | # Formatted code |
676 | 169 | 174 | ||
677 | 170 | add_custom_target(format-tests | 175 | add_custom_target(format-tests |
678 | 171 | 176 | ||
679 | === added file 'tests/snappy-xmir-test-check.sh' | |||
680 | --- tests/snappy-xmir-test-check.sh 1970-01-01 00:00:00 +0000 | |||
681 | +++ tests/snappy-xmir-test-check.sh 2017-02-02 15:08:16 +0000 | |||
682 | @@ -0,0 +1,32 @@ | |||
683 | 1 | #!/bin/bash | ||
684 | 2 | |||
685 | 3 | set -ex | ||
686 | 4 | |||
687 | 5 | if [ -z ${DISPLAY} ] ; then | ||
688 | 6 | echo DISPLAY is not set | ||
689 | 7 | exit 1 | ||
690 | 8 | fi | ||
691 | 9 | |||
692 | 10 | if [ ${DISPLAY} != "foo" ] ; then | ||
693 | 11 | echo DISPLAY is not set to 'foo' | ||
694 | 12 | exit 1 | ||
695 | 13 | fi | ||
696 | 14 | |||
697 | 15 | if [ -z ${DBUS_SESSION_BUS_ADDRESS} ] ; then | ||
698 | 16 | echo DBUS_SESSION_BUS_ADDRESS is not set | ||
699 | 17 | exit 1 | ||
700 | 18 | fi | ||
701 | 19 | |||
702 | 20 | if [ ${DBUS_SESSION_BUS_ADDRESS} != "bar" ] ; then | ||
703 | 21 | echo DBUS_SESSION_BUS_ADDRESS is not set to 'bar' | ||
704 | 22 | exit 1 | ||
705 | 23 | fi | ||
706 | 24 | |||
707 | 25 | if [ ! -z ${MIR_SOCKET} ] ; then | ||
708 | 26 | echo Mir variables are leaking in | ||
709 | 27 | exit 1 | ||
710 | 28 | fi | ||
711 | 29 | |||
712 | 30 | if [ ! -z ${UBUNTU_APP_LAUNCH_SNAPPY_XMIR_ENVVARS_PID} ] ; then | ||
713 | 31 | kill -TERM ${UBUNTU_APP_LAUNCH_SNAPPY_XMIR_ENVVARS_PID} | ||
714 | 32 | fi | ||
715 | 0 | 33 | ||
716 | === added file 'tests/snappy-xmir-test-helper-long.sh' | |||
717 | --- tests/snappy-xmir-test-helper-long.sh 1970-01-01 00:00:00 +0000 | |||
718 | +++ tests/snappy-xmir-test-helper-long.sh 2017-02-02 15:08:16 +0000 | |||
719 | @@ -0,0 +1,12 @@ | |||
720 | 1 | #!/bin/bash | ||
721 | 2 | |||
722 | 3 | set -ex | ||
723 | 4 | |||
724 | 5 | if [ $1 != "this-is-a-really-really-really_long_appid-that-we-shouldnt-reallyhave_13523432324235.234.234.234234+foo" ] ; then | ||
725 | 6 | exit 1 | ||
726 | 7 | fi | ||
727 | 8 | |||
728 | 9 | export DISPLAY=foo | ||
729 | 10 | export DBUS_SESSION_BUS_ADDRESS=bar | ||
730 | 11 | |||
731 | 12 | exec $2 $3 $4 $5 | ||
732 | 0 | 13 | ||
733 | === added file 'tests/snappy-xmir-test-helper.sh' | |||
734 | --- tests/snappy-xmir-test-helper.sh 1970-01-01 00:00:00 +0000 | |||
735 | +++ tests/snappy-xmir-test-helper.sh 2017-02-02 15:08:16 +0000 | |||
736 | @@ -0,0 +1,12 @@ | |||
737 | 1 | #!/bin/bash | ||
738 | 2 | |||
739 | 3 | set -ex | ||
740 | 4 | |||
741 | 5 | if [ $1 != "appid" ] ; then | ||
742 | 6 | exit 1 | ||
743 | 7 | fi | ||
744 | 8 | |||
745 | 9 | export DISPLAY=foo | ||
746 | 10 | export DBUS_SESSION_BUS_ADDRESS=bar | ||
747 | 11 | |||
748 | 12 | exec $2 $3 $4 $5 | ||
749 | 0 | 13 | ||
750 | === added file 'tests/snappy-xmir-test-libertine-launch.sh' | |||
751 | --- tests/snappy-xmir-test-libertine-launch.sh 1970-01-01 00:00:00 +0000 | |||
752 | +++ tests/snappy-xmir-test-libertine-launch.sh 2017-02-02 15:08:16 +0000 | |||
753 | @@ -0,0 +1,5 @@ | |||
754 | 1 | #!/bin/bash | ||
755 | 2 | |||
756 | 3 | set -ex | ||
757 | 4 | |||
758 | 5 | exec $@ | ||
759 | 0 | 6 | ||
760 | === added file 'tests/snappy-xmir-test.sh.in' | |||
761 | --- tests/snappy-xmir-test.sh.in 1970-01-01 00:00:00 +0000 | |||
762 | +++ tests/snappy-xmir-test.sh.in 2017-02-02 15:08:16 +0000 | |||
763 | @@ -0,0 +1,30 @@ | |||
764 | 1 | #!/bin/bash | ||
765 | 2 | |||
766 | 3 | set -ex | ||
767 | 4 | |||
768 | 5 | # Unset MIR_SOCKET as we might be in an environment it exists in | ||
769 | 6 | |||
770 | 7 | export MIR_SOCKET= | ||
771 | 8 | |||
772 | 9 | # Test the test harness | ||
773 | 10 | |||
774 | 11 | @CMAKE_CURRENT_SOURCE_DIR@/snappy-xmir-test-helper.sh appid @CMAKE_CURRENT_SOURCE_DIR@/snappy-xmir-test-check.sh | ||
775 | 12 | |||
776 | 13 | # Test our pass through | ||
777 | 14 | |||
778 | 15 | export UBUNTU_APP_LAUNCH_SNAPPY_XMIR_HELPER="@CMAKE_CURRENT_SOURCE_DIR@/snappy-xmir-test-helper.sh" | ||
779 | 16 | export UBUNTU_APP_LAUNCH_LIBERTINE_LAUNCH="@CMAKE_CURRENT_SOURCE_DIR@/snappy-xmir-test-libertine-launch.sh" | ||
780 | 17 | |||
781 | 18 | @CMAKE_BINARY_DIR@/snappy-xmir appid @CMAKE_CURRENT_SOURCE_DIR@/snappy-xmir-test-check.sh | ||
782 | 19 | |||
783 | 20 | # Add a Mir variable to make sure it gets cleared | ||
784 | 21 | |||
785 | 22 | export MIR_SOCKET="/this/is/a/socket" | ||
786 | 23 | |||
787 | 24 | @CMAKE_BINARY_DIR@/snappy-xmir appid @CMAKE_CURRENT_SOURCE_DIR@/snappy-xmir-test-check.sh | ||
788 | 25 | |||
789 | 26 | # This is a long appid test | ||
790 | 27 | |||
791 | 28 | export UBUNTU_APP_LAUNCH_SNAPPY_XMIR_HELPER="@CMAKE_CURRENT_SOURCE_DIR@/snappy-xmir-test-helper-long.sh" | ||
792 | 29 | |||
793 | 30 | @CMAKE_BINARY_DIR@/snappy-xmir "this-is-a-really-really-really_long_appid-that-we-shouldnt-reallyhave_13523432324235.234.234.234234+foo" @CMAKE_CURRENT_SOURCE_DIR@/snappy-xmir-test-check.sh | ||
794 | 0 | 31 | ||
795 | === modified file 'upstart-jobs/application-click.conf.in' | |||
796 | --- upstart-jobs/application-click.conf.in 2015-08-17 21:34:39 +0000 | |||
797 | +++ upstart-jobs/application-click.conf.in 2017-02-02 15:08:16 +0000 | |||
798 | @@ -14,7 +14,6 @@ | |||
799 | 14 | env APP_XMIR_ENABLE | 14 | env APP_XMIR_ENABLE |
800 | 15 | 15 | ||
801 | 16 | env UBUNTU_APP_LAUNCH_ARCH="@ubuntu_app_launch_arch@" | 16 | env UBUNTU_APP_LAUNCH_ARCH="@ubuntu_app_launch_arch@" |
802 | 17 | export UBUNTU_APP_LAUNCH_ARCH | ||
803 | 18 | 17 | ||
804 | 19 | apparmor switch ${APP_ID} | 18 | apparmor switch ${APP_ID} |
805 | 20 | cgroup freezer | 19 | cgroup freezer |
806 | 21 | 20 | ||
807 | === modified file 'upstart-jobs/application-snap.conf.in' | |||
808 | --- upstart-jobs/application-snap.conf.in 2016-09-08 15:05:06 +0000 | |||
809 | +++ upstart-jobs/application-snap.conf.in 2017-02-02 15:08:16 +0000 | |||
810 | @@ -15,7 +15,6 @@ | |||
811 | 15 | env INSTANCE_ID="" | 15 | env INSTANCE_ID="" |
812 | 16 | 16 | ||
813 | 17 | env UBUNTU_APP_LAUNCH_ARCH="@ubuntu_app_launch_arch@" | 17 | env UBUNTU_APP_LAUNCH_ARCH="@ubuntu_app_launch_arch@" |
814 | 18 | export UBUNTU_APP_LAUNCH_ARCH | ||
815 | 19 | 18 | ||
816 | 20 | # apparmor is taken care of by confine | 19 | # apparmor is taken care of by confine |
817 | 21 | cgroup freezer | 20 | cgroup freezer |
818 | 22 | 21 | ||
819 | === modified file 'upstart-jobs/untrusted-helper.conf.in' | |||
820 | --- upstart-jobs/untrusted-helper.conf.in 2014-08-07 16:16:05 +0000 | |||
821 | +++ upstart-jobs/untrusted-helper.conf.in 2017-02-02 15:08:16 +0000 | |||
822 | @@ -12,7 +12,6 @@ | |||
823 | 12 | env APP_URIS | 12 | env APP_URIS |
824 | 13 | 13 | ||
825 | 14 | env UBUNTU_APP_LAUNCH_ARCH="@ubuntu_app_launch_arch@" | 14 | env UBUNTU_APP_LAUNCH_ARCH="@ubuntu_app_launch_arch@" |
826 | 15 | export UBUNTU_APP_LAUNCH_ARCH | ||
827 | 16 | 15 | ||
828 | 17 | apparmor switch ${APP_ID} | 16 | apparmor switch ${APP_ID} |
829 | 18 | cgroup freezer | 17 | cgroup freezer |
830 | 19 | 18 | ||
831 | === modified file 'xmir-helper.c' | |||
832 | --- xmir-helper.c 2017-02-02 15:08:16 +0000 | |||
833 | +++ xmir-helper.c 2017-02-02 15:08:16 +0000 | |||
834 | @@ -30,7 +30,7 @@ | |||
835 | 30 | sigchild_handler (int signal) | 30 | sigchild_handler (int signal) |
836 | 31 | { | 31 | { |
837 | 32 | fprintf(stderr, "XMir has closed unexpectedly\n"); | 32 | fprintf(stderr, "XMir has closed unexpectedly\n"); |
839 | 33 | exit(1); | 33 | exit(EXIT_FAILURE); |
840 | 34 | } | 34 | } |
841 | 35 | 35 | ||
842 | 36 | struct sigaction sigchild_action = { | 36 | struct sigaction sigchild_action = { |
843 | @@ -43,7 +43,7 @@ | |||
844 | 43 | { | 43 | { |
845 | 44 | if (argc < 3) { | 44 | if (argc < 3) { |
846 | 45 | fprintf(stderr, "xmir-helper needs more arguments: xmir-helper $(appid) $(thing to exec) ... \n"); | 45 | fprintf(stderr, "xmir-helper needs more arguments: xmir-helper $(appid) $(thing to exec) ... \n"); |
848 | 46 | return 1; | 46 | return EXIT_FAILURE; |
849 | 47 | } | 47 | } |
850 | 48 | 48 | ||
851 | 49 | /* Make nice variables for the things we need */ | 49 | /* Make nice variables for the things we need */ |
852 | @@ -57,7 +57,7 @@ | |||
853 | 57 | int sockets[2]; | 57 | int sockets[2]; |
854 | 58 | if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockets) != 0) { | 58 | if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockets) != 0) { |
855 | 59 | fprintf(stderr, "Unable to create socketpair for communicating with XMir\n"); | 59 | fprintf(stderr, "Unable to create socketpair for communicating with XMir\n"); |
857 | 60 | return 1; | 60 | return EXIT_FAILURE; |
858 | 61 | } | 61 | } |
859 | 62 | 62 | ||
860 | 63 | /* Give them nice names, the compiler will optimize out */ | 63 | /* Give them nice names, the compiler will optimize out */ |
861 | @@ -67,7 +67,7 @@ | |||
862 | 67 | /* Watch for the child dying */ | 67 | /* Watch for the child dying */ |
863 | 68 | if (sigaction(SIGCHLD, &sigchild_action, NULL) != 0) { | 68 | if (sigaction(SIGCHLD, &sigchild_action, NULL) != 0) { |
864 | 69 | fprintf(stderr, "Unable to setup child signal handler\n"); | 69 | fprintf(stderr, "Unable to setup child signal handler\n"); |
866 | 70 | return 1; | 70 | return EXIT_FAILURE; |
867 | 71 | } | 71 | } |
868 | 72 | 72 | ||
869 | 73 | /* Start XMir */ | 73 | /* Start XMir */ |
Resubmitted this with a better description of what the branch actually does today.