19033N/A/*
19033N/A * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
19033N/A *
19033N/A * Permission is hereby granted, free of charge, to any person obtaining a
19033N/A * copy of this software and associated documentation files (the "Software"),
19033N/A * to deal in the Software without restriction, including without limitation
19033N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19033N/A * and/or sell copies of the Software, and to permit persons to whom the
19033N/A * Software is furnished to do so, subject to the following conditions:
19033N/A *
19033N/A * The above copyright notice and this permission notice (including the next
19033N/A * paragraph) shall be included in all copies or substantial portions of the
19033N/A * Software.
19033N/A *
19033N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19033N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19033N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19033N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19033N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19033N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19033N/A * DEALINGS IN THE SOFTWARE.
19033N/A */
19033N/A
19033N/ASupport needed for Solaris Trusted Extensions / Trusted GNOME.
19033N/A---
19033N/A driver/Makefile.in | 21 +++--
19033N/A driver/demo-Gtk.c | 80 ++++++++++++++++++-
19033N/A driver/lock-Gtk.c | 6 +-
19033N/A driver/prefs.c | 43 ++++++++++-
19033N/A driver/subprocs.c | 25 ++++++
19033N/A driver/trusted-utils.c | 171 ++++++++++++++++++++++++++++++++++++++++
19033N/A driver/trusted-utils.h | 54 +++++++++++++
19033N/A driver/types.h | 2 +
19033N/A driver/xscreensaver-getimage.c | 3 +-
19033N/A driver/xscreensaver.c | 11 +++
19033N/A driver/xscreensaver.h | 2 +
19033N/A 11 files changed, 406 insertions(+), 12 deletions(-)
19033N/A create mode 100644 driver/trusted-utils.c
19033N/A create mode 100644 driver/trusted-utils.h
19033N/A
19033N/Adiff --git xscreensaver-5.12/driver/Makefile.in xscreensaver-5.12/driver/Makefile.in
19033N/A--- xscreensaver-5.12/driver/Makefile.in
19033N/A+++ xscreensaver-5.12/driver/Makefile.in
19033N/A@@ -105,6 +105,10 @@ GTK_OBJS = demo-Gtk.o demo-Gtk-conf.o @GTK_EXTRA_OBJS@
19117N/A GTK_LOCK_SRCS = lock-Gtk.c atoms.c remote.c
19117N/A GTK_LOCK_OBJS = lock-Gtk.o atoms.o remote.o
19033N/A
19033N/A+TRUSTED_LIBS = -lglib-2.0 -lsecdb
19033N/A+TRUSTED_SRCS = trusted-utils.c
19033N/A+TRUSTED_OBJS = trusted-utils.o
19033N/A+
19033N/A PWENT_SRCS = passwd-pwent.c
19033N/A PWENT_OBJS = passwd-pwent.o
19033N/A
19033N/A@@ -800,9 +804,9 @@ XScreenSaver_Xm_ad.h: XScreenSaver-Xm.ad
19033N/A
19033N/A # The executables linked in this directory.
19033N/A #
19033N/A-xscreensaver: $(SAVER_OBJS)
19033N/A- $(CC) $(LDFLAGS) -o $@ $(SAVER_OBJS) $(SAVER_LIBS) \
19033N/A- -lgconf-2 -lgobject-2.0
19033N/A+xscreensaver: $(SAVER_OBJS) $(TRUSTED_OBJS)
19033N/A+ $(CC) $(LDFLAGS) -o $@ $(SAVER_OBJS) $(TRUSTED_OBJS) \
19033N/A+ $(TRUSTED_LIBS) $(SAVER_LIBS) -lgconf-2 -lgobject-2.0
19033N/A
19033N/A xscreensaver-command: $(CMD_OBJS)
19033N/A $(CC) $(LDFLAGS) -o $@ $(CMD_OBJS) $(CMD_LIBS)
19033N/A@@ -821,8 +825,9 @@ xscreensaver-demo: @PREFERRED_DEMO_PROGRAM@
19033N/A xscreensaver-lock: @PREFERRED_LOCK_PROGRAM@
19033N/A $(INSTALL_PROGRAM) @PREFERRED_LOCK_PROGRAM@ $@
19033N/A
19033N/A-xscreensaver-lock-Gtk: $(GTK_LOCK_OBJS)
19033N/A+xscreensaver-lock-Gtk: $(GTK_LOCK_OBJS) $(TRUSTED_OBJS)
19033N/A $(CC) $(LDFLAGS) -o $@ $(GTK_LOCK_OBJS) $(LIBS) $(X_LIBS) \
19033N/A+ $(TRUSTED_OBJS) $(TRUSTED_LIBS) \
19033N/A $(GTK_LIBS) $(XML_LIBS) $(X_PRE_LIBS) -lXt -lX11 \
19033N/A $(XDPMS_LIBS) -lXext \
19033N/A $(X_EXTRA_LIBS)
19033N/A@@ -832,9 +837,9 @@ xscreensaver-demo-Xm: $(DEMO_OBJS) $(MOTIF_OBJS)
19033N/A $(MOTIF_LIBS) $(INTL_LIBS) $(X_PRE_LIBS) -lXt -lX11 \
19033N/A $(XDPMS_LIBS) $(XINERAMA_LIBS) -lXext $(X_EXTRA_LIBS)
19033N/A
19033N/A-xscreensaver-demo-Gtk: $(DEMO_OBJS) $(GTK_OBJS)
19033N/A- $(CC) $(LDFLAGS) -o $@ $(DEMO_OBJS) $(GTK_OBJS) $(LIBS) $(X_LIBS) \
19033N/A- $(GTK_LIBS) $(XPM_LIBS) $(XML_LIBS) $(INTL_LIBS) $(X_PRE_LIBS) \
19033N/A+xscreensaver-demo-Gtk: $(DEMO_OBJS) $(GTK_OBJS) $(TRUSTED_OBJS)
19033N/A+ $(CC) $(LDFLAGS) -o $@ $(DEMO_OBJS) $(GTK_OBJS) $(TRUSTED_OBJS) $(LIBS) $(X_LIBS) \
19033N/A+ $(GTK_LIBS) $(XPM_LIBS) $(XML_LIBS) $(INTL_LIBS) $(TRUSTED_LIBS) $(X_PRE_LIBS) \
19033N/A -lXt -lX11 $(XDPMS_LIBS) $(XINERAMA_LIBS) -lXext $(X_EXTRA_LIBS)
19033N/A
19033N/A demo-Gtk.o: XScreenSaver_ad.h
19033N/A@@ -843,7 +848,7 @@ xscreensaver.o: XScreenSaver_ad.h
19033N/A xscreensaver-getimage.o: XScreenSaver_ad.h
19033N/A
19033N/A xscreensaver-getimage: $(GETIMG_OBJS)
19033N/A- $(CC) $(LDFLAGS) -o $@ $(GETIMG_OBJS) $(GETIMG_LIBS) -lm
19033N/A+ $(CC) $(LDFLAGS) -o $@ $(GETIMG_OBJS) $(TRUSTED_OBJS) $(GETIMG_LIBS) $(TRUSTED_LIBS) -lm
19033N/A
19033N/A pdf2jpeg: $(PDF2JPEG_OBJS)
19033N/A $(OBJCC) $(LDFLAGS) -o $@ $(PDF2JPEG_OBJS) $(PDF2JPEG_LIBS) -lm
19033N/Adiff --git xscreensaver-5.12/driver/demo-Gtk.c xscreensaver-5.12/driver/demo-Gtk.c
19033N/A--- xscreensaver-5.12/driver/demo-Gtk.c
19033N/A+++ xscreensaver-5.12/driver/demo-Gtk.c
19117N/A@@ -137,6 +137,14 @@
19033N/A #include <string.h>
19033N/A #include <ctype.h>
19033N/A
19033N/A+#include <user_attr.h>
19033N/A+
19033N/A+#include "trusted-utils.h"
19033N/A+void XTSOLgetWorkstationOwner(Display *, uid_t *);
19033N/A+static gboolean tsol_hack_initialized = False;
19033N/A+static gboolean tsol_multi_label_session = False;
19033N/A+extern Display *global_dpy;
19033N/A+
19033N/A #ifdef HAVE_GTK2
19033N/A enum {
19033N/A COL_ENABLED,
19117N/A@@ -2935,6 +2943,73 @@ populate_prefs_page (state *s)
19033N/A SENSITIZE ("fade_spinbutton", (fading_possible &&
19033N/A (p->fade_p || p->unfade_p)));
19033N/A
19033N/A+ tsol_multi_label_session = tsol_is_multi_label_session ();
19033N/A+ if (tsol_multi_label_session)
19033N/A+ {
19033N/A+ static int idletime = 0;
19033N/A+ if (!tsol_hack_initialized)
19033N/A+ {
19033N/A+ GtkWidget *doc_menu = name_to_widget(s,"doc_menu");
19033N/A+ GtkWidget *restart_menu = name_to_widget(s,"restart");
19033N/A+ GtkWidget *kill_menu = name_to_widget(s, "kill_menu");
19033N/A+ GtkWidget *lock_spinbutton = name_to_widget(s, "lock_spinbutton");
19033N/A+ GtkWidget *timeout_spinbutton = name_to_widget(s, "timeout_spinbutton");
19033N/A+ GtkWidget *lock_container = name_to_widget(s, "blanking_table");
19033N/A+ GtkWidget *lock_button_eventbox = name_to_widget(s, "lock_button_eventbox");
19033N/A+ Widget *newlabel = g_object_new(GTK_TYPE_LABEL, "label",
19033N/A+ _("_Lock Screen After"),
19033N/A+ "use-underline", TRUE,
19033N/A+ "mnemonic-widget", lock_spinbutton,
19033N/A+ NULL);
19033N/A+ GValue *gv = g_new0(GValue, 1);
19033N/A+ GtkAdjustment *adj;
19033N/A+ userattr_t *uent;
19033N/A+
19033N/A+ char *value = NULL;
19033N/A+ uid_t WorkstationOwner;
19033N/A+ Display *dpy = GDK_DISPLAY();
19033N/A+
19033N/A+ gtk_widget_hide(doc_menu);
19033N/A+ gtk_widget_set_sensitive(restart_menu, FALSE);
19033N/A+ gtk_widget_set_sensitive (kill_menu, FALSE);
19033N/A+
19033N/A+ XTSOLgetWorkstationOwner(dpy, &WorkstationOwner);
19033N/A+ uent = getuseruid(WorkstationOwner);
19033N/A+ value = getusrattrval(uent, USERATTR_IDLETIME_KW);
19033N/A+ if (value != NULL)
19033N/A+ {
19033N/A+ idletime = atoi(value);
19033N/A+ if (idletime)
19033N/A+ {
19033N/A+ adj = gtk_spin_button_get_adjustment((GtkSpinButton *)timeout_spinbutton);
19033N/A+ SET_ADJ_UPPER (adj, (gdouble)idletime);
19033N/A+ if (GET_ADJ_VALUE (adj) > (gdouble)idletime)
19033N/A+ SET_ADJ_VALUE (adj, (gdouble)idletime);
19033N/A+ gtk_spin_button_set_adjustment((GtkSpinButton *)timeout_spinbutton, adj);
19033N/A+ }
19033N/A+ }
19033N/A+
19033N/A+ gtk_container_add(GTK_CONTAINER(lock_container), GTK_WIDGET(newlabel));
19033N/A+ g_value_init(gv, G_TYPE_INT);
19033N/A+ g_value_set_int(gv, 2);
19033N/A+ gtk_container_child_set_property(GTK_CONTAINER(lock_container), GTK_WIDGET(newlabel), "top_attach", gv);
19033N/A+ g_value_set_int(gv, 1);
19033N/A+ gtk_container_child_set_property(GTK_CONTAINER(lock_container), GTK_WIDGET(newlabel), "left_attach", gv);
19033N/A+ gtk_widget_show(GTK_WIDGET(newlabel));
19033N/A+ gtk_widget_hide(GTK_WIDGET(lock_button_eventbox));
19033N/A+ g_object_set(lock_button_eventbox, "active", TRUE, NULL);
19033N/A+
19033N/A+ tsol_hack_initialized = True;
19033N/A+ }
19033N/A+
19033N/A+ if (idletime)
19033N/A+ {
19033N/A+ SENSITIZE ("lock_spinbutton", 0);
19033N/A+ SENSITIZE ("lock_mlabel", 0);
19033N/A+ SENSITIZE ("lock_button", 0);
19033N/A+ }
19033N/A+ }
19033N/A+
19033N/A # undef SENSITIZE
19033N/A }
19033N/A }
19117N/A@@ -3022,6 +3097,9 @@ sensitize_menu_items (state *s, Bool force_p)
19033N/A
19033N/A for (i = 0; i < countof(names); i++)
19033N/A {
19033N/A+ if (tsol_is_multi_label_session() && 2==i)
19033N/A+ continue;
19033N/A+
19033N/A GtkWidget *w = name_to_widget (s, names[i]);
19033N/A gtk_widget_set_sensitive (GTK_WIDGET(w), running_p);
19033N/A }
19117N/A@@ -4991,7 +5069,7 @@ main (int argc, char **argv)
19033N/A applicationShellWidgetClass,
19033N/A dpy, 0, 0);
19033N/A
19033N/A- dpy = XtDisplay (toplevel_shell);
19033N/A+ global_dpy = dpy = XtDisplay (toplevel_shell);
19033N/A db = XtDatabase (dpy);
19033N/A XtGetApplicationNameAndClass (dpy, &progname, &progclass);
19033N/A XSetErrorHandler (demo_ehandler);
19033N/Adiff --git xscreensaver-5.12/driver/lock-Gtk.c xscreensaver-5.12/driver/lock-Gtk.c
19033N/A--- xscreensaver-5.12/driver/lock-Gtk.c
19033N/A+++ xscreensaver-5.12/driver/lock-Gtk.c
19117N/A@@ -72,6 +72,7 @@
19033N/A
19033N/A #include "remote.h"
19117N/A #include "atoms.h"
19033N/A+#include "trusted-utils.h"
19033N/A
19033N/A #if GTK_CHECK_VERSION(2,14,0)
19033N/A # define GET_WINDOW(w) gtk_widget_get_window (w)
19117N/A@@ -151,7 +152,10 @@ load_unlock_logo_image (void)
19033N/A const char *logofile;
19033N/A struct stat statbuf;
19033N/A
19033N/A- logofile = DEFAULT_ICONDIR "/unlock-logo.png";
19033N/A+ if (tsol_is_multi_label_session())
19033N/A+ logofile = DEFAULT_ICONDIR "/trusted-logo.png";
19033N/A+ else
19033N/A+ logofile = DEFAULT_ICONDIR "/unlock-logo.png";
19033N/A
19033N/A if (stat (logofile, &statbuf) != 0)
19033N/A {
19033N/Adiff --git xscreensaver-5.12/driver/prefs.c xscreensaver-5.12/driver/prefs.c
19033N/A--- xscreensaver-5.12/driver/prefs.c
19033N/A+++ xscreensaver-5.12/driver/prefs.c
19033N/A@@ -37,6 +37,8 @@
19033N/A # include "vms-pwd.h"
19033N/A #endif /* VMS */
19033N/A
19033N/A+#include "trusted-utils.h"
19033N/A+#include <user_attr.h>
19033N/A
19033N/A /* This file doesn't need the Xt headers, so stub these types out... */
19033N/A #undef XtPointer
19033N/A@@ -67,6 +69,9 @@
19033N/A #include "prefs.h"
19033N/A #include "resources.h"
19033N/A
19033N/A+#include "trusted-utils.h"
19033N/A+Display *global_dpy;
19033N/A+
19033N/A /* don't use realpath() on fedora system */
19033N/A #ifdef _FORTIFY_SOURCE
19033N/A #undef HAVE_REALPATH
19033N/A@@ -1046,7 +1051,10 @@ load_init_file (Display *dpy, saver_preferences *p)
19033N/A p->xsync_p = get_boolean_resource (dpy, "synchronous", "Synchronous");
19033N/A p->verbose_p = get_boolean_resource (dpy, "verbose", "Boolean");
19033N/A p->timestamp_p = get_boolean_resource (dpy, "timestamp", "Boolean");
19033N/A- p->lock_p = get_boolean_resource (dpy, "lock", "Boolean");
19033N/A+ if (tsol_is_multi_label_session())
19033N/A+ p->lock_p = True; /* always lock in a Multi Label Session */
19033N/A+ else
19033N/A+ p->lock_p = get_boolean_resource (dpy, "lock", "Boolean");
19033N/A p->fade_p = get_boolean_resource (dpy, "fade", "Boolean");
19033N/A p->unfade_p = get_boolean_resource (dpy, "unfade", "Boolean");
19033N/A p->fade_seconds = 1000 * get_seconds_resource (dpy, "fadeSeconds", "Time");
19033N/A@@ -1070,6 +1078,7 @@ load_init_file (Display *dpy, saver_preferences *p)
19033N/A p->lock_timeout = 1000 * get_minutes_resource (dpy, "lockTimeout", "Time");
19033N/A p->cycle = 1000 * get_minutes_resource (dpy, "cycle", "Time");
19033N/A p->passwd_timeout = 1000 * get_seconds_resource (dpy, "passwdTimeout", "Time");
19033N/A+
19033N/A /* bugid 5077981 */
19033N/A p->unlock_timeout_p = get_boolean_resource (dpy, "passwdTimeoutEnabled", "Boolean");
19033N/A p->pointer_timeout = 1000 * get_seconds_resource (dpy, "pointerPollTime", "Time");
19033N/A@@ -1175,6 +1184,38 @@ load_init_file (Display *dpy, saver_preferences *p)
19033N/A if (s) free (s);
19033N/A }
19033N/A
19033N/A+ if (tsol_is_multi_label_session())
19033N/A+ {
19033N/A+ userattr_t *uent;
19033N/A+ int idletime;
19033N/A+ char *value = NULL;
19033N/A+ uid_t WorkstationOwner;
19033N/A+
19033N/A+ XTSOLgetWorkstationOwner (global_dpy, &WorkstationOwner);
19033N/A+ uent = getuseruid (WorkstationOwner);
19033N/A+ value = getusrattrval (uent, USERATTR_IDLETIME_KW);
19033N/A+ if (value != NULL)
19033N/A+ {
19033N/A+ idletime = atoi(value) * 60 * 1000;
19033N/A+ if (idletime)
19033N/A+ {
19033N/A+ p->lock_timeout = 0;
19033N/A+ if (p->timeout > idletime)
19033N/A+ p->timeout = idletime;
19033N/A+ }
19033N/A+ }
19033N/A+
19033N/A+ /* always lock or logout in a Multi Label Session */
19033N/A+ if (p->mode == DONT_BLANK)
19033N/A+ p->mode = BLANK_ONLY;
19033N/A+
19033N/A+ value = getusrattrval (uent, USERATTR_IDLECMD_KW);
19033N/A+ if (value && strcasecmp (value, USERATTR_IDLECMD_LOGOUT_KW) == 0)
19033N/A+ p->lock_cmd = LOGOUT_CMD;
19033N/A+ else
19033N/A+ p->lock_cmd = LOCK_CMD;
19033N/A+ }
19033N/A+
19033N/A if (system_default_screenhack_count) /* note: first_time is also true */
19033N/A {
19033N/A merge_system_screenhacks (dpy, p, system_default_screenhacks,
19033N/Adiff --git xscreensaver-5.12/driver/subprocs.c xscreensaver-5.12/driver/subprocs.c
19033N/A--- xscreensaver-5.12/driver/subprocs.c
19033N/A+++ xscreensaver-5.12/driver/subprocs.c
19033N/A@@ -70,6 +70,7 @@ extern int kill (pid_t, int); /* signal() is in sys/signal.h... */
19033N/A #include "exec.h"
19033N/A #include "yarandom.h"
19033N/A #include "visual.h" /* for id_to_visual() */
19033N/A+#include "trusted-utils.h"
19033N/A
19033N/A extern saver_info *global_si_kludge; /* I hate C so much... */
19033N/A
19033N/A@@ -932,6 +933,30 @@ check_if_hacks_dir_exists(Bool verbose_p)
19033N/A }
19033N/A }
19033N/A
19033N/A+/* Added separate function for logout as we need to find better way to log user
19033N/A+ out. See CR6422890. For s10 we will use /usr/bin/gnome-session-save --kill
19033N/A+*/
19033N/A+void
19033N/A+logout(saver_screen_info *ssi)
19033N/A+{
19033N/A+ saver_info *si = ssi->global;
19033N/A+ saver_preferences *p = &si->prefs;
19033N/A+ if (p->lock_cmd == LOGOUT_CMD && !(si->emergency_lock_p || si->locked_p))
19033N/A+ {
19033N/A+ struct stat st;
19033N/A+ if (!stat ("/usr/bin/gnome-session-save", &st))
19033N/A+ {
19033N/A+ pid_t forked = fork_and_exec (ssi, "/usr/bin/gnome-session-save\t--force-logout");
19033N/A+ if (forked < 1)
19033N/A+ {
19033N/A+ char buf [255];
19033N/A+ snprintf (buf, sizeof(buf), "%s: couldn't fork", blurb());
19033N/A+ perror (buf);
19033N/A+ }
19033N/A+ }
19033N/A+ }
19033N/A+}
19033N/A+
19033N/A void
19033N/A spawn_screenhack (saver_screen_info *ssi)
19033N/A {
19033N/Adiff --git xscreensaver-5.12/driver/trusted-utils.c xscreensaver-5.12/driver/trusted-utils.c
19033N/Anew file mode 100644
19033N/A--- /dev/null
19033N/A+++ xscreensaver-5.12/driver/trusted-utils.c
19033N/A@@ -0,0 +1,171 @@
19033N/A+/*
19033N/A+ * Trusted xscreensaver
19033N/A+ *
19033N/A+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
19033N/A+ *
19033N/A+ * Permission is hereby granted, free of charge, to any person obtaining a
19033N/A+ * copy of this software and associated documentation files (the "Software"),
19033N/A+ * to deal in the Software without restriction, including without limitation
19033N/A+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19033N/A+ * and/or sell copies of the Software, and to permit persons to whom the
19033N/A+ * Software is furnished to do so, subject to the following conditions:
19033N/A+ *
19033N/A+ * The above copyright notice and this permission notice (including the next
19033N/A+ * paragraph) shall be included in all copies or substantial portions of the
19033N/A+ * Software.
19033N/A+ *
19033N/A+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19033N/A+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19033N/A+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19033N/A+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19033N/A+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19033N/A+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19033N/A+ * DEALINGS IN THE SOFTWARE.
19033N/A+ *
19033N/A+ *
19033N/A+ * Based on work by Erwann Chenede, Ghee Teo
19033N/A+ *
19033N/A+ * Used to check if we are in a multilabel session and to load
19033N/A+ * additional functionality within the multilabel session.
19033N/A+ */
19033N/A+#include <dlfcn.h>
19033N/A+#include <link.h>
19033N/A+#include <stdlib.h>
19033N/A+#include <user_attr.h>
19033N/A+#include <sys/types.h>
19033N/A+#include <unistd.h>
19033N/A+#include <strings.h>
19033N/A+#include <stdio.h>
19033N/A+#include "trusted-utils.h"
19033N/A+
19033N/A+/*
19033N/A+ * Checks for Multi label session
19033N/A+ */
19033N/A+gboolean
19033N/A+tsol_is_multi_label_session (void)
19033N/A+{
19033N/A+ static char *session = NULL;
19033N/A+
19033N/A+ if (!session)
19033N/A+ session = (char *)getenv("TRUSTED_SESSION");
19033N/A+
19033N/A+ if (!session)
19033N/A+ return FALSE;
19033N/A+
19033N/A+ return TRUE;
19033N/A+}
19033N/A+
19033N/A+/*
19033N/A+ * dynamicly load the libxtsol library
19033N/A+ */
19033N/A+static
19033N/A+void * dlopen_xtsol (void)
19033N/A+{
19033N/A+ void *handle = NULL;
19033N/A+
19033N/A+ if ((handle = dlopen ("/usr/lib/libXtsol.so.1", RTLD_LAZY)) != NULL)
19033N/A+ return handle;
19033N/A+ if ((handle = dlopen ("/usr/openwin/lib/libXtsol.so.1", RTLD_LAZY)) != NULL)
19033N/A+ return handle;
19033N/A+
19033N/A+ return handle;
19033N/A+}
19033N/A+
19033N/A+/*
19033N/A+ * dynamicly load the libDtTsol library
19033N/A+ */
19033N/A+static
19033N/A+void * dlopen_gnometsol (void)
19033N/A+{
19033N/A+ void *handle = NULL;
19033N/A+
19033N/A+ if ((handle = dlopen ("/usr/lib/libgnometsol.so", RTLD_LAZY)) != NULL)
19033N/A+ return handle;
19033N/A+
19033N/A+ return handle;
19033N/A+}
19033N/A+
19033N/A+xtsol_XTSOLgetWorkstationOwner libxtsol_XTSOLgetWorkstationOwner = NULL;
19033N/A+
19033N/A+void
19033N/A+XTSOLgetWorkstationOwner(Display *dpy, uid_t *WorkstationOwner)
19033N/A+{
19033N/A+ static gpointer xtsol_handle = NULL;
19033N/A+ static gboolean _xtsol_initialized = FALSE;
19033N/A+
19033N/A+ if ( ! _xtsol_initialized )
19033N/A+ {
19033N/A+ _xtsol_initialized = TRUE;
19033N/A+ xtsol_handle = dlopen_xtsol ();
19033N/A+ if (xtsol_handle != NULL)
19033N/A+ libxtsol_XTSOLgetWorkstationOwner
19033N/A+ = (xtsol_XTSOLgetWorkstationOwner) dlsym(xtsol_handle,
19033N/A+ "XTSOLgetWorkstationOwner");
19033N/A+ }
19033N/A+
19033N/A+ if (libxtsol_XTSOLgetWorkstationOwner == NULL)
19033N/A+ *WorkstationOwner = getuid();
19033N/A+ else
19033N/A+ libxtsol_XTSOLgetWorkstationOwner(dpy, WorkstationOwner);
19033N/A+}
19033N/A+
19033N/A+xtsol_XTSOLMakeTPWindow libxtsol_XTSOLMakeTPWindow = NULL;
19033N/A+
19033N/A+void
19033N/A+XTSOLMakeTPWindow(Display *dpy, Window w)
19033N/A+{
19033N/A+ static gpointer xtsol_handle = NULL;
19033N/A+ static gboolean _xtsol_initialized = FALSE;
19033N/A+
19033N/A+ if ( ! _xtsol_initialized )
19033N/A+ {
19033N/A+ _xtsol_initialized = TRUE;
19033N/A+ xtsol_handle = dlopen_xtsol ();
19033N/A+ if (xtsol_handle != NULL)
19033N/A+ libxtsol_XTSOLMakeTPWindow
19033N/A+ = (xtsol_XTSOLMakeTPWindow) dlsym(xtsol_handle,
19033N/A+ "XTSOLMakeTPWindow");
19033N/A+ }
19033N/A+
19033N/A+ if (libxtsol_XTSOLMakeTPWindow)
19033N/A+ {
19033N/A+ libxtsol_XTSOLMakeTPWindow(dpy, w);
19033N/A+ }
19033N/A+}
19033N/A+
19033N/A+gnome_tsol_get_usrattr_val libgnome_tsol_get_usrattr_val = NULL;
19033N/A+
19033N/A+/*
19033N/A+ * Returns a value from uattr for the given key.
19033N/A+ * If there is no value in user_attr, then it returns the
19033N/A+ * system wide default from policy.conf or labelencodings
19033N/A+ * as appropriate.
19033N/A+ */
19033N/A+char *
19033N/A+getusrattrval(userattr_t *uattr, char *keywd)
19033N/A+{
19033N/A+ static gpointer gnometsol_handle = NULL;
19033N/A+ static gboolean _gnometsol_initialized = FALSE;
19033N/A+ char *value;
19033N/A+
19033N/A+ if ( ! _gnometsol_initialized )
19033N/A+ {
19033N/A+ _gnometsol_initialized = TRUE;
19033N/A+ gnometsol_handle = dlopen_gnometsol ();
19033N/A+ if (gnometsol_handle != NULL)
19033N/A+ libgnome_tsol_get_usrattr_val
19033N/A+ = (gnome_tsol_get_usrattr_val) dlsym(gnometsol_handle,
19033N/A+ "gnome_tsol_get_usrattr_val");
19033N/A+ }
19033N/A+
19033N/A+ if (libgnome_tsol_get_usrattr_val == NULL)
19033N/A+ {
19033N/A+ if (strcmp(keywd, USERATTR_IDLETIME_KW) == 0)
19033N/A+ value = strdup("15");
19033N/A+ else if (strcmp(keywd, USERATTR_IDLECMD_KW) == 0)
19033N/A+ value = strdup(USERATTR_IDLECMD_LOCK_KW);
19033N/A+ } else
19033N/A+ value = libgnome_tsol_get_usrattr_val(uattr, keywd);
19033N/A+
19033N/A+ return ( value );
19033N/A+}
19033N/Adiff --git xscreensaver-5.12/driver/trusted-utils.h xscreensaver-5.12/driver/trusted-utils.h
19033N/Anew file mode 100644
19033N/A--- /dev/null
19033N/A+++ xscreensaver-5.12/driver/trusted-utils.h
19033N/A@@ -0,0 +1,54 @@
19033N/A+/*
19033N/A+ * Trusted xscreensaver
19033N/A+ *
19033N/A+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
19033N/A+ *
19033N/A+ * Permission is hereby granted, free of charge, to any person obtaining a
19033N/A+ * copy of this software and associated documentation files (the "Software"),
19033N/A+ * to deal in the Software without restriction, including without limitation
19033N/A+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19033N/A+ * and/or sell copies of the Software, and to permit persons to whom the
19033N/A+ * Software is furnished to do so, subject to the following conditions:
19033N/A+ *
19033N/A+ * The above copyright notice and this permission notice (including the next
19033N/A+ * paragraph) shall be included in all copies or substantial portions of the
19033N/A+ * Software.
19033N/A+ *
19033N/A+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19033N/A+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19033N/A+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19033N/A+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19033N/A+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19033N/A+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19033N/A+ * DEALINGS IN THE SOFTWARE.
19033N/A+ *
19033N/A+ * Based on work by Erwann Chenede, Ghee Teo
19033N/A+ *
19033N/A+ * Definitions for the trusted functions.
19033N/A+ */
19033N/A+#ifndef TRUSTED_XSCREENSAVER_H
19033N/A+#define TRUSTED_XSCREENSAVER_H
19033N/A+
19033N/A+#ifdef HAVE_XTSOL
19033N/A+#include <X11/extensions/Xtsol.h>
19033N/A+#endif /* HAVE_XTSOL */
19033N/A+#include <user_attr.h>
19033N/A+#include <glib.h>
19033N/A+#include <X11/Xlib.h>
19033N/A+#include <sys/types.h>
19033N/A+#include <unistd.h>
19033N/A+
19033N/A+extern gboolean tsol_is_multi_label_session (void);
19033N/A+extern char *getusrattrval(userattr_t *, char *);
19033N/A+extern void XTSOLgetWorkstationOwner(Display *, uid_t *);
19033N/A+
19033N/A+typedef void (*xtsol_XTSOLgetWorkstationOwner) (Display *, uid_t *);
19033N/A+extern void XTSOLMakeTPWindow(Display *, Window);
19033N/A+typedef void (*xtsol_XTSOLMakeTPWindow) (Display *, Window);
19033N/A+typedef char *(*gnome_tsol_get_usrattr_val) (userattr_t *, char *);
19033N/A+
19033N/A+enum {
19033N/A+ LOCK_CMD = 0,
19033N/A+ LOGOUT_CMD
19033N/A+};
19033N/A+#endif /* TRUSTED_XSCREENSAVER_H */
19033N/Adiff --git xscreensaver-5.12/driver/types.h xscreensaver-5.12/driver/types.h
19033N/A--- xscreensaver-5.12/driver/types.h
19033N/A+++ xscreensaver-5.12/driver/types.h
19033N/A@@ -105,6 +105,8 @@ struct saver_preferences {
19033N/A Time initial_delay; /* how long to sleep after launch */
19033N/A Time splash_duration; /* how long the splash screen stays up */
19033N/A Time timeout; /* how much idle time before activation */
19033N/A+ int lock_cmd; /* tsol only - whether to lock or logout */
19033N/A+
19033N/A Time lock_timeout; /* how long after activation locking starts */
19033N/A Time cycle; /* how long each hack should run */
19033N/A Time passwd_timeout; /* how much time before pw dialog goes down */
19033N/Adiff --git xscreensaver-5.12/driver/xscreensaver-getimage.c xscreensaver-5.12/driver/xscreensaver-getimage.c
19033N/A--- xscreensaver-5.12/driver/xscreensaver-getimage.c
19033N/A+++ xscreensaver-5.12/driver/xscreensaver-getimage.c
19033N/A@@ -83,6 +83,7 @@ static char *defaults[] = {
19033N/A 0
19033N/A };
19033N/A
19033N/A+extern Display *global_dpy;
19033N/A
19033N/A
19033N/A char *progname = 0;
19033N/A@@ -1797,7 +1798,7 @@ main (int argc, char **argv)
19033N/A
19033N/A toplevel = XtAppInitialize (&app, progclass, 0, 0, &argc, argv,
19033N/A defaults, 0, 0);
19033N/A- dpy = XtDisplay (toplevel);
19033N/A+ global_dpy = dpy = XtDisplay (toplevel);
19033N/A screen = XtScreen (toplevel);
19033N/A db = XtDatabase (dpy);
19033N/A XtGetApplicationNameAndClass (dpy, &s, &progclass);
19033N/Adiff --git xscreensaver-5.12/driver/xscreensaver.c xscreensaver-5.12/driver/xscreensaver.c
19033N/A--- xscreensaver-5.12/driver/xscreensaver.c
19033N/A+++ xscreensaver-5.12/driver/xscreensaver.c
19033N/A@@ -142,6 +142,7 @@
19033N/A
19033N/A #include <stdio.h>
19033N/A #include <ctype.h>
19033N/A+#include <zone.h>
19033N/A #include <X11/Xlib.h>
19033N/A
19033N/A #ifdef ENABLE_NLS
19117N/A@@ -229,6 +230,9 @@
19033N/A #include "auth.h"
19117N/A #include "atoms.h"
19033N/A
19033N/A+#include "trusted-utils.h"
19033N/A+extern Display *global_dpy;
19033N/A+
19033N/A saver_info *global_si_kludge = 0; /* I hate C so much... */
19033N/A
19033N/A /* Globals */
19117N/A@@ -1183,6 +1187,9 @@ main_loop (saver_info *si)
19033N/A
19033N/A maybe_reload_init_file (si);
19033N/A
19033N/A+ if (tsol_is_multi_label_session())
19033N/A+ logout(&si->screens[0]);
19033N/A+
19033N/A if (p->mode == DONT_BLANK)
19033N/A {
19033N/A if (p->verbose_p)
19117N/A@@ -1459,6 +1466,9 @@ main (int argc, char **argv)
19033N/A struct passwd *spasswd;
19033N/A int i;
19033N/A
19033N/A+ if (tsol_is_multi_label_session () && (getzoneid () != 0))
19033N/A+ exit (1);
19033N/A+
19033N/A #ifdef ENABLE_NLS
19033N/A if (!setlocale (LC_ALL, ""))
19033N/A fprintf (stderr, "locale not supported by C library\n");
19117N/A@@ -1509,6 +1519,7 @@ main (int argc, char **argv)
19033N/A # endif /* !NO_LOCKING */
19033N/A
19033N/A shell = connect_to_server (si, &argc, argv);
19033N/A+ global_dpy = XtDisplay(shell);
19033N/A process_command_line (si, &argc, argv);
19033N/A stderr_log_file (si);
19033N/A print_banner (si);
19033N/Adiff --git xscreensaver-5.12/driver/xscreensaver.h xscreensaver-5.12/driver/xscreensaver.h
19033N/A--- xscreensaver-5.12/driver/xscreensaver.h
19033N/A+++ xscreensaver-5.12/driver/xscreensaver.h
19033N/A@@ -170,6 +170,8 @@ extern struct screenhack_job *make_job (pid_t pid, int screen,
19033N/A const char *cmd);
19033N/A #endif
19033N/A
19033N/A+extern void logout(saver_screen_info *ssi);
19033N/A+
19033N/A /* =======================================================================
19033N/A subprocs diagnostics
19033N/A ======================================================================= */
19033N/A