Merge lp:~diegosarmentero/ubuntu-system-settings/check-hash into lp:ubuntu-system-settings

Proposed by Diego Sarmentero
Status: Merged
Merged at revision: 1268
Proposed branch: lp:~diegosarmentero/ubuntu-system-settings/check-hash
Merge into: lp:ubuntu-system-settings
Prerequisite: lp:~diegosarmentero/ubuntu-system-settings/account-detected
Diff against target: 243 lines (+82/-8)
8 files modified
plugins/system-update/PageComponent.qml (+7/-5)
plugins/system-update/download_tracker.cpp (+2/-1)
plugins/system-update/download_tracker.h (+5/-1)
plugins/system-update/network/network.cpp (+2/-0)
plugins/system-update/update.cpp (+1/-0)
plugins/system-update/update.h (+5/-0)
plugins/system-update/update_manager.cpp (+0/-1)
tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py (+60/-0)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-system-settings/check-hash
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Sebastien Bacher (community) Needs Information
Review via email: mp+236554@code.launchpad.net

Commit message

- Check click hash

Description of the change

To test this branch in the device you can set the environment variable URL_APPS to http://localhost:8000/iteminfo/ (best to do it in /etc/environments and restart). Then execute the python script added in this branch, and open System Updates to see an update on the calculator, which should fail because of the invalid hash

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, that looks fine to me but do you have any hint on how to test the change?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1055. By Diego Sarmentero

fixing click update sign flow

1056. By Diego Sarmentero

remove unnecesary use of secondary urls

1057. By Diego Sarmentero

[ jonas-drange ]
* [wifi/phone] dynamically chooses what SIM to use when there's only
  one present. (LP: #1375832)
[ Iain Lane ]
* [storage/about] Use a QSharedPointer to manage freeing of the
  counter which we use to display all of the collected sizes at once.
  If the measuring process was cancelled, we were freeing it multiple
  times - once for each outstanding size measurement. This led to a
  crash. (LP: #1375988)
* [security-privacy] Link with gobject, uses symbols from this
  library. Prevents "[…]libUbuntuSecurityPrivacyPanel.so contains an
  unresolvable reference to symbol
  g_signal_handlers_disconnect_matched: it's probably a plugin"
  warnings.
[ jonas-drange ]
* [cellular] react to application.state changes and update potential
  out-of-date default SIM settings (LP: #1364103)
* [wifi] let removed networks update the previous network model so
  that we can reuse the model (and not pop the pagestack twice,
  causing this ux issue) (LP: #1370389)
[ Sebastien Bacher ]
* [location] use a flickable so the list can be scrolled (LP:
  #1374017)
* [security] get localized application names from the trust-store (LP:
  #1374018)
[ Ken VanDine ]
* Fixed handling of the Downloading/Installing label based on actual
  state. . Forward updateProgress signals for system updates. Layout
  fixes (LP: #1312587)
* Use new splash screen (LP: #1376242)
* Improved tracking download states
* Use new target_build_number from system-image-dbus to determine
  visibility of the update notification (LP: #1355803)
[ CI bot ]
* Resync trunk
[ Sebastien Bacher ]
* [storage] use libclick rather than calling the command line (LP:
  #1368967)
* [storage] tweaks to the disk informations, limit the free space to
  the user available one (excluding the system partitions), don't list
  the external mounts, that's described in the design and is going to
  require work on the categories computation to give correct values
  (LP: #1284247)
* [about] display the free space value next to the storage label (LP:
  #1335144)
[ Albert Astals ]
* Add i18n.tr
[ jonas-drange ]
* [wifi] connect to hidden network is now a dialog (LP: #1366005)
[ Ken VanDine ]
* Provide more keywords to make search useful (LP: #1370219) (LP:
  #1370219)
* [background] set sourceSize in the image preview to work around an
  issue loading large images (LP: #1373462)
[ CI bot ]
* Resync trunk
[ Mathieu Trudel-Lapierre ]
* [bluetooth] Properly handle device types for connection and
  disconnection. (LP: #1369964)
[ Michael Terry ]
* Add a translator comment for what HERE means. (LP: #1368838) (LP:
  #1368838)
* Prevent a crash in unity8 when the wizard also crashes or stops
  early. (LP: #1355892) (LP: #1355892)
[ Michael Terry ]
* Prevent the buttons of the wizard's password page from overlapping
  its content when the OSK appears. (LP: #1368346) (LP: #1368346)
[ Ken VanDine ]
* Set the version information in the SystemUpdate constructor (LP:
  #1371810) (LP: #1371810)
* [reset] Don't bail out on an isValid() check on the SystemImage
  QDBusInterface, the docs say isValid() may not be reliable for
  remote interfaces (LP: #1370815) (LP: #1370815)
* Fixed reference error for count on the various device models (LP:
  #1362517) (LP: #1362517)
* [background] Use the ContentPeerPicker to select sources for
  backgrounds (LP: #1356542) (LP: #1356542)
[ Iain Lane ]
* Don't check if the timedated interface is valid before calling
  SetTime on it, it might have timed out and we should reactivate it
  in that case.
* [about] Fix developerMode property to be QMLish - read & write
  instead of separate "read" and "toggle" properties.
* [about] Don't display a frame for icons that can't be found,
  improving the visual appearance. Also return the correct path for
  click packages which use the icon theme.
[ Sebastien Bacher ]
* [storage] handle the scope click .ini and get the correct icons (LP:
  #1368920)
[ Albert Astals ]
* make pot
[ Oliver Grawert ]
* fix LP: #1365903, add a watch to Developer Mode page so the page
  gets refreshed when going back through the page stack, also fix the
  page id and bounds (LP: #1365903)
* Some packaging fixes
  - > is not a valid relationship. It should be >>
  - Don't recommend suru-icon-theme since we also depend on it
  - Bump S-V to 3.9.6 which for example allows the images we ship in
    /usr/lib/
  - Override binary-no-manpage lintian warnings. We're not going to get man
    pages for u-s-s any time soon
[ Ken VanDine ]
* Make UpdateManager a singleton and refresh the availableUpdates
  count when the model updates (LP: #1325629) (LP: #1325629)
[ Ken VanDine ]
* Include an icon instead of using the themed icon (LP: #1365408) (LP:
  #1365408)
[ Mathieu Trudel-Lapierre ]
* [bluetooth] don't try to enable Discoverable if the device isn't
  powered yet. (LP: #1355904)
[ Ken VanDine ]
* When activated by a url request for a specific panel, clear the
  pageStack to maintain the natural navigation instead of pushing a
  new page on top of a page from a the previous panel (LP: #1362025)
  (LP: #1362025, #1359953)
[ Lars Uebernickel ]
* Use Icon instead of StatusIcon
[ CI bot ]
* Resync trunk
[ John R. Lenton ]
* Take the system settings push helper closer to implementing the spec
  at https://wiki.ubuntu.com/SoftwareUpdates#Prompting (LP: #1363972)

1058. By Diego Sarmentero

improve resume for tracker

Revision history for this message
Charles Kerr (charlesk) wrote :

The code looks good for getting the checksum and making it available to QML, but unless I'm misreading, it doesn't take the final step of showing it to the user?

Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

> The code looks good for getting the checksum and making it available to QML,
> but unless I'm misreading, it doesn't take the final step of showing it to the
> user?

Yes, the Download Manager will check the checksum after the download is complete, and if that fails it will emit an Error signal with the text that is going to be displayed in the Update item in the UI.

Revision history for this message
Sebastien Bacher (seb128) wrote :

not sure why CI didn't do a build of the current revision, I gave it a retry...
the code looks fine other

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

running the testcase is not working, the test server displays those error

  File "/tmp/mock_update_click_server.py", line 31, in response_item_info
    self.wfile.write(bytes(json.dumps(response), 'UTF-8'))
  File "/usr/lib/python3.4/socket.py", line 391, in write
    return self._sock.send(b)
BrokenPipeError: [Errno 32] Broken pipe

The UI displays a bar going to 100% but no error

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/system-update/PageComponent.qml'
2--- plugins/system-update/PageComponent.qml 2014-10-08 15:51:44 +0000
3+++ plugins/system-update/PageComponent.qml 2014-10-17 11:45:42 +0000
4@@ -420,17 +420,18 @@
5
6 function resume () {
7 console.warn("RESUME: " + modelData.packageName);
8- if (modelData.systemUpdate)
9- return UpdateManager.startDownload(modelData.packageName);
10- modelData.updateState = true;
11- tracker.resume();
12+ UpdateManager.startDownload(modelData.packageName);
13 }
14
15 function start () {
16 console.warn("START: " + modelData.packageName);
17+ if (!modelData.selected || modelData.systemUpdate) {
18+ UpdateManager.startDownload(modelData.packageName);
19+ } else {
20+ tracker.resume();
21+ }
22 modelData.selected = true;
23 modelData.updateState = true;
24- UpdateManager.startDownload(modelData.packageName);
25 }
26 Column {
27 id: textArea
28@@ -561,6 +562,7 @@
29 packageName: modelData.packageName
30 clickToken: modelData.clickToken
31 download: modelData.downloadUrl
32+ downloadSha512: modelData.downloadSha512
33
34 onFinished: {
35 progress.visible = false;
36
37=== modified file 'plugins/system-update/download_tracker.cpp'
38--- plugins/system-update/download_tracker.cpp 2014-09-30 02:05:36 +0000
39+++ plugins/system-update/download_tracker.cpp 2014-10-17 11:45:42 +0000
40@@ -27,6 +27,7 @@
41 #define DOWNLOAD_COMMAND "post-download-command"
42 #define APP_ID "app_id"
43 #define PKCON_COMMAND "pkcon"
44+#define DOWNLOAD_MANAGER_SHA512 "sha512"
45
46 namespace UpdatePlugin {
47
48@@ -81,7 +82,7 @@
49 vmap[APP_ID] = m_packageName;
50 StringMap map;
51 map[X_CLICK_TOKEN] = m_clickToken;
52- DownloadStruct dstruct = DownloadStruct(m_downloadUrl, vmap, map);
53+ DownloadStruct dstruct = DownloadStruct(m_downloadUrl, m_download_sha512, DOWNLOAD_MANAGER_SHA512, vmap, map);
54 m_manager->createDownload(dstruct);
55 }
56 }
57
58=== modified file 'plugins/system-update/download_tracker.h'
59--- plugins/system-update/download_tracker.h 2014-09-30 02:05:36 +0000
60+++ plugins/system-update/download_tracker.h 2014-10-17 11:45:42 +0000
61@@ -42,6 +42,7 @@
62 Q_PROPERTY(QString clickToken READ clickToken WRITE setClickToken)
63 Q_PROPERTY(QString download READ download WRITE setDownload)
64 Q_PROPERTY(QString packageName READ packageName WRITE setPackageName)
65+ Q_PROPERTY(QString downloadSha512 READ downloadSha512 WRITE setDownloadSha512)
66 Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
67
68 public:
69@@ -54,10 +55,12 @@
70 QString download() { return m_downloadUrl; }
71 QString clickToken() { return m_clickToken; }
72 QString packageName() { return m_packageName; }
73+ QString downloadSha512() { return m_download_sha512; }
74+ int progress() { return m_progress; }
75 void setDownload(const QString& url);
76 void setClickToken(const QString& token);
77 void setPackageName(const QString& package);
78- int progress() { return m_progress; }
79+ void setDownloadSha512(const QString &sha512) { m_download_sha512 = sha512; }
80
81 public Q_SLOTS:
82 void bindDownload(Download* download);
83@@ -82,6 +85,7 @@
84 Download* m_download;
85 Manager* m_manager;
86 int m_progress;
87+ QString m_download_sha512;
88
89 void startService();
90 QString getPkconCommand();
91
92=== modified file 'plugins/system-update/network/network.cpp'
93--- plugins/system-update/network/network.cpp 2014-09-18 13:50:15 +0000
94+++ plugins/system-update/network/network.cpp 2014-10-17 11:45:42 +0000
95@@ -107,6 +107,7 @@
96 QString version = object.value("version").toString();
97 QString icon_url = object.value("icon_url").toString();
98 QString url = object.value("download_url").toString();
99+ QString download_sha512 = object.value("download_sha512").toString();
100 int size = object.value("binary_filesize").toVariant().toInt();
101 if (m_apps.contains(name)) {
102 m_apps[name]->setRemoteVersion(version);
103@@ -114,6 +115,7 @@
104 m_apps[name]->setIconUrl(icon_url);
105 m_apps[name]->setDownloadUrl(url);
106 m_apps[name]->setBinaryFilesize(size);
107+ m_apps[name]->setDownloadSha512(download_sha512);
108 updates = true;
109 }
110 }
111
112=== modified file 'plugins/system-update/update.cpp'
113--- plugins/system-update/update.cpp 2014-09-12 23:47:39 +0000
114+++ plugins/system-update/update.cpp 2014-10-17 11:45:42 +0000
115@@ -29,6 +29,7 @@
116 QObject(parent),
117 m_binary_filesize(0),
118 m_click_url(""),
119+ m_clickToken(""),
120 m_downloadUrl(""),
121 m_download_progress(0),
122 m_error(""),
123
124=== modified file 'plugins/system-update/update.h'
125--- plugins/system-update/update.h 2014-09-12 19:12:36 +0000
126+++ plugins/system-update/update.h 2014-10-17 11:45:42 +0000
127@@ -57,6 +57,7 @@
128 NOTIFY downloadProgressChanged)
129 Q_PROPERTY(QString downloadUrl READ downloadUrl NOTIFY downloadUrlChanged)
130 Q_PROPERTY(QString clickToken READ clickToken NOTIFY clickTokenChanged)
131+ Q_PROPERTY(QString downloadSha512 READ downloadSha512 NOTIFY downloadSha512Changed)
132
133 Q_SIGNALS:
134 void systemUpdateChanged();
135@@ -75,6 +76,7 @@
136 void downloadUrlChanged();
137 void clickTokenChanged();
138 void packageNameChanged();
139+ void downloadSha512Changed();
140
141 public:
142 explicit Update(QObject *parent = 0);
143@@ -97,6 +99,7 @@
144 const QString& getClickUrl() const { return m_click_url; }
145 QString downloadUrl() { return m_downloadUrl; }
146 QString clickToken() { return m_clickToken; }
147+ QString downloadSha512() { return m_download_sha512; }
148
149 void setSystemUpdate(bool isSystem);
150 void initializeApplication(QString packagename, QString title,
151@@ -115,6 +118,7 @@
152 void setClickUrl(const QString &url) { m_click_url = url; }
153 void setDownloadUrl(const QString &url);
154 void setClickToken(const QString &token) { m_clickToken = token; Q_EMIT clickTokenChanged(); }
155+ void setDownloadSha512(const QString &sha512) { m_download_sha512 = sha512; Q_EMIT downloadSha512Changed(); }
156
157 private:
158 int m_binary_filesize;
159@@ -134,6 +138,7 @@
160 bool m_update;
161 bool m_update_ready;
162 bool m_update_state;
163+ QString m_download_sha512;
164
165 bool getIgnoreUpdates();
166 };
167
168=== modified file 'plugins/system-update/update_manager.cpp'
169--- plugins/system-update/update_manager.cpp 2014-10-08 15:51:44 +0000
170+++ plugins/system-update/update_manager.cpp 2014-10-17 11:45:42 +0000
171@@ -321,7 +321,6 @@
172 {
173 app->setError("");
174 app->setClickToken(clickToken);
175- app->setDownloadUrl(app->getClickUrl());
176 }
177
178 void UpdateManager::updateClickScope()
179
180=== added file 'tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py'
181--- tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py 1970-01-01 00:00:00 +0000
182+++ tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py 2014-10-17 11:45:42 +0000
183@@ -0,0 +1,60 @@
184+import json
185+import threading
186+from http.server import BaseHTTPRequestHandler, HTTPServer
187+
188+
189+KEEP_ALIVE = True
190+
191+
192+class MyHandler(BaseHTTPRequestHandler):
193+
194+ def do_HEAD(self):
195+ self.send_response(200)
196+ self.send_header("X-Click-Token", "X-Click-Token")
197+ self.end_headers()
198+
199+ def response_item_info(self):
200+ response = [{
201+ "name": "com.ubuntu.calculator",
202+ "version": "9.0",
203+ "icon_url": ("https://raw.githubusercontent.com/ninja-ide/"
204+ "ninja-ide/master/ninja_ide/img/ninja_icon.png"),
205+ "download_url": ("https://public.apps.ubuntu.com/download/com."
206+ "ubuntu/calculator/com.ubuntu.calculator_1"
207+ ".3.329_all.click"),
208+ "binary_filesize": 3423,
209+ "download_sha512": "343244fsdfdsffs"
210+ }]
211+ self.send_response(200)
212+ self.send_header("Content-type", "application/json")
213+ self.end_headers()
214+ self.wfile.write(bytes(json.dumps(response), 'UTF-8'))
215+
216+ def do_POST(self):
217+ """Respond to a POST request."""
218+ self.do_GET()
219+
220+ def do_GET(self):
221+ """Respond to a GET request."""
222+ if self.path.find("iteminfo/") != -1:
223+ self.response_item_info()
224+ elif self.path.find("shutdown") != -1:
225+ global KEEP_ALIVE
226+ KEEP_ALIVE = False
227+
228+
229+def run_click_server():
230+ server_address = ('', 8000)
231+ httpd = HTTPServer(server_address, MyHandler)
232+ global KEEP_ALIVE
233+ print('start')
234+ while KEEP_ALIVE:
235+ httpd.handle_request()
236+
237+
238+def run_mocked_settings():
239+ t = threading.Thread(target=run_click_server)
240+ t.start()
241+
242+
243+run_mocked_settings()

Subscribers

People subscribed via source and target branches