Merge ~jamesh/gnome-software:classic-snap-install into gnome-software:wip/ubuntu-master

Proposed by James Henstridge
Status: Needs review
Proposed branch: ~jamesh/gnome-software:classic-snap-install
Merge into: gnome-software:wip/ubuntu-master
Diff against target: 168 lines (+75/-4)
3 files modified
plugins/snap/gs-plugin-snap.c (+19/-2)
src/gs-details-page.c (+14/-0)
src/gs-details-page.ui (+42/-2)
Reviewer Review Type Date Requested Status
GNOME3 Team Pending
Review via email: mp+326206@code.launchpad.net

Description of the change

Add support for installing classic snaps through gnome-software.

This is using Robert Ancell's patch from bug 1690280, along with a change to the details page to display a warning for snap packages that don't have the SANDBOXED kudo (which is currently granted to any snap using strict confinement).

There are a few open questions:

1. Is this where the warning should sit?
2. What exact text should it contain?

As far as warnings to users go, I would tend to think a strict confined snap that connects to the home interface to be similarly dangerous to a classic snap. It doesn't look like we can detect that case from the metadata returned by "find" requests though.

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

This should be proposed upstream. I notice I didn't open an upstream bug - can you do that?

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
2index b268a13..c5d9124 100644
3--- a/plugins/snap/gs-plugin-snap.c
4+++ b/plugins/snap/gs-plugin-snap.c
5@@ -24,6 +24,12 @@
6 #include <snapd-glib/snapd-glib.h>
7 #include <gnome-software.h>
8
9+/* FIXME: <snapd-glib/snapd-glib.h> doesn't include
10+ * snapd-enum-types.h, and it checks that this macro is defined */
11+#define __SNAPD_GLIB_INSIDE__
12+#include <snapd-glib/snapd-enum-types.h>
13+#undef __SNAPD_GLIB_INSIDE__
14+
15 struct GsPluginData {
16 GsAuth *auth;
17 GHashTable *store_snaps;
18@@ -175,6 +181,8 @@ static GsApp *
19 snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
20 {
21 GsApp *app;
22+ SnapdConfinement confinement;
23+ GEnumClass *enum_class;
24
25 /* create a unique ID for deduplication, TODO: branch? */
26 app = gs_app_new (snapd_snap_get_name (snap));
27@@ -186,7 +194,13 @@ snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
28 gs_app_set_name (app, GS_APP_QUALITY_HIGHEST, snapd_snap_get_name (snap));
29 if (gs_plugin_check_distro_id (plugin, "ubuntu"))
30 gs_app_add_quirk (app, AS_APP_QUIRK_PROVENANCE);
31- if (snapd_snap_get_confinement (snap) == SNAPD_CONFINEMENT_STRICT)
32+
33+ confinement = snapd_snap_get_confinement (snap);
34+ enum_class = g_type_class_ref (SNAPD_TYPE_CONFINEMENT);
35+ gs_app_set_metadata (app, "snap::confinement", g_enum_get_value (enum_class, confinement)->value_nick);
36+ g_type_class_unref (enum_class);
37+
38+ if (confinement == SNAPD_CONFINEMENT_STRICT)
39 gs_app_add_kudo (app, GS_APP_KUDO_SANDBOXED);
40
41 return app;
42@@ -541,6 +555,7 @@ gs_plugin_app_install (GsPlugin *plugin,
43 GError **error)
44 {
45 g_autoptr(SnapdClient) client = NULL;
46+ SnapdInstallFlags flags = SNAPD_INSTALL_FLAGS_NONE;
47
48 /* We can only install apps we know of */
49 if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
50@@ -550,7 +565,9 @@ gs_plugin_app_install (GsPlugin *plugin,
51 client = get_client (plugin, cancellable, error);
52 if (client == NULL)
53 return FALSE;
54- if (!snapd_client_install_sync (client, gs_app_get_id (app), NULL, progress_cb, app, cancellable, error)) {
55+ if (g_strcmp0 (gs_app_get_metadata_item (app, "snap::confinement"), "classic") == 0)
56+ flags |= SNAPD_INSTALL_FLAGS_CLASSIC;
57+ if (!snapd_client_install2_sync (client, flags, gs_app_get_id (app), NULL, NULL, progress_cb, app, cancellable, error)) {
58 gs_app_set_state_recover (app);
59 return FALSE;
60 }
61diff --git a/src/gs-details-page.c b/src/gs-details-page.c
62index d93c6b5..9a3d760 100644
63--- a/src/gs-details-page.c
64+++ b/src/gs-details-page.c
65@@ -142,6 +142,7 @@ struct _GsDetailsPage
66 GtkWidget *label_content_rating_none;
67 GtkWidget *button_details_rating_value;
68 GtkWidget *label_details_rating_title;
69+ GtkWidget *box_not_sandboxed_warning;
70 };
71
72 G_DEFINE_TYPE (GsDetailsPage, gs_details_page, GS_TYPE_PAGE)
73@@ -964,6 +965,18 @@ gs_details_page_refresh_all (GsDetailsPage *self)
74 break;
75 }
76
77+ /* Display a warning about non-sandboxed apps that may come
78+ * from third party sources. Currently only checking snaps. */
79+ ret = FALSE;
80+ switch (gs_app_get_bundle_kind (self->app)) {
81+ case AS_BUNDLE_KIND_SNAP:
82+ ret |= (kudos & GS_APP_KUDO_SANDBOXED) == 0;
83+ break;
84+ default:
85+ break;
86+ }
87+ gtk_widget_set_visible (self->box_not_sandboxed_warning, ret);
88+
89 /* are we trying to replace something in the baseos */
90 gtk_widget_set_visible (self->infobar_details_package_baseos,
91 gs_app_has_quirk (self->app, AS_APP_QUIRK_COMPULSORY) &&
92@@ -2351,6 +2364,7 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
93 gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_content_rating_none);
94 gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, button_details_rating_value);
95 gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, label_details_rating_title);
96+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_not_sandboxed_warning);
97 }
98
99 static void
100diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
101index f1f1bd4..7d8cec5 100644
102--- a/src/gs-details-page.ui
103+++ b/src/gs-details-page.ui
104@@ -601,6 +601,46 @@
105 </packing>
106 </child>
107 <child>
108+ <object class="GtkBox" id="box_not_sandboxed_warning">
109+ <property name="visible">False</property>
110+ <property name="can_focus">False</property>
111+ <property name="spacing">30</property>
112+ <child>
113+ <object class="GtkImage" id="image_not_sandboxed_image_icon">
114+ <property name="visible">True</property>
115+ <property name="can_focus">False</property>
116+ <property name="pixel_size">16</property>
117+ <property name="icon_name">dialog-warning</property>
118+ <property name="icon_size">6</property>
119+ </object>
120+ <packing>
121+ <property name="expand">False</property>
122+ <property name="fill">True</property>
123+ <property name="position">0</property>
124+ </packing>
125+ </child>
126+ <child>
127+ <object class="GtkLabel" id="label_not_sandboxed_warning">
128+ <property name="visible">True</property>
129+ <property name="can_focus">False</property>
130+ <property name="label" translatable="yes">This third party package is not sandboxed. It will have access to your documents.</property>
131+ <property name="xalign">0</property>
132+ <property name="yalign">0.5</property>
133+ </object>
134+ <packing>
135+ <property name="expand">True</property>
136+ <property name="fill">True</property>
137+ <property name="position">1</property>
138+ </packing>
139+ </child>
140+ </object>
141+ <packing>
142+ <property name="expand">True</property>
143+ <property name="fill">True</property>
144+ <property name="position">12</property>
145+ </packing>
146+ </child>
147+ <child>
148 <object class="GtkBox" id="box_details_details">
149 <property name="visible">True</property>
150 <property name="can_focus">False</property>
151@@ -1135,7 +1175,7 @@
152 <packing>
153 <property name="expand">False</property>
154 <property name="fill">True</property>
155- <property name="position">12</property>
156+ <property name="position">13</property>
157 </packing>
158 </child>
159 <child>
160@@ -1198,7 +1238,7 @@
161 <packing>
162 <property name="expand">False</property>
163 <property name="fill">True</property>
164- <property name="position">13</property>
165+ <property name="position">15</property>
166 </packing>
167 </child>
168 <child>

Subscribers

People subscribed via source and target branches

to all changes: