[virt-tools-list] [PATCHv2 virt-viewer 02/10] kiosk: add app kiosk option, pass it down to window

Marc-André Lureau marcandre.lureau at gmail.com
Fri Aug 16 19:47:38 UTC 2013


See man page update for details.
---
 man/remote-viewer.pod    | 13 +++++++++++++
 man/virt-viewer.pod      | 13 +++++++++++++
 src/virt-viewer-app.c    | 37 +++++++++++++++++++++++++++++++++++++
 src/virt-viewer-window.c | 15 +++++++++++++++
 src/virt-viewer-window.h |  1 +
 5 files changed, 79 insertions(+)

diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index a4710c8..10fda2c 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -77,6 +77,19 @@ smartcard-remove. Examples:
 Note that hotkeys for which no binding is given are disabled, specifying an
 empty string disables all hotkeys.
 
+=item -k, --kiosk
+
+Start in kiosk mode. In this mode, the application will start in
+fullscreen with minimal UI. It will prevent the user from quitting or
+performing any interaction outside of usage of the remote desktop
+session.
+
+Note that it can't offer a complete secure solution by itself. Your
+kiosk system must have additional configuration and security settings
+to lock down the OS. In particular, you must configure or disable the
+window manager, limit the session capabilities, use some
+restart/watchdog mechanism, disable VT switching etc.
+
 =back
 
 =head1 HOTKEY
diff --git a/man/virt-viewer.pod b/man/virt-viewer.pod
index 9187c2e..9d0597a 100644
--- a/man/virt-viewer.pod
+++ b/man/virt-viewer.pod
@@ -86,6 +86,19 @@ smartcard-insert and smartcard-remove. Examples:
 Note that hotkeys for which no binding is given are disabled, specifying an
 empty string disables all hotkeys.
 
+=item -k, --kiosk
+
+Start in kiosk mode. In this mode, the application will start in
+fullscreen with minimal UI. It will prevent the user from quitting or
+performing any interaction outside of usage of the remote desktop
+session.
+
+Note that it can't offer a complete secure solution by itself. Your
+kiosk system must have additional configuration and security settings
+to lock down the OS. In particular, you must configure or disable the
+window manager, limit the session capabilities, use some
+restart/watchdog mechanism, disable VT switching etc.
+
 =back
 
 =head1 EXAMPLES
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 13c2565..226e3fc 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -119,6 +119,7 @@ struct _VirtViewerAppPrivate {
     gboolean fullscreen_auto_conf;
     gboolean attach;
     gboolean quiting;
+    gboolean kiosk;
 
     VirtViewerSession *session;
     gboolean active;
@@ -165,6 +166,7 @@ enum {
     PROP_ENABLE_ACCEL,
     PROP_HAS_FOCUS,
     PROP_FULLSCREEN_AUTO_CONF,
+    PROP_KIOSK,
 };
 
 enum {
@@ -251,6 +253,11 @@ virt_viewer_app_quit(VirtViewerApp *self)
     g_return_if_fail(VIRT_VIEWER_IS_APP(self));
     VirtViewerAppPrivate *priv = self->priv;
 
+    if (self->priv->kiosk) {
+        g_warning("The app is in kiosk mode and can't quit");
+        return;
+    }
+
     virt_viewer_app_save_config(self);
 
     if (priv->session) {
@@ -659,6 +666,7 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
     GtkWindow *w;
 
     window = g_object_new(VIRT_VIEWER_TYPE_WINDOW, "app", self, NULL);
+    virt_viewer_window_set_kiosk(window, self->priv->kiosk);
     if (self->priv->main_window)
         virt_viewer_window_set_zoom_level(window, virt_viewer_window_get_zoom_level(self->priv->main_window));
     virt_viewer_app_set_nth_window(self, nth, window);
@@ -1252,6 +1260,13 @@ static void virt_viewer_app_usb_failed(VirtViewerSession *session G_GNUC_UNUSED,
 }
 
 static void
+virt_viewer_app_set_kiosk(VirtViewerApp *self, gboolean enabled)
+{
+    self->priv->kiosk = enabled;
+}
+
+
+static void
 virt_viewer_app_get_property (GObject *object, guint property_id,
                               GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
 {
@@ -1296,6 +1311,10 @@ virt_viewer_app_get_property (GObject *object, guint property_id,
         g_value_set_boolean(value, virt_viewer_app_get_fullscreen_auto_conf(self));
         break;
 
+    case PROP_KIOSK:
+        g_value_set_boolean(value, priv->kiosk);
+        break;
+
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -1341,6 +1360,10 @@ virt_viewer_app_set_property (GObject *object, guint property_id,
         priv->fullscreen_auto_conf = g_value_get_boolean(value);
         break;
 
+    case PROP_KIOSK:
+        virt_viewer_app_set_kiosk(self, g_value_get_boolean(value));
+        break;
+
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -1408,6 +1431,7 @@ static gboolean opt_verbose = FALSE;
 static gboolean opt_debug = FALSE;
 static gboolean opt_fullscreen = FALSE;
 static gboolean opt_fullscreen_auto_conf = FALSE;
+static gboolean opt_kiosk = FALSE;
 
 static void
 virt_viewer_app_init (VirtViewerApp *self)
@@ -1516,6 +1540,7 @@ virt_viewer_app_constructor (GType gtype,
     virt_viewer_window_set_zoom_level(priv->main_window, opt_zoom);
     virt_viewer_app_set_fullscreen(self, opt_fullscreen);
     virt_viewer_app_set_hotkeys(self, opt_hotkeys);
+    virt_viewer_app_set_kiosk(self, opt_kiosk);
 
     return obj;
 }
@@ -1623,6 +1648,16 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
                                                          G_PARAM_READABLE |
                                                          G_PARAM_STATIC_STRINGS));
 
+    g_object_class_install_property(object_class,
+                                    PROP_KIOSK,
+                                    g_param_spec_boolean("kiosk",
+                                                         "Kiosk",
+                                                         "Kiosk mode",
+                                                         FALSE,
+                                                         G_PARAM_CONSTRUCT |
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_STATIC_STRINGS));
+
     signals[SIGNAL_WINDOW_ADDED] =
         g_signal_new("window-added",
                      G_OBJECT_CLASS_TYPE(object_class),
@@ -2100,6 +2135,8 @@ virt_viewer_app_get_options(void)
           N_("Open in full screen mode (auto-conf adjusts guest resolution to fit the client's)"), N_("<auto-conf>") },
         { "hotkeys", 'H', 0, G_OPTION_ARG_STRING, &opt_hotkeys,
           N_("Customise hotkeys"), NULL },
+        { "kiosk", 'k', 0, G_OPTION_ARG_NONE, &opt_kiosk,
+          N_("Enable kiosk mode"), NULL },
         { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose,
           N_("Display verbose information"), NULL },
         { "debug", '\0', 0, G_OPTION_ARG_NONE, &opt_debug,
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 193c431..f0fb9c2 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -98,6 +98,7 @@ struct _VirtViewerWindowPrivate {
     gboolean grabbed;
     gint fullscreen_monitor;
     gboolean desktop_resize_pending;
+    gboolean kiosk;
 
     gint zoomlevel;
     gboolean auto_resize;
@@ -1337,6 +1338,20 @@ virt_viewer_window_get_display(VirtViewerWindow *self)
     return self->priv->display;
 }
 
+void
+virt_viewer_window_set_kiosk(VirtViewerWindow *self, gboolean enabled)
+{
+    if (self->priv->kiosk == enabled)
+        return;
+
+    self->priv->kiosk = enabled;
+
+    if (enabled)
+        virt_viewer_window_enable_kiosk(self);
+    else
+        g_debug("disabling kiosk not implemented yet");
+}
+
 /*
  * Local variables:
  *  c-indent-level: 4
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
index 41ac5e2..33cf8f4 100644
--- a/src/virt-viewer-window.h
+++ b/src/virt-viewer-window.h
@@ -74,6 +74,7 @@ void virt_viewer_window_leave_fullscreen(VirtViewerWindow *self);
 void virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor);
 GtkMenuItem *virt_viewer_window_get_menu_displays(VirtViewerWindow *self);
 GtkBuilder* virt_viewer_window_get_builder(VirtViewerWindow *window);
+void virt_viewer_window_set_kiosk(VirtViewerWindow *self, gboolean enabled);
 
 G_END_DECLS
 
-- 
1.8.3.rc1.49.g8d97506




More information about the virt-tools-list mailing list