[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCHv3 virt-viewer 04/12] kiosk: add app kiosk option, pass it down to window



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 | 13 +++++++++++++
 src/virt-viewer-window.h |  1 +
 5 files changed, 77 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 bb502bc..875b172 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) {
@@ -663,6 +670,7 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
         return window;
 
     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);
@@ -1256,6 +1264,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)
 {
@@ -1300,6 +1315,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);
     }
@@ -1345,6 +1364,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);
     }
@@ -1412,6 +1435,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)
@@ -1520,6 +1544,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;
 }
@@ -1627,6 +1652,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),
@@ -2104,6 +2139,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..247505a 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,18 @@ virt_viewer_window_get_display(VirtViewerWindow *self)
     return self->priv->display;
 }
 
+void
+virt_viewer_window_set_kiosk(VirtViewerWindow *self, gboolean enabled)
+{
+    g_return_if_fail(VIRT_VIEWER_IS_WINDOW(self));
+    g_return_if_fail(enabled == !!enabled);
+
+    if (self->priv->kiosk == enabled)
+        return;
+
+    self->priv->kiosk = enabled;
+}
+
 /*
  * Local variables:
  *  c-indent-level: 4
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
index 5066dbf..4639708 100644
--- a/src/virt-viewer-window.h
+++ b/src/virt-viewer-window.h
@@ -77,6 +77,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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]