19033N/A/*
19033N/A * Copyright (c) 2002, 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/ASolaris uses the gtk unlock dialog program originally written by
19033N/AXimian & Wipro, in order to provide a dialog box that works with
19033N/Athe GNOME accessibility framework. This was done as a fork of
19033N/Athe original xscreensaver because the maintainer would not allow
19033N/Ause of a toolkit in the lock dialog - he has since softened his
19033N/Astance a bit, but this has not been presented to him to see if it
19033N/Ameets his requirements as spelled out at:
19033N/A http://www.jwz.org/xscreensaver/toolkits.html
19033N/A
19033N/AThis patch also contains a fixes for:
19033N/A
19033N/ASun bug 6541240
19033N/A Screen saver will lock user out of the system if they have no
19033N/A password set
19033N/A
19033N/ASun bug 5077993/GNOME Bug 147639:
19033N/A Gok cant automatically UI grab screensaver preferences
19033N/A http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=5077993
19033N/A http://bugzilla.gnome.org/show_bug.cgi?id=147639
19033N/A
19033N/ASun bug 5083155:
19033N/A Unable to unlock screen when running dual-head magnification
19033N/A http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=5083155
19033N/A
19033N/ASun bug 5059445:
19033N/A screen kb and screen reader support
19033N/A http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=5059445
19033N/A
19033N/ASun bug 5039878:
19033N/A "Password:" field should be focused / have flashing caret
19033N/A http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=5039878
19033N/A
19033N/ASun bug 6461887:
19033N/A GNOME screen lock does not prevent access to other applications
19033N/A via 'alt-tab'
19033N/A
19033N/ASun bug 6736157:
19033N/A [A11Y] Security problem when desktop a11y support is turned on.
19033N/A
19033N/ASun bug 6573182:
19033N/A after applying patch 120094-11 (or later), xscreensaver coredump
19033N/A http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6573182
19033N/A---
19033N/A config.h.in | 3 +
19033N/A configure.in | 23 +-
19117N/A driver/Makefile.in | 59 +++-
19033N/A driver/auth.h | 4 +
19033N/A driver/demo-Gtk.c | 18 +
19033N/A driver/dialog-data.h | 122 ++++++
20353N/A driver/lock-Gtk.c | 956 ++++++++++++++++++++++++++++++++++++++++++++
20353N/A driver/lock.c | 1069 ++++++++++++++++++++++++++++++++++++++++++++-----
19098N/A driver/passwd-pam.c | 207 +++++++++-
19033N/A driver/passwd.c | 1 +
19033N/A driver/setuid.c | 5 +-
19033N/A driver/subprocs.c | 35 ++-
19033N/A driver/timers.c | 114 ++++++-
19033N/A driver/types.h | 18 +
19033N/A driver/windows.c | 21 +-
19117N/A driver/xscreensaver.c | 131 ++++++-
19033N/A driver/xscreensaver.h | 6 +
19117N/A 17 files changed, 2654 insertions(+), 135 deletions(-)
19033N/A create mode 100644 driver/dialog-data.h
19033N/A create mode 100644 driver/lock-Gtk.c
19033N/A
19033N/Adiff --git xscreensaver-5.12/config.h.in xscreensaver-5.12/config.h.in
19033N/A--- xscreensaver-5.12/config.h.in
19033N/A+++ xscreensaver-5.12/config.h.in
19033N/A@@ -405,6 +405,9 @@
19033N/A make use of this if it is available. */
19033N/A #undef HAVE_XPM
19033N/A
19033N/A+/* Define this to build the external lock dialog */
19033N/A+#undef HAVE_XSCREENSAVER_LOCK
19033N/A+
19033N/A /* Define this if you have the X Shared Memory Extension. */
19033N/A #undef HAVE_XSHM_EXTENSION
19033N/A
19033N/Adiff --git xscreensaver-5.12/configure.in xscreensaver-5.12/configure.in
19033N/A--- xscreensaver-5.12/configure.in
19033N/A+++ xscreensaver-5.12/configure.in
19033N/A@@ -2527,6 +2527,8 @@ if test "$with_gtk" = yes; then
19033N/A pkg_check_version libglade-2.0 1.99.0
19033N/A pkg_check_version gdk-pixbuf-2.0 2.0.0
19033N/A pkg_check_version gdk-pixbuf-xlib-2.0 2.0.0
19033N/A+ pkg_check_version gconf-2.0 2.6.1
19033N/A+ pkg_check_version libloginhelper-1.0 1.0
19033N/A have_gtk="$ok"
19033N/A
19033N/A if test "$have_gtk" = no; then
19033N/A@@ -2542,6 +2544,9 @@ if test "$with_gtk" = yes; then
19033N/A fi
19033N/A
19033N/A if test "$have_gtk" = yes; then
19033N/A+#--- Begin SUNW addition
19033N/A+ AC_DEFINE(HAVE_XSCREENSAVER_LOCK,[],[Define this to build the external lock dialog])
19033N/A+#--- End SUNW addition
19033N/A AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
19033N/A [ac_cv_gtk_config_cflags=`$pkg_config --cflags $pkgs`])
19033N/A AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
19033N/A@@ -3626,6 +3631,16 @@ if test "$have_gtk" = yes; then
19033N/A ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
19033N/A fi
19033N/A
19033N/A+#--- Begin SUNW addition
19033N/A+PREFERRED_LOCK_PROGRAM=
19033N/A+ALL_LOCK_PROGRAMS=
19033N/A+LOCK_PROGRAM=
19033N/A+if test "$have_gtk" = yes; then
19033N/A+ PREFERRED_LOCK_PROGRAM=xscreensaver-lock-Gtk
19033N/A+ ALL_LOCK_PROGRAMS="$PREFERRED_LOCK_PROGRAM $ALL_LOCK_PROGRAMS"
19033N/A+ LOCK_PROGRAM=xscreensaver-lock
19033N/A+fi
19033N/A+#--- End SUNW addition
19033N/A
19033N/A if test "$have_kerberos" = yes; then
19033N/A PASSWD_SRCS="$PASSWD_SRCS \$(KERBEROS_SRCS)"
19033N/A@@ -3765,6 +3780,11 @@ AC_SUBST(INCLUDES)
19033N/A
19033N/A AC_SUBST(PREFERRED_DEMO_PROGRAM)
19033N/A AC_SUBST(ALL_DEMO_PROGRAMS)
19033N/A+#--- Begin SUNW addition
19033N/A+AC_SUBST(PREFERRED_LOCK_PROGRAM)
19033N/A+AC_SUBST(ALL_LOCK_PROGRAMS)
19033N/A+AC_SUBST(LOCK_PROGRAM)
19033N/A+#--- End SUNW addition
19033N/A AC_SUBST(SAVER_LIBS)
19033N/A AC_SUBST(MOTIF_LIBS)
19033N/A AC_SUBST(GTK_LIBS)
19033N/A@@ -4244,7 +4264,8 @@ HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
19033N/A
19033N/A
19033N/A # Sanity check the hackdir
19033N/A-for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command ; do
19033N/A+# SUNW addition: added xscreensaver-lock to list on next line
19033N/A+for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command xscreensaver-lock ; do
19033N/A if test "${HACKDIR}" = "${bindir}/${bad_choice}" ; then
19033N/A echo ""
19033N/A AC_MSG_ERROR([\"--with-hackdir=${bindir}/${bad_choice}\" won't work.
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@@ -29,6 +29,7 @@ GTK_APPDIR = $(GTK_DATADIR)/applications
19033N/A GTK_ICONDIR = $(GTK_DATADIR)/pixmaps
19033N/A GTK_GLADEDIR = $(prefix)/lib/xscreensaver/config
19033N/A HACK_CONF_DIR = @HACK_CONF_DIR@
19033N/A+LOCK_DIR = $(libexecdir)
19033N/A
19033N/A CC = @CC@
19033N/A OBJCC = @OBJCC@
19033N/A@@ -42,6 +43,7 @@ SUBP_DEFS = $(DEFS) -DHACK_PATH='"@HACKDIR@"' \
19033N/A GTK_DEFS = $(DEFS) -DDEFAULT_ICONDIR='"$(GTK_GLADEDIR)"' \
19033N/A -DBINDIR='"$(bindir)"'
19033N/A CONF_DEFS = -DHACK_CONFIGURATION_PATH='"$(HACK_CONF_DIR)"'
19033N/A+LOCK_DEFS = $(DEFS) -DLOCKDIR=\"$(LOCK_DIR)\"
19033N/A
19033N/A LIBS = @LIBS@
19033N/A INTL_LIBS = @INTLLIBS@
19033N/A@@ -100,6 +102,8 @@ GTK_SRCS = demo-Gtk.c demo-Gtk-conf.c \
19033N/A demo-Gtk-widgets.c demo-Gtk-support.c
19033N/A GTK_EXTRA_OBJS = demo-Gtk-widgets.o demo-Gtk-support.o
19033N/A 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 PWENT_SRCS = passwd-pwent.c
19033N/A PWENT_OBJS = passwd-pwent.o
19033N/A@@ -219,8 +223,8 @@ GETIMG_LIBS = $(LIBS) $(X_LIBS) $(XPM_LIBS) $(JPEG_LIBS) \
19033N/A $(X_PRE_LIBS) -lXt -lX11 $(XMU_LIBS) -lXext $(X_EXTRA_LIBS)
19033N/A
19033N/A EXES = xscreensaver xscreensaver-command xscreensaver-demo \
19033N/A- xscreensaver-getimage @EXES_OSX@
19033N/A-EXES2 = @ALL_DEMO_PROGRAMS@
19033N/A+ xscreensaver-getimage @EXES_OSX@ @LOCK_PROGRAM@
19033N/A+EXES2 = @ALL_DEMO_PROGRAMS@ @ALL_LOCK_PROGRAMS@
19033N/A EXES_OSX = pdf2jpeg
19033N/A
19033N/A SCRIPTS_1 = xscreensaver-getimage-file xscreensaver-getimage-video \
19033N/A@@ -250,7 +254,7 @@ VMSFILES = compile_axp.com compile_decc.com link_axp.com link_decc.com \
19033N/A vms-getpwnam.c vms-pwd.h vms-hpwd.c vms-validate.c \
19033N/A vms_axp.opt vms_axp_12.opt vms_decc.opt vms_decc_12.opt
19033N/A
19033N/A-TARFILES = $(EXTRAS) $(VMSFILES) $(SAVER_SRCS_1) \
19033N/A+TARFILES = $(EXTRAS) $(VMSFILES) $(SAVER_SRCS_1) $(GTK_LOCK_SRCS) \
19033N/A $(MOTIF_SRCS) $(GTK_SRCS) $(PWENT_SRCS) $(PWHELPER_SRCS) \
19033N/A $(KERBEROS_SRCS) $(PAM_SRCS) $(LOCK_SRCS_1) $(DEMO_SRCS_1) \
19033N/A $(CMD_SRCS) $(GETIMG_SRCS_1) $(PDF2JPEG_SRCS) $(HDRS) \
19033N/A@@ -263,7 +267,7 @@ all: $(EXES) $(EXES2)
19033N/A tests: $(TEST_EXES)
19033N/A
19033N/A install: install-program install-ad install-scripts \
19033N/A- install-gnome install-man install-xml install-pam
19033N/A+ install-gnome install-man install-xml
19033N/A uninstall: uninstall-program uninstall-ad \
19033N/A uninstall-gnome uninstall-man uninstall-xml
19033N/A
19033N/A@@ -275,6 +279,9 @@ install-program: $(EXES)
19033N/A @if [ ! -d $(install_prefix)$(bindir) ]; then \
19033N/A $(INSTALL_DIRS) $(install_prefix)$(bindir) ; \
19033N/A fi
19033N/A+ @if [ -n "@LOCK_PROGRAM@" -a ! -d $(install_prefix)$(LOCK_DIR) ]; then \
19033N/A+ $(INSTALL_DIRS) $(install_prefix)$(LOCK_DIR) ; \
19033N/A+ fi
19033N/A @inst="$(INSTALL_PROGRAM)" ; \
19033N/A if [ @NEED_SETUID@ = yes ]; then \
19033N/A me=`PATH="$$PATH:/usr/ucb" whoami` ; \
19033N/A@@ -303,6 +310,12 @@ install-program: $(EXES)
19033N/A echo $(INSTALL_PROGRAM) $$exe $(install_prefix)$(bindir)/$$exe ; \
19033N/A $(INSTALL_PROGRAM) $$exe $(install_prefix)$(bindir)/$$exe ; \
19033N/A done
19033N/A+ @if [ -n "@LOCK_PROGRAM@" ]; then \
19033N/A+ echo $(INSTALL_PROGRAM) xscreensaver-lock \
19033N/A+ $(install_prefix)$(LOCK_DIR)/xscreensaver-lock ; \
19033N/A+ $(INSTALL_PROGRAM) xscreensaver-lock \
19033N/A+ $(install_prefix)$(LOCK_DIR)/xscreensaver-lock ; \
19033N/A+ fi
19033N/A
19033N/A install-ad: XScreenSaver.ad
19033N/A @if [ ! -d $(install_prefix)$(AD_DIR) ]; then \
19033N/A@@ -738,7 +751,7 @@ $(SAVER_UTIL_OBJS):
19033N/A
19033N/A # How we build object files in this directory.
19033N/A .c.o:
19033N/A- $(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $(X_CFLAGS) $<
19033N/A+ $(CC) -c $(INCLUDES) $(DEFS) $(INTL_DEFS) $(CFLAGS) $(X_CFLAGS) $<
19033N/A
19033N/A .m.o:
19033N/A $(OBJCC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $(X_CFLAGS) $<
19033N/A@@ -764,6 +777,16 @@ demo-Gtk-conf.o: demo-Gtk-conf.c
19033N/A $(CC) -c $(INCLUDES) $(CONF_DEFS) $(GTK_DEFS) $(CFLAGS) $(X_CFLAGS) \
19033N/A $(srcdir)/demo-Gtk-conf.c
19033N/A
19033N/A+# lock takes an extra -D option.
19033N/A+lock.o:
19033N/A+ $(CC) -c $(INCLUDES) $(LOCK_DEFS) $(CFLAGS) $(X_CFLAGS) \
19033N/A+ $(srcdir)/lock.c
19033N/A+
19033N/A+# lock-Gtk takes extra -D and -I options.
19033N/A+lock-Gtk.o: lock-Gtk.c
19033N/A+ $(CC) -c $(INCLUDES) -I$(ICON_SRC) $(GTK_DEFS) \
19033N/A+ $(CFLAGS) $(X_CFLAGS) $(INTL_DEFS) \
19033N/A+ $(srcdir)/lock-Gtk.c
19033N/A
19033N/A # How we build the default app-defaults file into the program.
19033N/A #
19033N/A@@ -778,7 +801,8 @@ XScreenSaver_Xm_ad.h: XScreenSaver-Xm.ad
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+ $(CC) $(LDFLAGS) -o $@ $(SAVER_OBJS) $(SAVER_LIBS) \
19033N/A+ -lgconf-2 -lgobject-2.0
19033N/A
19033N/A xscreensaver-command: $(CMD_OBJS)
19033N/A $(CC) $(LDFLAGS) -o $@ $(CMD_OBJS) $(CMD_LIBS)
19033N/A@@ -794,6 +818,15 @@ xscreensaver-demo: @PREFERRED_DEMO_PROGRAM@
19033N/A cp -p @PREFERRED_DEMO_PROGRAM@@EXEEXT@ $@@EXEEXT@ ; \
19033N/A fi
19033N/A
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+ $(CC) $(LDFLAGS) -o $@ $(GTK_LOCK_OBJS) $(LIBS) $(X_LIBS) \
19033N/A+ $(GTK_LIBS) $(XML_LIBS) $(X_PRE_LIBS) -lXt -lX11 \
19033N/A+ $(XDPMS_LIBS) -lXext \
19033N/A+ $(X_EXTRA_LIBS)
19033N/A+
19033N/A xscreensaver-demo-Xm: $(DEMO_OBJS) $(MOTIF_OBJS)
19033N/A $(CC) $(LDFLAGS) -o $@ $(DEMO_OBJS) $(MOTIF_OBJS) $(LIBS) $(X_LIBS) \
19033N/A $(MOTIF_LIBS) $(INTL_LIBS) $(X_PRE_LIBS) -lXt -lX11 \
19033N/A@@ -817,7 +850,7 @@ pdf2jpeg: $(PDF2JPEG_OBJS)
19033N/A
19033N/A
19033N/A TEST_PASSWD_OBJS = test-passwd.o $(LOCK_OBJS_1) $(PASSWD_OBJS) \
19033N/A- subprocs.o setuid.o splash.o prefs.o mlstring.o exec.o \
19033N/A+ subprocs.o setuid.o splash.o prefs.o mlstring.o \
19033N/A $(SAVER_UTIL_OBJS)
19033N/A test-passwd.o: XScreenSaver_ad.h
19033N/A
19117N/A@@ -907,8 +940,14 @@ dpms.o: $(srcdir)/types.h
19117N/A dpms.o: $(srcdir)/xscreensaver.h
19117N/A exec.o: ../config.h
19117N/A exec.o: $(srcdir)/exec.h
19117N/A+lock-Gtk.o: $(srcdir)/atoms.h
19117N/A+lock-Gtk.o: ../config.h
19117N/A+lock-Gtk.o: $(srcdir)/remote.h
19117N/A+lock-Gtk.o: $(UTILS_SRC)/xscreensaver-intl.h
19117N/A lock.o: $(srcdir)/auth.h
19117N/A lock.o: ../config.h
19117N/A+lock.o: $(srcdir)/dialog-data.h
19117N/A+lock.o: $(srcdir)/exec.h
19117N/A lock.o: $(srcdir)/mlstring.h
19117N/A lock.o: $(srcdir)/prefs.h
19117N/A lock.o: $(srcdir)/types.h
19117N/A@@ -917,6 +956,8 @@ lock.o: $(srcdir)/xscreensaver.h
19117N/A mlstring.o: $(srcdir)/mlstring.h
19117N/A passwd.o: $(srcdir)/auth.h
19117N/A passwd.o: ../config.h
19117N/A+passwd.o: $(srcdir)/dialog-data.h
19117N/A+passwd.o: $(srcdir)/mlstring.h
19117N/A passwd.o: $(srcdir)/prefs.h
19117N/A passwd.o: $(srcdir)/types.h
19117N/A passwd.o: $(srcdir)/xscreensaver.h
19117N/A@@ -984,6 +1025,8 @@ test-vp.o: ../config.h
19117N/A test-xdpms.o: ../config.h
19117N/A test-xinerama.o: ../config.h
19117N/A timers.o: ../config.h
19117N/A+timers.o: $(srcdir)/dialog-data.h
19117N/A+timers.o: $(srcdir)/mlstring.h
19117N/A timers.o: $(srcdir)/prefs.h
19117N/A timers.o: $(srcdir)/types.h
19117N/A timers.o: $(srcdir)/xscreensaver.h
19117N/A@@ -1011,6 +1054,8 @@ xscreensaver-getimage.o: $(UTILS_SRC)/yarandom.h
19117N/A xscreensaver.o: XScreenSaver_ad.h
19117N/A xscreensaver.o: $(srcdir)/auth.h
19117N/A xscreensaver.o: ../config.h
19117N/A+xscreensaver.o: $(srcdir)/dialog-data.h
19117N/A+xscreensaver.o: $(srcdir)/mlstring.h
19117N/A xscreensaver.o: $(srcdir)/prefs.h
19117N/A xscreensaver.o: $(srcdir)/types.h
19117N/A xscreensaver.o: $(UTILS_SRC)/resources.h
19033N/Adiff --git xscreensaver-5.12/driver/auth.h xscreensaver-5.12/driver/auth.h
19033N/A--- xscreensaver-5.12/driver/auth.h
19033N/A+++ xscreensaver-5.12/driver/auth.h
19033N/A@@ -51,4 +51,8 @@ xss_authenticate(saver_info *si, Bool verbose_p);
19033N/A void
19033N/A auth_finished_cb (saver_info *si);
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+extern int write_to_child (saver_info* si, const char* cmd, const char *msg);
19033N/A+#endif
19033N/A+
19033N/A #endif
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
19033N/A@@ -98,6 +98,8 @@
19033N/A # define G_MODULE_EXPORT /**/
19033N/A #endif /* !HAVE_GTK2 */
19033N/A
19033N/A+#include <gconf/gconf-client.h>
19033N/A+
19033N/A #if defined(DEFAULT_ICONDIR) && !defined(GLADE_DIR)
19033N/A # define GLADE_DIR DEFAULT_ICONDIR
19033N/A #endif
19117N/A@@ -5006,6 +5008,22 @@ main (int argc, char **argv)
19033N/A load_init_file (dpy, p);
19033N/A initialize_sort_map (s);
19033N/A
19033N/A+ /* Bug 147639: Gok cant automatically UI grab screensaver preferences */
19033N/A+ {
19033N/A+ GConfClient *client = gconf_client_get_default ();
19033N/A+
19033N/A+#define KEY "/desktop/gnome/interface/accessibility"
19033N/A+
19033N/A+ /* check if accessibilty mode is enabled */
19033N/A+ if (gconf_client_get_bool (client, KEY, NULL))
19033N/A+ {
19033N/A+ /* GTK Accessibility Module initialized */
19033N/A+ const char *modulesptr = g_getenv ("GTK_MODULES");
19033N/A+ if (!modulesptr || (modulesptr [0] == '\0'))
19033N/A+ putenv ("GTK_MODULES=gail:atk-bridge");
19033N/A+ }
19033N/A+ }
19033N/A+
19033N/A /* Now that Xt has been initialized, and the resources have been read,
19033N/A we can set our `progname' variable to something more in line with
19033N/A reality.
19033N/Adiff --git xscreensaver-5.12/driver/dialog-data.h xscreensaver-5.12/driver/dialog-data.h
19033N/Anew file mode 100644
19033N/A--- /dev/null
19033N/A+++ xscreensaver-5.12/driver/dialog-data.h
19033N/A@@ -0,0 +1,122 @@
19033N/A+/* xscreensaver, Copyright (c) 1993-2008 Jamie Zawinski <jwz@jwz.org>
19033N/A+ *
19033N/A+ * Permission to use, copy, modify, distribute, and sell this software and its
19033N/A+ * documentation for any purpose is hereby granted without fee, provided that
19033N/A+ * the above copyright notice appear in all copies and that both that
19033N/A+ * copyright notice and this permission notice appear in supporting
19033N/A+ * documentation. No representations are made about the suitability of this
19033N/A+ * software for any purpose. It is provided "as is" without express or
19033N/A+ * implied warranty.
19033N/A+ */
19033N/A+
19033N/A+#ifndef __DIALOG_DATA_H__
19033N/A+#define __DIALOG_DATA_H__
19033N/A+
19033N/A+#include <stdio.h>
19033N/A+#include "types.h"
19033N/A+#include "mlstring.h"
19033N/A+
19033N/A+struct passwd_dialog_data {
19033N/A+
19033N/A+ saver_screen_info *prompt_screen;
19033N/A+ int previous_mouse_x, previous_mouse_y;
19033N/A+
19033N/A+ char typed_passwd [80];
19033N/A+
19033N/A+ XtIntervalId timer;
19033N/A+ int i_beam;
19033N/A+
19033N/A+ float ratio;
19033N/A+ Position x, y;
19033N/A+ Dimension width;
19033N/A+ Dimension height;
19033N/A+ Dimension border_width;
19033N/A+
19033N/A+ Bool echo_input;
19033N/A+ Bool show_stars_p; /* "I regret that I have but one asterisk for my country."
19033N/A+ -- Nathan Hale, 1776. */
19033N/A+
19033N/A+ char *heading_label;
19033N/A+ char *body_label;
19033N/A+ char *user_label;
19033N/A+ mlstring *info_label;
19033N/A+ /* The entry field shall only be displayed if prompt_label is not NULL */
19033N/A+ mlstring *prompt_label;
19033N/A+ char *date_label;
19033N/A+ char *passwd_string;
19033N/A+ Bool passwd_changed_p; /* Whether the user entry field needs redrawing */
19033N/A+ Bool caps_p; /* Whether we saw a keypress with caps-lock on */
19033N/A+ char *unlock_label;
19033N/A+ char *login_label;
19033N/A+ char *uname_label;
19033N/A+
19033N/A+ Bool show_uname_p;
19033N/A+
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A+ XFontStruct *heading_font;
19033N/A+ XFontStruct *body_font;
19033N/A+ XFontStruct *label_font;
19033N/A+ XFontStruct *passwd_font;
19033N/A+ XFontStruct *date_font;
19033N/A+ XFontStruct *button_font;
19033N/A+ XFontStruct *uname_font;
19033N/A+
19033N/A+ Pixel foreground;
19033N/A+ Pixel background;
19033N/A+ Pixel passwd_foreground;
19033N/A+ Pixel passwd_background;
19033N/A+ Pixel thermo_foreground;
19033N/A+ Pixel thermo_background;
19033N/A+ Pixel shadow_top;
19033N/A+ Pixel shadow_bottom;
19033N/A+ Pixel button_foreground;
19033N/A+ Pixel button_background;
19033N/A+
19033N/A+ Dimension preferred_logo_width, logo_width;
19033N/A+ Dimension preferred_logo_height, logo_height;
19033N/A+ Dimension thermo_width;
19033N/A+ Dimension internal_border;
19033N/A+ Dimension shadow_width;
19033N/A+
19033N/A+ Dimension passwd_field_x, passwd_field_y;
19033N/A+ Dimension passwd_field_width, passwd_field_height;
19033N/A+
19033N/A+ Dimension unlock_button_x, unlock_button_y;
19033N/A+ Dimension unlock_button_width, unlock_button_height;
19033N/A+
19033N/A+ Dimension login_button_x, login_button_y;
19033N/A+ Dimension login_button_width, login_button_height;
19033N/A+
19033N/A+ Dimension thermo_field_x, thermo_field_y;
19033N/A+ Dimension thermo_field_height;
19033N/A+
19033N/A+ Pixmap logo_pixmap;
19033N/A+ Pixmap logo_clipmask;
19033N/A+ int logo_npixels;
19033N/A+ unsigned long *logo_pixels;
19033N/A+#endif /* ! HAVE_XSCREENSAVER_LOCK */
19033N/A+
19033N/A+ Cursor passwd_cursor;
19033N/A+ Bool unlock_button_down_p;
19033N/A+ Bool login_button_down_p;
19033N/A+ Bool login_button_p;
19033N/A+ Bool login_button_enabled_p;
19033N/A+ Bool button_state_changed_p; /* Refers to both buttons */
19033N/A+
19033N/A+ Pixmap save_under;
19033N/A+ Pixmap user_entry_pixmap;
19033N/A+
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* extern passwd dialog stuff */
19033N/A+ XtInputId stdout_input_id;
19033N/A+ int stdin_fd; /* child's stdin - parent writes to this */
19033N/A+ int stdout_fd; /* child's stdout - parent reads from this */
19033N/A+ FILE *stdin_file; /* child's stdin - parent writes to this */
19033N/A+ FILE *stdout_file; /* child's stdout - parent reads from this */
19033N/A+ Bool got_windowid;
19033N/A+ Bool got_passwd;
19033N/A+#endif
19033N/A+};
19033N/A+
19033N/A+#endif /* __DIALOG_DATA_H__ */
19033N/A+
19033N/Adiff --git xscreensaver-5.12/driver/lock-Gtk.c xscreensaver-5.12/driver/lock-Gtk.c
19033N/Anew file mode 100644
19033N/A--- /dev/null
19033N/A+++ xscreensaver-5.12/driver/lock-Gtk.c
20353N/A@@ -0,0 +1,956 @@
19033N/A+/* lock-Gtk.c -- a GTK+ password dialog for xscreensaver
19033N/A+ * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski <jwz@jwz.org>
19033N/A+ *
19033N/A+ * Permission to use, copy, modify, distribute, and sell this software and its
19033N/A+ * documentation for any purpose is hereby granted without fee, provided that
19033N/A+ * the above copyright notice appear in all copies and that both that
19033N/A+ * copyright notice and this permission notice appear in supporting
19033N/A+ * documentation. No representations are made about the suitability of this
19033N/A+ * software for any purpose. It is provided "as is" without express or
19033N/A+ * implied warranty.
19033N/A+ */
19033N/A+
19033N/A+/* GTK+ locking code written by Jacob Berkman <jacob@ximian.com> for
19033N/A+ * Sun Microsystems.
19033N/A+ *
19033N/A+ * Copyright (c) 2002, 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+#ifdef HAVE_CONFIG_H
19033N/A+# include "config.h"
19033N/A+#endif
19033N/A+
19033N/A+#ifdef HAVE_GTK2 /* whole file */
19033N/A+
19033N/A+#include <xscreensaver-intl.h>
19033N/A+
19033N/A+#include <unistd.h>
19033N/A+#include <errno.h>
19033N/A+#include <string.h>
19033N/A+#include <time.h>
19033N/A+#include <stdlib.h>
19033N/A+#include <stdio.h>
19033N/A+#include <fcntl.h>
19033N/A+#include <sys/types.h>
19033N/A+#include <sys/stat.h>
19033N/A+
19033N/A+#include <gtk/gtk.h>
19033N/A+#include <gdk/gdkx.h>
19033N/A+
19033N/A+/* AT-enabled */
19033N/A+#include <stdio.h>
19033N/A+#include <ctype.h>
19033N/A+#include <X11/Xos.h>
19033N/A+#include <X11/Xlib.h>
19033N/A+#include <X11/Xatom.h>
19033N/A+#include <X11/Xutil.h>
19033N/A+#include <X11/Xmu/WinUtil.h>
19033N/A+
19033N/A+#include <gconf/gconf-client.h>
19033N/A+#include <libbonobo.h>
19033N/A+#include <login-helper/Accessibility_LoginHelper.h>
19033N/A+#include <atk/atkobject.h>
19033N/A+
19033N/A+#include "remote.h"
19117N/A+#include "atoms.h"
19033N/A+
19033N/A+#if GTK_CHECK_VERSION(2,14,0)
19033N/A+# define GET_WINDOW(w) gtk_widget_get_window (w)
19033N/A+#else
19033N/A+# define GET_WINDOW(w) ((w)->window)
19033N/A+#endif
19033N/A+
19033N/A+static Atom XA_UNLOCK_RATIO;
19033N/A+
19033N/A+typedef struct {
19033N/A+ GtkWidget *dialog;
19033N/A+ GtkWidget *user_prompt_label;
19033N/A+ GtkWidget *user_input_entry;
19033N/A+ GtkWidget *progress;
19033N/A+ GtkWidget *button;
19033N/A+ GtkWidget *msg_label;
19033N/A+ GtkWidget *pam_message_label;
19033N/A+} PasswdDialog;
19033N/A+
19033N/A+/*Global info */
19033N/A+#define MAXRAISEDWINS 2
19033N/A+
19033N/A+char *progname = 0;
19033N/A+FILE *parent_file = NULL; /* child writes to parent on this */
19033N/A+
19033N/A+#define FD_TO_PARENT 9
19033N/A+
19033N/A+/* Send a command to the xscreensaver parent daemon
19033N/A+ Arguments:
19033N/A+ - msg - type of message - "input", "raise_wid", etc.
19033N/A+ - data - data for message
19033N/A+ - flush - whether to flush now or allow stdio to buffer
19033N/A+ Message format sent to parent:
19033N/A+ "msg\n" if no data, otherwise "msg=data\n"
19033N/A+
19033N/A+ Can be used to flush previously buffered messages by calling
19033N/A+ with NULL msg & data, and TRUE for flush.
19033N/A+ */
19033N/A+static int
19033N/A+write_to_parent (const char* msg, const char *data, gboolean flush)
19033N/A+{
19033N/A+ int len = 0;
19033N/A+
19033N/A+ /*
19033N/A+ fprintf (stderr, "-->Child write_to_parent() string to send is: %s=%s\n",
19033N/A+ msg, data ? data : "(null)");
19033N/A+ fflush (stderr);
19033N/A+ */
19033N/A+
19033N/A+ if (msg)
19033N/A+ {
19033N/A+ if (data)
19033N/A+ len = fprintf (parent_file, "%s=%s\n", msg, data);
19033N/A+ else
19033N/A+ len = fprintf (parent_file, "%s\n", msg);
19033N/A+ }
19033N/A+
19033N/A+ if (flush)
19033N/A+ fflush (parent_file);
19033N/A+
19033N/A+ return len;
19033N/A+}
19033N/A+
19033N/A+/* Send parent a message with a window id as the data */
19033N/A+static void
19033N/A+write_windowid (const char* msg, Window w)
19033N/A+{
19033N/A+ char s[16]; /* more than long enough to hold a 32-bit integer + '\0' */
19033N/A+
19033N/A+ snprintf(s, sizeof(s), "0x%lx", w);
19033N/A+ write_to_parent(msg, s, FALSE);
19033N/A+}
19033N/A+
19033N/A+static GtkWidget *
19033N/A+load_unlock_logo_image (void)
19033N/A+{
19033N/A+ const char *logofile;
19033N/A+ struct stat statbuf;
19033N/A+
19033N/A+ logofile = DEFAULT_ICONDIR "/unlock-logo.png";
19033N/A+
19033N/A+ if (stat (logofile, &statbuf) != 0)
19033N/A+ {
19033N/A+ logofile = DEFAULT_ICONDIR "/logo-180.gif"; /* fallback */
19033N/A+ }
19033N/A+
19033N/A+ return gtk_image_new_from_file (logofile);
19033N/A+}
19033N/A+
19033N/A+/* Create unlock dialog */
19033N/A+static PasswdDialog *
19033N/A+make_dialog (gboolean center_pos)
19033N/A+{
19033N/A+ GtkWidget *dialog;
19033N/A+ AtkObject *atk_dialog;
19033N/A+ GtkWidget *frame1, *frame2;
19033N/A+ GtkWidget *vbox;
19033N/A+ GtkWidget *hbox1, *hbox2;
19033N/A+ GtkWidget *bbox;
19033N/A+ GtkWidget *vbox2;
19033N/A+ GtkWidget *entry;
19033N/A+ AtkObject *atk_entry;
19033N/A+ GtkWidget *title_label, *msg_label, *prompt_label,
19033N/A+ *user_label, *date_label, *pam_msg_label;
19033N/A+ AtkObject *atk_title_label, *atk_prompt_label;
19033N/A+ GtkWidget *button;
19033N/A+ GtkWidget *image;
19033N/A+ GtkWidget *progress;
19033N/A+ char *version;
19033N/A+ char *user;
19033N/A+ char *host;
19033N/A+ char *s;
19033N/A+ gchar *format_string_locale, *format_string_utf8;
19033N/A+ PasswdDialog *pwd;
19033N/A+
19033N/A+ /* taken from lock.c */
19033N/A+ char buf[256];
19033N/A+ gchar *utf8_format;
19033N/A+ time_t now = time (NULL);
19033N/A+ struct tm* tm;
19033N/A+
19033N/A+ server_xscreensaver_version (GDK_DISPLAY (), &version, &user, &host);
19033N/A+
19033N/A+ if (!version)
19033N/A+ {
19033N/A+ fprintf (stderr, "%s: no xscreensaver running on display %s, exiting.\n",
19033N/A+ progname, gdk_get_display ());
19033N/A+ exit (1);
19033N/A+ }
19033N/A+
19033N/A+ /* PUSH */
19033N/A+ gtk_widget_push_colormap (gdk_rgb_get_cmap ());
19033N/A+
19033N/A+ pwd = g_new0 (PasswdDialog, 1);
19033N/A+
19033N/A+ dialog = gtk_window_new (GTK_WINDOW_POPUP);
19033N/A+ pwd->dialog = dialog;
19033N/A+
19033N/A+ /*
19033N/A+ ** bugid: 5077989(P2)Bug 147580: password input dialogue obscures GOK
19033N/A+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
19033N/A+ bugid: 5002244: scr unlock dialog incompatible with MAG technique
19033N/A+ ** 6182506: scr dialog is obscured by MAG window
19033N/A+ */
19033N/A+ if (center_pos)
19033N/A+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
19033N/A+ else
19033N/A+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
19033N/A+
19033N/A+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); /*mali99 irritating*/
19033N/A+
19033N/A+ /* AT-enabled dialog role = frame */
19033N/A+ atk_dialog = gtk_widget_get_accessible (dialog);
19033N/A+ atk_object_set_description (atk_dialog, _("screen unlock dialog"));
19033N/A+
19033N/A+ /* frame */
19033N/A+ frame1 = g_object_new (GTK_TYPE_FRAME,
19033N/A+ "shadow", GTK_SHADOW_OUT,
19033N/A+ NULL);
19033N/A+ gtk_container_add (GTK_CONTAINER (dialog), frame1);
19033N/A+ /* AT role = panel */
19033N/A+
19033N/A+ /* vbox */
19033N/A+ vbox = gtk_vbox_new (FALSE, 10);
19033N/A+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
19033N/A+ gtk_container_add (GTK_CONTAINER (frame1), vbox);
19033N/A+ /* AT role= filler(default) */
19033N/A+
19033N/A+ /* hbox */
19033N/A+ hbox1 = gtk_hbox_new (FALSE, 5);
19033N/A+ gtk_box_pack_start (GTK_BOX (vbox), hbox1,
19033N/A+ TRUE, TRUE, 0);
19033N/A+
19033N/A+ /* image frame */
19033N/A+ frame2 = g_object_new (GTK_TYPE_FRAME,
19033N/A+ "shadow", GTK_SHADOW_ETCHED_IN,
19033N/A+ NULL);
19033N/A+ gtk_box_pack_start (GTK_BOX (hbox1), frame2,
19033N/A+ TRUE, TRUE, 0);
19033N/A+ /* AT role= filler(default) */
19033N/A+
19033N/A+ /* image */
19033N/A+ image = load_unlock_logo_image ();
19033N/A+ /* AT role = icon */
19033N/A+ gtk_container_add (GTK_CONTAINER (frame2), image);
19033N/A+
19033N/A+ /* progress thingie */
19033N/A+ progress = g_object_new (GTK_TYPE_PROGRESS_BAR,
19033N/A+ "orientation", GTK_PROGRESS_BOTTOM_TO_TOP,
19033N/A+ "fraction", 1.0,
19033N/A+ NULL);
19033N/A+ gtk_box_pack_start (GTK_BOX (hbox1), progress,
19033N/A+ FALSE, FALSE, 0);
19033N/A+ pwd->progress = progress;
19033N/A+ atk_object_set_description (gtk_widget_get_accessible (progress),
19033N/A+ _("Percent of time you have left to unlock the screen."));
19033N/A+
19033N/A+ /* text fields */
19033N/A+ vbox2 = gtk_vbox_new (FALSE, 20);
19033N/A+ gtk_box_pack_start (GTK_BOX (hbox1), vbox2,
19033N/A+ TRUE, TRUE, 0);
19033N/A+ /* AT role =filler */
19033N/A+
19033N/A+ s = g_markup_printf_escaped ("<span size=\"xx-large\"><b>%s </b></span>",
19033N/A+ _("Screensaver"));
19033N/A+ /* XScreenSaver foo label */
19033N/A+ title_label = g_object_new (GTK_TYPE_LABEL,
19033N/A+ "use-markup", TRUE,
19033N/A+ "label", s,
19033N/A+ NULL);
19033N/A+ g_free (s);
19033N/A+ gtk_box_pack_start (GTK_BOX (vbox2), title_label,
19033N/A+ FALSE, FALSE, 0);
19033N/A+ /* AT role = label prog name */
19033N/A+ atk_title_label = gtk_widget_get_accessible (title_label);
19033N/A+ atk_object_add_relationship (atk_title_label, ATK_RELATION_LABEL_FOR,
19033N/A+ atk_dialog);
19033N/A+ atk_object_add_relationship (atk_dialog, ATK_RELATION_LABELLED_BY,
19033N/A+ atk_title_label);
19033N/A+
19033N/A+ /* This display is locked. */
19033N/A+ msg_label = g_object_new (GTK_TYPE_LABEL,
19033N/A+ "use-markup", TRUE,
19033N/A+ "label", _("<b>This display is locked.</b>"),
19033N/A+ NULL);
19033N/A+ pwd->msg_label = msg_label;
19033N/A+ gtk_box_pack_start (GTK_BOX (vbox2), msg_label,
19033N/A+ FALSE, FALSE, 0);
19033N/A+
19033N/A+ /* User information */
19033N/A+ s = g_strdup_printf (_("User: %s"), user ? user : "");
19033N/A+ user_label = g_object_new (GTK_TYPE_LABEL,
19033N/A+ "label", s,
19033N/A+ "use_underline", TRUE,
19033N/A+ NULL);
19033N/A+ g_free(s);
19033N/A+ gtk_label_set_width_chars (GTK_LABEL (user_label), 35);
19033N/A+ gtk_box_pack_start (GTK_BOX (vbox2), user_label, FALSE, FALSE, 0);
19033N/A+
19033N/A+ /* User input */
19033N/A+ hbox2 = gtk_widget_new (GTK_TYPE_HBOX,
19033N/A+ "border_width", 5,
19033N/A+ "visible", TRUE,
19033N/A+ "homogeneous", FALSE,
19033N/A+ "spacing", 1,
19033N/A+ NULL);
19033N/A+
19033N/A+ /* PAM prompt */
19033N/A+ prompt_label = g_object_new (GTK_TYPE_LABEL,
19033N/A+ /* blank space for prompt */
19033N/A+ "label", _(" "),
19033N/A+ "use_underline", TRUE,
19033N/A+ "use_markup", FALSE,
19033N/A+ "justify", GTK_JUSTIFY_CENTER,
19033N/A+ "wrap", FALSE,
20829N/A+ "selectable", FALSE,
19033N/A+ "xalign", 1.0,
19033N/A+ "xpad", 0,
19033N/A+ "ypad", 0,
19033N/A+ "visible", FALSE,
19033N/A+ NULL);
19033N/A+ pwd->user_prompt_label = prompt_label;
19033N/A+
19033N/A+ entry = g_object_new (GTK_TYPE_ENTRY,
19033N/A+ "activates-default", TRUE,
19033N/A+ "visible", TRUE,
19033N/A+ "editable", TRUE,
19033N/A+ "visibility", FALSE,
19033N/A+ "can_focus", TRUE,
19033N/A+ NULL);
19033N/A+ pwd->user_input_entry = entry;
19033N/A+ /* gtk_widget_grab_focus (entry); */
19033N/A+ atk_entry = gtk_widget_get_accessible (entry);
19033N/A+ atk_object_set_role (atk_entry, ATK_ROLE_PASSWORD_TEXT);
19033N/A+
19033N/A+ /* AT role = label for input widget */
19033N/A+ atk_prompt_label = gtk_widget_get_accessible (prompt_label);
19033N/A+ atk_object_add_relationship (atk_prompt_label, ATK_RELATION_LABEL_FOR,
19033N/A+ atk_entry);
19033N/A+ atk_object_add_relationship (atk_entry, ATK_RELATION_LABELLED_BY,
19033N/A+ atk_prompt_label);
19033N/A+
19033N/A+ gtk_box_pack_start (GTK_BOX (hbox2), prompt_label, FALSE, FALSE, 0);
19033N/A+ gtk_box_pack_end (GTK_BOX (hbox2), entry, TRUE, TRUE, 0);
19033N/A+ gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
19033N/A+
19033N/A+ pam_msg_label = g_object_new (GTK_TYPE_LABEL,
19033N/A+ NULL);
19033N/A+ pwd->pam_message_label = pam_msg_label;
19033N/A+
19033N/A+ gtk_box_pack_start (GTK_BOX (vbox2), pam_msg_label, FALSE, FALSE, 0);
19033N/A+
19033N/A+ /* date string */
19033N/A+ tm = localtime (&now);
19033N/A+ memset (buf, 0, sizeof (buf));
19033N/A+ format_string_utf8 = _("%d-%b-%y (%a); %I:%M %p");
19033N/A+ format_string_locale = g_locale_from_utf8 (format_string_utf8, -1,
19033N/A+ NULL, NULL, NULL);
19033N/A+ strftime (buf, sizeof (buf) - 1, format_string_locale, tm);
19033N/A+ g_free (format_string_locale);
19033N/A+
19033N/A+ utf8_format = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
19033N/A+ s = g_markup_printf_escaped ("<small>%s</small>", utf8_format);
19033N/A+ g_free (utf8_format);
19033N/A+
19033N/A+ date_label = g_object_new (GTK_TYPE_LABEL,
19033N/A+ "use-markup", TRUE,
19033N/A+ "label", s,
19033N/A+ NULL);
19033N/A+ g_free (s);
19033N/A+ gtk_box_pack_start (GTK_BOX (vbox2), date_label,
19033N/A+ FALSE, FALSE, 0);
19033N/A+
19033N/A+ /* button box */
19033N/A+ bbox = g_object_new (GTK_TYPE_HBUTTON_BOX,
19033N/A+ "layout-style", GTK_BUTTONBOX_END,
19033N/A+ "spacing", 10,
19033N/A+ NULL);
19033N/A+
19033N/A+ /* Ok button */
19033N/A+ button = gtk_button_new_from_stock (GTK_STOCK_OK);
19033N/A+ pwd->button = button;
19033N/A+
19033N/A+ gtk_box_pack_end (GTK_BOX (bbox), button,
19033N/A+ FALSE, TRUE, 0);
19033N/A+
19033N/A+ free (user);
19033N/A+ free (version);
19033N/A+ free (host);
19033N/A+
19033N/A+ /* POP */
19033N/A+ gtk_widget_pop_colormap ();
19033N/A+
19033N/A+ return pwd;
19033N/A+}
19033N/A+
19033N/A+/* Callback for when user has finished entering input, even though
19033N/A+ we don't display an "OK" button for them to click on */
19033N/A+static void
19033N/A+ok_clicked_cb (GtkWidget *button, PasswdDialog *pwd)
19033N/A+{
19033N/A+ const char *s;
19033N/A+
19033N/A+ g_object_set (pwd->msg_label, "label", _("<b>Checking...</b>"), NULL);
19033N/A+
19033N/A+ s = gtk_entry_get_text (GTK_ENTRY (pwd->user_input_entry));
19033N/A+ write_to_parent ("input", s, TRUE);
19033N/A+
19033N/A+ /* Reset password field to blank, else passwd field shows old passwd *'s,
19033N/A+ visible when passwd is expired, and pam is walking the user to change
19033N/A+ old passwd.
19033N/A+ */
19033N/A+ gtk_editable_delete_text (GTK_EDITABLE (pwd->user_input_entry), 0, -1);
19033N/A+ gtk_widget_hide (pwd->user_input_entry);
19033N/A+ gtk_widget_hide (pwd->user_prompt_label);
19033N/A+}
19033N/A+
19033N/A+static void
19033N/A+connect_signals (PasswdDialog *pwd)
19033N/A+{
19033N/A+ g_signal_connect (pwd->button, "clicked",
19033N/A+ G_CALLBACK (ok_clicked_cb),
19033N/A+ pwd);
19033N/A+
19033N/A+ g_signal_connect (pwd->user_input_entry, "activate",
19033N/A+ G_CALLBACK (ok_clicked_cb),
19033N/A+ pwd);
19033N/A+
19033N/A+ g_signal_connect (pwd->dialog, "delete-event",
19033N/A+ G_CALLBACK (gtk_main_quit),
19033N/A+ NULL);
19033N/A+}
19033N/A+
19033N/A+static GdkFilterReturn
19033N/A+dialog_filter_func (GdkXEvent *xevent, GdkEvent *gevent, gpointer data)
19033N/A+{
19033N/A+ PasswdDialog *pwd = data;
19033N/A+ XEvent *event = xevent;
19033N/A+ gdouble ratio;
19033N/A+
19033N/A+ if ((event->xany.type != ClientMessage ||
19033N/A+ event->xclient.message_type != XA_UNLOCK_RATIO))
19033N/A+ return GDK_FILTER_CONTINUE;
19033N/A+
19033N/A+ ratio = event->xclient.data.l[0] / (gdouble)100.0;
19033N/A+
19033N/A+ /* CR 6176524 passwdTimeoutEnable for disabled user */
19033N/A+ if (event->xclient.data.l[1] == 0)
19033N/A+ g_object_set (pwd->progress, "fraction", ratio, NULL);
19033N/A+
19033N/A+ return GDK_FILTER_REMOVE;
19033N/A+}
19033N/A+
19033N/A+static gboolean
19033N/A+handle_input (GIOChannel *source, GIOCondition cond, gpointer data)
19033N/A+{
19033N/A+ PasswdDialog *pwd = data;
19033N/A+ GIOStatus status;
19033N/A+ char *str;
19033N/A+ char *label;
19033N/A+ char *hmsg = NULL; /* This is the heading of lock dialog..shows status */
19033N/A+
19033N/A+ if (cond & G_IO_HUP) /* daemon crashed/exited/was killed */
19033N/A+ gtk_main_quit ();
19033N/A+
19033N/A+ do
19033N/A+ {
19033N/A+ status = g_io_channel_read_line (source, &str, NULL, NULL, NULL);
19033N/A+ }
19033N/A+ while (status == G_IO_STATUS_AGAIN);
19033N/A+
19033N/A+/* debug only
19033N/A+ if (status == G_IO_STATUS_ERROR)
19033N/A+ g_message ("handle input() status_error %s\n",str);
19033N/A+ if (status == G_IO_STATUS_EOF)
19033N/A+ g_message ("handle input() status_eof %s\n",str);
19033N/A+ if (status == G_IO_STATUS_NORMAL)
19033N/A+ g_message ("handle input() status_normal %s\n",str);
19033N/A+ Most likely, the returned error msg of g_io_channel_read_line(),
19033N/A+ i.e str will not be translated into other locales ...
19033N/A+*/
19033N/A+
19033N/A+ if (str)
19033N/A+ {
19033N/A+ /* strip trailing newline */
19033N/A+ char *nl = strrchr(str, '\n');
19033N/A+ if (nl)
19033N/A+ *nl = 0;
19033N/A+
19033N/A+ /*
19033N/A+ fprintf (stderr,">>>>>Child..in handle_input..string is:%s\n",str);
19033N/A+ fflush (stderr);
19033N/A+ */
19033N/A+
19033N/A+ /* Handle commands from parent daemon */
19033N/A+
19033N/A+ if (((strncmp (str, "ul_", 3)) == 0))
19033N/A+ {
19033N/A+ /* search for =, and if found, split into two strings there */
19033N/A+ char *msgstr = strchr(str, '='); /* Data sent with command */
19033N/A+ if (msgstr)
19033N/A+ *msgstr++ = 0;
19033N/A+
19033N/A+ if ((strcmp (str, "ul_ok") == 0))
19033N/A+ {
19033N/A+ hmsg = _("Authentication Successful!");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_acct_ok") == 0))
19033N/A+ {
19033N/A+ hmsg = _("PAM Account Management Also Successful!");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_setcred_fail") == 0))
19033N/A+ {
19033N/A+ hmsg = _("Just a Warning PAM Set Credential Failed!");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_setcred_ok") == 0))
19033N/A+ {
19033N/A+ hmsg = _("PAM Set Credential Also Successful!");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_acct_fail") == 0))
19033N/A+ {
19033N/A+ hmsg = _("Your Password has expired.");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_fail") == 0))
19033N/A+ {
19033N/A+ hmsg = _("Sorry!");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_read") == 0))
19033N/A+ {
19033N/A+ hmsg = _("Waiting for user input!");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_time") == 0))
19033N/A+ {
19033N/A+ hmsg = _("Timed Out!");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_null") == 0))
19033N/A+ {
19033N/A+ hmsg = _("Still Checking!");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_cancel") == 0))
19033N/A+ {
19033N/A+ hmsg = _("Authentication Cancelled!");
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_pamprompt") == 0))
19033N/A+ {
19033N/A+ gtk_label_set_text (GTK_LABEL (pwd->user_prompt_label), msgstr);
19033N/A+ gtk_widget_show (pwd->user_prompt_label);
19033N/A+ msgstr = NULL; /* clear message so we don't show it twice */
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_prompt_echo") == 0))
19033N/A+ {
19033N/A+ if ((strcmp (msgstr, "true") == 0))
19033N/A+ {
19033N/A+ gtk_entry_set_visibility
19033N/A+ (GTK_ENTRY (pwd->user_input_entry), TRUE);
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ if ((strcmp (msgstr, "stars") == 0))
19033N/A+ /* reset to default display of "*" or bullet */
19033N/A+ gtk_entry_unset_invisible_char
19033N/A+ (GTK_ENTRY (pwd->user_input_entry));
19033N/A+ else
19033N/A+ /* set to no display */
19033N/A+ gtk_entry_set_invisible_char
19033N/A+ (GTK_ENTRY (pwd->user_input_entry), 0);
19033N/A+
19033N/A+ gtk_entry_set_visibility
19033N/A+ (GTK_ENTRY (pwd->user_input_entry), FALSE);
19033N/A+ }
19033N/A+ msgstr = NULL; /* clear message so we don't show it to user */
19033N/A+ /* Show the entry field */
19033N/A+ gtk_widget_show (pwd->user_input_entry);
19033N/A+ gtk_widget_grab_focus (pwd->user_input_entry);
19098N/A+ gdk_display_sync
19098N/A+ (gtk_widget_get_display (pwd->user_input_entry));
19033N/A+ }
19033N/A+ else if ((strcmp (str, "ul_message") == 0))
19033N/A+ {
19033N/A+ hmsg = NULL; /* only show msg */
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ /* Should not be others, but if so just show it */
19033N/A+ hmsg = str;
19033N/A+ }
19033N/A+
19033N/A+ if (hmsg)
19033N/A+ {
19033N/A+ label = g_markup_printf_escaped ("<b>%s</b>", hmsg);
19033N/A+ g_object_set (pwd->msg_label, "label", label, NULL);
19033N/A+ g_free (label);
19033N/A+ }
19033N/A+
19033N/A+ if (msgstr)
19033N/A+ {
19033N/A+ gtk_label_set_text (GTK_LABEL (pwd->pam_message_label), msgstr);
19033N/A+ }
19033N/A+ }
19033N/A+ else if ((strcmp (str, "cmd_exit") == 0))
19033N/A+ {
19033N/A+ gtk_main_quit ();
19033N/A+ }
19033N/A+ else /* something came through that didn't start with ul_ */
19033N/A+ {
19033N/A+ gtk_label_set_text (GTK_LABEL (pwd->pam_message_label), str);
19033N/A+ }
19033N/A+
19033N/A+ g_free (str);
19033N/A+ }
19033N/A+
19033N/A+ return (status != G_IO_STATUS_EOF);
19033N/A+}
19033N/A+
19033N/A+int
19033N/A+main (int argc, char *argv[])
19033N/A+{
19033N/A+ GIOChannel *ioc;
19033N/A+ PasswdDialog *pwd;
19033N/A+ char *s;
19033N/A+ char *real_progname = argv[0];
19033N/A+ GConfClient *client;
19033N/A+ const char *modulesptr = NULL;
19033N/A+ int i;
19033N/A+
19033N/A+ gboolean at_enable = FALSE; /* accessibility mode enabled ? */
19033N/A+ Bonobo_ServerInfoList *server_list = NULL;
19033N/A+ CORBA_Environment ev;
19033N/A+ Accessibility_LoginHelper helper;
19033N/A+ Accessibility_LoginHelper *helper_list = NULL;
19033N/A+ CORBA_boolean safe;
19033N/A+ gboolean center_position = TRUE; /* center dialog on screen? */
19033N/A+
19033N/A+#ifdef ENABLE_NLS
19033N/A+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
19033N/A+ textdomain (GETTEXT_PACKAGE);
19033N/A+
19033N/A+#ifdef HAVE_GTK2
19033N/A+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
19033N/A+#else /* ! HAVE_GTK2 */
19033N/A+ if (!setlocale (LC_ALL, ""))
19033N/A+ fprintf (stderr, "%s: locale not supported by C library\n", real_progname);
19033N/A+#endif /* ! HAVE_GTK2 */
19033N/A+#endif /* ENABLE_NLS */
19033N/A+
19033N/A+ s = strrchr (real_progname, '/');
19033N/A+ if (s) real_progname = s+1;
19033N/A+ progname = real_progname;
19033N/A+
19033N/A+ parent_file = fdopen(FD_TO_PARENT, "w");
19098N/A+ if (!parent_file)
19098N/A+ {
19098N/A+ fprintf (stderr, "%s: can't communicate with parent, exiting.\n",
19098N/A+ progname);
19098N/A+ exit (1);
19098N/A+ }
19033N/A+
19033N/A+ gtk_init (&argc, &argv);
19033N/A+
19033N/A+ /* Intern the atoms that xscreensaver_command() needs.
19033N/A+ */
19117N/A+ {
19117N/A+ Display *dpy = gdk_x11_get_default_xdisplay();
19117N/A+
19117N/A+ const struct atom_request unlock_atoms[] =
19117N/A+ {
19117N/A+ { &XA_UNLOCK_RATIO, "UNLOCK_RATIO" },
19117N/A+ { NULL, NULL } /* Must be last to terminate list */
19117N/A+ };
19117N/A+
19117N/A+ const struct atom_request *atom_lists[3] = { NULL, NULL, NULL };
19117N/A+ atom_lists[0] = remote_control_atoms;
19117N/A+ atom_lists[1] = unlock_atoms;
19117N/A+ request_atoms (dpy, atom_lists);
19117N/A+ }
19033N/A+
19033N/A+ /* bugid 6346056(P1):
19033N/A+ ATOK pallet sometimes appears in screensave/lock-screen mode
19033N/A+ */
19033N/A+ putenv ("GTK_IM_MODULE=gtk-im-context-simple");
19033N/A+
19033N/A+
19033N/A+ /* accessibility mode enabled ? */
19033N/A+ client = gconf_client_get_default ();
19033N/A+ at_enable = gconf_client_get_bool (client,
19033N/A+ "/desktop/gnome/interface/accessibility",
19033N/A+ NULL);
19033N/A+ if (at_enable)
19033N/A+ {
19033N/A+
19033N/A+ /* GTK Accessibility Module initialized */
19033N/A+ modulesptr = g_getenv ("GTK_MODULES");
19033N/A+ if (!modulesptr || modulesptr [0] == '\0')
19033N/A+ putenv ("GTK_MODULES=gail:atk-bridge");
19033N/A+
19033N/A+ CORBA_exception_init (&ev);
19033N/A+ if (!bonobo_init (&argc, argv))
19033N/A+ {
19033N/A+ g_error ("Can't initialize Bonobo");
19033N/A+ }
19033N/A+
19033N/A+ /* bonobo-activation query lists existing instances */
19033N/A+ server_list = bonobo_activation_query (
19033N/A+ "(repo_ids.has('IDL:Accessibility/LoginHelper:1.0')) AND _active",
19033N/A+ NULL, &ev);
19033N/A+
19033N/A+ if (BONOBO_EX (&ev))
19033N/A+ {
19033N/A+ bonobo_debug_shutdown ();
19033N/A+ g_error ("LoginHelper query failed : %s",
19033N/A+ bonobo_exception_get_text (&ev));
19033N/A+ /* not reached (below) because g_error exits */
19033N/A+ CORBA_exception_free (&ev);
19033N/A+ }
19033N/A+
19033N/A+ /*
19033N/A+ * 6182506: unlock dialog can be obscured by the magnifier window
19033N/A+ * if it's always centered, so don't force that if any accessibility
19033N/A+ * helpers are present
19033N/A+ */
19033N/A+ if (server_list && server_list->_length)
19033N/A+ center_position = FALSE;
19033N/A+ } /* accessibility enabled */
19033N/A+
19033N/A+ pwd = make_dialog (center_position);
19033N/A+ connect_signals (pwd);
19033N/A+
19033N/A+ gtk_widget_show_all (pwd->dialog);
19033N/A+ gtk_window_present (GTK_WINDOW (pwd->dialog));
19033N/A+ gtk_widget_map (pwd->dialog);
19033N/A+
19098N/A+ gdk_display_sync (gtk_widget_get_display (pwd->dialog));
19033N/A+
19033N/A+ gdk_window_add_filter (GET_WINDOW (pwd->dialog), dialog_filter_func, pwd);
19033N/A+ write_windowid ("dialog_win", GDK_WINDOW_XID (GET_WINDOW (pwd->dialog)));
19033N/A+
19033N/A+ if (server_list && server_list->_length)
19033N/A+ {
19033N/A+ /* debug only
19033N/A+ g_message ("%d LoginHelpers are running.",
19033N/A+ server_list ? server_list->_length : 0);
19033N/A+ */
19033N/A+
19033N/A+ helper_list = g_new0 (Accessibility_LoginHelper, server_list->_length);
19033N/A+
19033N/A+ /* for each instance... */
19033N/A+ for (i = 0; i < server_list->_length; i++)
19033N/A+ {
19033N/A+ Bonobo_Unknown server;
19033N/A+ Bonobo_ServerInfo info = server_list->_buffer[i];
19033N/A+
19033N/A+ server = bonobo_activation_activate_from_id (
19033N/A+ info.iid, Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, NULL, &ev);
19033N/A+
19033N/A+ if (BONOBO_EX (&ev))
19033N/A+ {
19033N/A+ g_warning ("Error activating server %d: %s", i,
19033N/A+ bonobo_exception_get_text (&ev));
19033N/A+ CORBA_exception_free (&ev);
19033N/A+ continue;
19033N/A+ }
19033N/A+ else if (server == CORBA_OBJECT_NIL)
19033N/A+ {
19033N/A+ g_warning ("Activated server %d is NIL!", i);
19033N/A+ continue;
19033N/A+ }
19033N/A+
19033N/A+ bonobo_activate ();
19033N/A+
19033N/A+ helper = Bonobo_Unknown_queryInterface
19033N/A+ (server, "IDL:Accessibility/LoginHelper:1.0", &ev);
19033N/A+
19033N/A+ if (BONOBO_EX (&ev))
19033N/A+ {
19033N/A+ g_warning ("Error performing interface query: %s",
19033N/A+ bonobo_exception_get_text (&ev));
19033N/A+ CORBA_exception_free (&ev);
19033N/A+ continue;
19033N/A+ }
19033N/A+ else if (helper == CORBA_OBJECT_NIL)
19033N/A+ {
19033N/A+ g_warning ("Activated an object which advertised LoginHelper but does not implement it!");
19033N/A+ continue;
19033N/A+ }
19033N/A+
19033N/A+ helper_list[i] = helper;
19033N/A+ bonobo_object_release_unref (server, &ev);
19033N/A+
19033N/A+ if (helper && !BONOBO_EX (&ev))
19033N/A+ {
19033N/A+ /* ask the helper to go into safe mode */
19033N/A+ safe = Accessibility_LoginHelper_setSafe (helper, TRUE, &ev);
19033N/A+ if (BONOBO_EX (&ev))
19033N/A+ {
19033N/A+ g_warning ("setSafe(TRUE) failed: %s",
19033N/A+ bonobo_exception_get_text (&ev));
19033N/A+ CORBA_exception_free (&ev);
19033N/A+ }
19033N/A+
19033N/A+ /* get the raise window list (if the program went into safe mode) */
19033N/A+ if (safe)
19033N/A+ {
19033N/A+ int j;
19033N/A+ gboolean needs_windows_raised = FALSE;
19033N/A+ Accessibility_LoginHelper_DeviceReqList *list;
19033N/A+
19033N/A+ g_debug ("safe");
19033N/A+
19033N/A+ /* does this helper need to have windows raised? */
19033N/A+ list = Accessibility_LoginHelper_getDeviceReqs (helper, &ev);
19033N/A+
19033N/A+ if (BONOBO_EX (&ev))
19033N/A+ {
19033N/A+ g_warning ("Bonobo exception getting Device Requirements: %s",
19033N/A+ bonobo_exception_get_text (&ev));
19033N/A+ CORBA_exception_free (&ev);
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ g_debug ("LoginHelper device requirements: ");
19033N/A+ if (list->_length == 0)
19033N/A+ g_debug (" - None.");
19033N/A+
19033N/A+ for (j = 0; j < list->_length; j++)
19033N/A+ {
19033N/A+ switch (list->_buffer[j])
19033N/A+ {
19033N/A+ case Accessibility_LoginHelper_GUI_EVENTS:
19033N/A+ g_debug (" - Needs access to the GUI event subsystem (e.g. Xserver)");
19033N/A+ break;
19033N/A+ case Accessibility_LoginHelper_CORE_KEYBOARD:
19033N/A+ g_debug (" - Needs access to core keyboard device");
19033N/A+ write_to_parent("ungrab_keyboard", "true", FALSE);
19033N/A+ break;
19033N/A+ case Accessibility_LoginHelper_CORE_POINTER:
19033N/A+ g_debug (" - Needs access to core pointer device");
19033N/A+ write_to_parent("ungrab_pointer", "true", FALSE);
19033N/A+ break;
19033N/A+ case Accessibility_LoginHelper_EXT_INPUT:
19033N/A+ g_debug (" - Reads XInput extended input devices");
19033N/A+ break;
19033N/A+ case Accessibility_LoginHelper_POST_WINDOWS:
19033N/A+ g_debug (" - Posts windows");
19033N/A+ needs_windows_raised = TRUE;
19033N/A+ break;
19033N/A+ case Accessibility_LoginHelper_AUDIO_OUT:
19033N/A+ g_debug (" - Writes to audio device");
19033N/A+ break;
19033N/A+ case Accessibility_LoginHelper_AUDIO_IN:
19033N/A+ g_debug (" - Reads from audio device");
19033N/A+ break;
19033N/A+ case Accessibility_LoginHelper_LOCALHOST:
19033N/A+ g_debug (" - Needs LOCALHOST network connection");
19033N/A+ break;
19033N/A+ case Accessibility_LoginHelper_SERIAL_OUT:
19033N/A+ g_debug (" - Needs to write to one or more serial ports");
19033N/A+ break;
19033N/A+ default:
19033N/A+ break;
19033N/A+ }
19033N/A+ }
19033N/A+ CORBA_free (list);
19033N/A+ }
19033N/A+
19033N/A+ if (needs_windows_raised)
19033N/A+ {
19033N/A+ Accessibility_LoginHelper_WindowList *windows
19033N/A+ = Accessibility_LoginHelper_getRaiseWindows
19033N/A+ (helper, &ev);
19033N/A+
19033N/A+ if (BONOBO_EX (&ev))
19033N/A+ {
19033N/A+ g_warning ("getRaiseWindows failed: %s",
19033N/A+ bonobo_exception_get_text (&ev));
19033N/A+ CORBA_exception_free (&ev);
19033N/A+ }
19033N/A+
19033N/A+ g_debug ("%d windows need raising", windows->_length);
19033N/A+ for (j = 0; j < windows->_length; j++)
19033N/A+ {
19033N/A+ Window wid = windows->_buffer[j].winID;
19033N/A+ g_debug ("Window ID = 0x%lx", wid);
19033N/A+ if (wid)
19033N/A+ write_windowid ("raise_win", wid);
19033N/A+ }
19033N/A+ }
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ g_warning ("LoginHelper %d did not go into safe mode", i);
19033N/A+ }
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ if (BONOBO_EX (&ev))
19033N/A+ {
19033N/A+ g_warning ("Error activating %s: %s",
19033N/A+ info.iid, bonobo_exception_get_text (&ev));
19033N/A+ CORBA_exception_free (&ev);
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ g_warning ("no active instance of %s found", info.iid);
19033N/A+ }
19033N/A+ }
19033N/A+ }
19033N/A+ } /* accessibility helpers active */
19033N/A+
19033N/A+ /* Flush dialog window ids & any messages about login helpers to parent */
19033N/A+ write_to_parent(NULL, NULL, TRUE);
19033N/A+
19033N/A+ gtk_widget_grab_focus (pwd->user_input_entry);
19033N/A+
19033N/A+ ioc = g_io_channel_unix_new (0);
19033N/A+ g_io_add_watch (ioc, G_IO_IN | G_IO_HUP, handle_input, pwd);
19033N/A+
19033N/A+ gtk_main ();
19033N/A+
19033N/A+ /* Reset accessibility helpers back to non-safe mode now that we're done */
19033N/A+ if (server_list)
19033N/A+ {
19033N/A+ for (i = 0; i < server_list->_length; i++)
19033N/A+ {
19033N/A+ helper = helper_list[i];
19033N/A+ /* really no need to check the return value this time */
19033N/A+ Accessibility_LoginHelper_setSafe (helper, FALSE, &ev);
19033N/A+ if (BONOBO_EX (&ev))
19033N/A+ {
19033N/A+ g_warning ("setSafe(FALSE) failed: %s",
19033N/A+ bonobo_exception_get_text (&ev));
19033N/A+ CORBA_exception_free (&ev);
19033N/A+ }
19033N/A+ CORBA_Object_release (helper, &ev);
19033N/A+ }
19033N/A+ CORBA_free (server_list);
19033N/A+ bonobo_debug_shutdown ();
19033N/A+ }
19033N/A+
19033N/A+ return 0;
19033N/A+}
19033N/A+#endif /* HAVE_GTK2 */
19033N/A+
19033N/Adiff --git xscreensaver-5.12/driver/lock.c xscreensaver-5.12/driver/lock.c
19033N/A--- xscreensaver-5.12/driver/lock.c
19033N/A+++ xscreensaver-5.12/driver/lock.c
19033N/A@@ -21,8 +21,13 @@
19033N/A #include <X11/Intrinsic.h>
19033N/A #include <X11/cursorfont.h>
19033N/A #include <X11/Xos.h> /* for time() */
19033N/A+#include <X11/Xatom.h>
19033N/A #include <time.h>
19033N/A #include <sys/time.h>
19033N/A+#include <errno.h>
19033N/A+#include <gconf/gconf-client.h>
19033N/A+#include "exec.h"
19033N/A+#include "dialog-data.h"
19033N/A #include "xscreensaver.h"
19033N/A #include "resources.h"
19033N/A #include "mlstring.h"
20829N/A@@ -83,114 +88,631 @@ vms_passwd_valid_p(char *pw, Bool verbose_p)
19033N/A
19033N/A typedef struct info_dialog_data info_dialog_data;
19033N/A
19033N/A-struct passwd_dialog_data {
19033N/A-
19033N/A- saver_screen_info *prompt_screen;
19033N/A- int previous_mouse_x, previous_mouse_y;
19033N/A-
19033N/A- char typed_passwd [80];
19033N/A- XtIntervalId timer;
19033N/A- int i_beam;
19033N/A-
19033N/A- float ratio;
19033N/A- Position x, y;
19033N/A- Dimension width;
19033N/A- Dimension height;
19033N/A- Dimension border_width;
19033N/A-
19033N/A- Bool echo_input;
19033N/A- Bool show_stars_p; /* "I regret that I have but one asterisk for my country."
19033N/A- -- Nathan Hale, 1776. */
19033N/A-
19033N/A- char *heading_label;
19033N/A- char *body_label;
19033N/A- char *user_label;
19033N/A- mlstring *info_label;
19033N/A- /* The entry field shall only be displayed if prompt_label is not NULL */
19033N/A- mlstring *prompt_label;
19033N/A- char *date_label;
19033N/A- char *passwd_string;
19033N/A- Bool passwd_changed_p; /* Whether the user entry field needs redrawing */
19033N/A- Bool caps_p; /* Whether we saw a keypress with caps-lock on */
19033N/A- char *unlock_label;
19033N/A- char *login_label;
19033N/A- char *uname_label;
19033N/A-
19033N/A- Bool show_uname_p;
19033N/A-
19033N/A- XFontStruct *heading_font;
19033N/A- XFontStruct *body_font;
19033N/A- XFontStruct *label_font;
19033N/A- XFontStruct *passwd_font;
19033N/A- XFontStruct *date_font;
19033N/A- XFontStruct *button_font;
19033N/A- XFontStruct *uname_font;
19033N/A-
19033N/A- Pixel foreground;
19033N/A- Pixel background;
19033N/A- Pixel passwd_foreground;
19033N/A- Pixel passwd_background;
19033N/A- Pixel thermo_foreground;
19033N/A- Pixel thermo_background;
19033N/A- Pixel shadow_top;
19033N/A- Pixel shadow_bottom;
19033N/A- Pixel button_foreground;
19033N/A- Pixel button_background;
19033N/A-
19033N/A- Dimension preferred_logo_width, logo_width;
19033N/A- Dimension preferred_logo_height, logo_height;
19033N/A- Dimension thermo_width;
19033N/A- Dimension internal_border;
19033N/A- Dimension shadow_width;
19033N/A-
19033N/A- Dimension passwd_field_x, passwd_field_y;
19033N/A- Dimension passwd_field_width, passwd_field_height;
19033N/A-
19033N/A- Dimension unlock_button_x, unlock_button_y;
19033N/A- Dimension unlock_button_width, unlock_button_height;
19033N/A-
19033N/A- Dimension login_button_x, login_button_y;
19033N/A- Dimension login_button_width, login_button_height;
19033N/A-
19033N/A- Dimension thermo_field_x, thermo_field_y;
19033N/A- Dimension thermo_field_height;
19033N/A-
19033N/A- Pixmap logo_pixmap;
19033N/A- Pixmap logo_clipmask;
19033N/A- int logo_npixels;
19033N/A- unsigned long *logo_pixels;
19033N/A-
19033N/A- Cursor passwd_cursor;
19033N/A- Bool unlock_button_down_p;
19033N/A- Bool login_button_down_p;
19033N/A- Bool login_button_p;
19033N/A- Bool login_button_enabled_p;
19033N/A- Bool button_state_changed_p; /* Refers to both buttons */
19033N/A-
19033N/A- Pixmap save_under;
19033N/A- Pixmap user_entry_pixmap;
19033N/A-};
19033N/A+/* struct passwd_dialog_data moved to dialog-data.h */
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A static void draw_passwd_window (saver_info *si);
19033N/A+#endif
19033N/A static void update_passwd_window (saver_info *si, const char *printed_passwd,
19033N/A float ratio);
19033N/A static void destroy_passwd_window (saver_info *si);
19033N/A+static int ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error);
19033N/A static void undo_vp_motion (saver_info *si);
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A static void finished_typing_passwd (saver_info *si, passwd_dialog_data *pw);
19033N/A+#endif
19033N/A static void cleanup_passwd_window (saver_info *si);
19033N/A static void restore_background (saver_info *si);
19033N/A
19033N/A extern void xss_authenticate(saver_info *si, Bool verbose_p);
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+
19033N/A+#define WIN_ALLOC_INCREMENT 8 /* allocate entries in the window lists in
19033N/A+ increments of 8 at a time for fewer
19033N/A+ reallocs and less chance of malloc error
19033N/A+ at the wrong time */
19033N/A+#define EXTRA_RAISE_WIN_SLOTS 4 /* Need to leave four extra slots free in
19033N/A+ raise_wins to allow calling XRestackWindows
19033N/A+ when a window pops up without having to
19033N/A+ realloc or copy to a new list.
19033N/A+ These slots would be used by:
19033N/A+ - passwd_dialog
19033N/A+ - stderr_overlay_window
19033N/A+ - xscreensaver virtual root
19033N/A+ - an interloper popup we need to hide
19033N/A+ */
19033N/A+
19033N/A+extern Atom XA_UNLOCK_RATIO;
19033N/A+
19033N/A+Bool g_passwd_dialog_created = 0;
19033N/A+
19033N/A+GConfClient *client = NULL;
19033N/A+
19033N/A+static const char *switch_windows_gconf_key
19033N/A+ = "/apps/metacity/global_keybindings/switch_windows";
19033N/A+static char *global_switch_key = NULL;
19033N/A+
19033N/A+static const char *main_menu_gconf_key
19033N/A+ = "/apps/metacity/global_keybindings/panel_main_menu";
19033N/A+static char *global_menu_key = NULL;
19033N/A+
19033N/A+extern Bool safe_XDestroyWindow (Display *dpy, Window window);
19033N/A+static Bool safe_XRestackWindows(Display *dpy, Window windows[], int nwindows);
19033N/A+static Bool safe_XSendEvent(Display *dpy, Window w, Bool propagate,
19033N/A+ long event_mask, XEvent *event_send);
19033N/A+static void passwd_animate_timer (XtPointer closure, XtIntervalId *id);
19033N/A+extern void swallow_unlock_typeahead_events (saver_info *si, XEvent *e);
19033N/A+
19033N/A+
19033N/A+static saver_screen_info *
19033N/A+find_screen_for_window (saver_info *si, Window wid)
19033N/A+{
19033N/A+ saver_screen_info *ssi;
19033N/A+ Screen *screen;
19033N/A+ Window root, root_ret, parent_ret, *children = NULL;
19033N/A+ unsigned int nchildren = 0;
19033N/A+ int screen_no, status;
19033N/A+
19033N/A+ status = XQueryTree (si->dpy, wid, &root_ret, &parent_ret,
19033N/A+ &children, &nchildren);
19033N/A+
19033N/A+ if (status == 0) /* failed */
19033N/A+ return NULL;
19033N/A+
19033N/A+ XFree(children);
19033N/A+ children = NULL;
19033N/A+
19033N/A+ for (screen_no = 0; screen_no < si->nscreens; screen_no++)
19033N/A+ {
19033N/A+ ssi = &si->screens[screen_no];
19033N/A+ screen = ssi->screen;
19033N/A+ root = RootWindowOfScreen (screen);
19033N/A+
19033N/A+ if (root == root_ret)
19033N/A+ return ssi;
19033N/A+ }
19033N/A+
19033N/A+ return NULL; /* Didn't match the root on any screen we know of - PUNT! */
19033N/A+}
19033N/A+
19033N/A+/*
19033N/A+ 5083155 Unable to unlock screen when running dual-head MAG
19033N/A+ adding dual or multiple heads for magnifier support
19033N/A+
19033N/A+ screen 0: loginhelp can pass the raisedWid of GOK or MAG or both
19033N/A+ found: return its parent Wid (child of root)
19033N/A+ not found: 0
19033N/A+
19033N/A+ other screen: MAG only if the target screen no > 0 is selected
19033N/A+ found: restack on that screen
19033N/A+ return 0
19033N/A+ not-found : return 0
19033N/A+
19033N/A+ */
19033N/A+
19033N/A+static Window
19033N/A+check_raisedWid (saver_info *si, Window wid)
19033N/A+{
19033N/A+ saver_screen_info *ssi;
19033N/A+ Screen *screen;
19033N/A+ Window root, root_ret, parent_ret, *children = NULL;
19033N/A+ unsigned int nchildren = 0;
19033N/A+ int screen_no, status;
19033N/A+
19033N/A+ status = XQueryTree (si->dpy, wid, &root_ret, &parent_ret,
19033N/A+ &children, &nchildren);
19033N/A+
19033N/A+ if (status == 0) /* failed */
19033N/A+ return 0;
19033N/A+
19033N/A+ XFree(children);
19033N/A+ children = NULL;
19033N/A+
19033N/A+ for (screen_no = 0; screen_no < si->nscreens; screen_no++)
19033N/A+ {
19033N/A+ ssi = &si->screens[screen_no];
19033N/A+ screen = ssi->screen;
19033N/A+ root = RootWindowOfScreen (screen);
19033N/A+
19033N/A+ if (root == root_ret)
19033N/A+ break;
19033N/A+ }
19033N/A+
19033N/A+ if ( screen_no >= si->nscreens ) /* Didn't match the root on any screen */
19033N/A+ return 0; /* we know of - PUNT! */
19033N/A+
19033N/A+ /* Climb the tree until we find an ancestor that's a child of root */
19033N/A+ while ( root_ret != parent_ret )
19033N/A+ {
19033N/A+ wid = parent_ret;
19033N/A+
19033N/A+ status = XQueryTree (si->dpy, wid, &root_ret, &parent_ret,
19033N/A+ &children, &nchildren);
19033N/A+
19033N/A+ if (status == 0) /* failed */
19033N/A+ return 0;
19033N/A+
19033N/A+ XFree(children);
19033N/A+ children = NULL;
19033N/A+ }
19033N/A+
19033N/A+ if ( ssi != si->pw_data->prompt_screen )
19033N/A+ {
19033N/A+ /* found in other screen (not the one with the unlock dialog),
19033N/A+ implies MAG target screen, invoke XRestackWindow() there
19033N/A+ */
19033N/A+ Window screen_win[2] = { wid, ssi->screensaver_window };
19033N/A+ safe_XRestackWindows(si->dpy, screen_win, 2);
19033N/A+ return 0; /* no need to do the restack on prompt screen */
19033N/A+ }
19033N/A+
19033N/A+ return wid;
19033N/A+}
19033N/A+
19033N/A+/* Enforce window stacking order when a new window arrives.
19033N/A+ Only allow raising windows the unlock dialog has told us to raise
19033N/A+ (including itself).
19033N/A+ */
19033N/A+static void
19033N/A+restack_my_windows (saver_info* si, saver_screen_info *ssi, Window newWin)
19033N/A+{
19033N/A+ int n = 0;
19033N/A+ Window short_stack[EXTRA_RAISE_WIN_SLOTS];
19033N/A+ Window *restack_list;
19033N/A+ Bool allowed = False;
19033N/A+
19033N/A+ /* If window is on another screen than the unlock dialog,
19033N/A+ or we have list of no windows to raise */
19033N/A+ if ((si->raise_wins == NULL) || (ssi != si->pw_data->prompt_screen))
19033N/A+ {
19033N/A+ restack_list = short_stack;
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ restack_list = si->raise_wins;
19033N/A+ for (n = 0; n < si->num_raise_wins; n++)
19033N/A+ {
19033N/A+ if (si->raise_wins[n] == newWin)
19033N/A+ allowed = True;
19033N/A+ }
19033N/A+ }
19033N/A+
19033N/A+ if (si->passwd_dialog && (ssi == si->pw_data->prompt_screen))
19033N/A+ {
19033N/A+ restack_list[n++] = si->passwd_dialog;
19033N/A+ if (si->passwd_dialog == newWin)
19033N/A+ allowed = True;
19033N/A+ }
19033N/A+
19033N/A+ if (ssi->stderr_overlay_window)
19033N/A+ {
19033N/A+ restack_list[n++] = ssi->stderr_overlay_window;
19033N/A+ if (ssi->stderr_overlay_window == newWin)
19033N/A+ allowed = True;
19033N/A+ }
19033N/A+
19033N/A+ if (ssi->screensaver_window)
19033N/A+ {
19033N/A+ restack_list[n++] = ssi->screensaver_window;
19033N/A+ if (ssi->screensaver_window == newWin)
19033N/A+ allowed = True;
19033N/A+ }
19033N/A+
19033N/A+ /* If it's not in the allowed list, it goes behind
19033N/A+ the screensaver_window. */
19033N/A+ if (newWin && !allowed)
19033N/A+ restack_list[n++] = newWin;
19033N/A+
19033N/A+ if (n > 1)
19033N/A+ safe_XRestackWindows (si->dpy, restack_list, n);
19033N/A+}
19033N/A+
19033N/A+/* Send a command to the xscreensaver-lock child process
19033N/A+ Arguments:
19033N/A+ - msg - message to send, such as ul_ok
19033N/A+ - data - additional data, such as string to display for this message,
19033N/A+ if any, otherwise NULL
19033N/A+ Message format sent to child:
19033N/A+ "msg\n" if no data, otherwise "msg=data\n"
19033N/A+ */
19033N/A+int
19033N/A+write_to_child (saver_info* si, const char* msg, const char *data)
19033N/A+{
19033N/A+ if (msg == NULL)
19033N/A+ {
19033N/A+ fprintf (stderr, "Invalid null message written to child\n");
19033N/A+ return -1;
19033N/A+ }
19033N/A+
19033N/A+ if (si->external_passwd && g_passwd_dialog_created &&
19033N/A+ si->pw_data->stdin_fd != -1)
19033N/A+ {
19033N/A+ int len;
19033N/A+
19033N/A+ if (si->prefs.verbose_p)
19033N/A+ {
19033N/A+ fprintf (stderr,
19033N/A+ "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
19033N/A+ "HAVE_SCRSVR_LOCK writing to fd:%d message is:\n%s=%s\n"
19033N/A+ "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n",
19033N/A+ si->pw_data->stdin_fd, msg, data ? data : "(null)");
19033N/A+ }
19033N/A+
19033N/A+ if (data)
19033N/A+ len = fprintf (si->pw_data->stdin_file, "%s=%s\n", msg, data);
19033N/A+ else
19033N/A+ len = fprintf (si->pw_data->stdin_file, "%s\n", msg);
19033N/A+
19033N/A+ fflush (si->pw_data->stdin_file);
19033N/A+ return len;
19033N/A+ }
19033N/A+
19033N/A+ return (0); /* if we didn't write anything return 0 */
19033N/A+}
19033N/A+
19033N/A+static int
19033N/A+sane_dup2 (int fd1, int fd2)
19033N/A+{
19033N/A+ int ret;
19033N/A+
19033N/A+ do
19033N/A+ {
19033N/A+ ret = dup2 (fd1, fd2);
19033N/A+ }
19033N/A+ while (ret < 0 && errno == EINTR);
19033N/A+
19033N/A+ return ret;
19033N/A+}
19033N/A+
19033N/A+static int
19033N/A+close_and_invalidate (int *fd)
19033N/A+{
19033N/A+ int ret;
19033N/A+
19033N/A+ ret = close (*fd);
19033N/A+ *fd = -1;
19033N/A+
19033N/A+ return ret;
19033N/A+}
19033N/A+
19033N/A+void
19033N/A+handle_passwd_input (XtPointer xtdata, int *fd, XtInputId *id)
19033N/A+{
19033N/A+ saver_info *si = (saver_info *)xtdata;
19033N/A+ saver_preferences *p = &si->prefs;
19033N/A+ char buffer[1024];
19033N/A+ char *msg, *data;
19033N/A+ passwd_dialog_data *pw = si->pw_data;
19033N/A+
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf (stderr, "passwd input handler() fd=%d\n", *fd);
19033N/A+
19033N/A+ msg = fgets (buffer, sizeof (buffer), pw->stdout_file);
19033N/A+ if (!msg) /* child closed pipe */
19033N/A+ {
19033N/A+ if (p->verbose_p)
19033N/A+ {
19033N/A+ fprintf (stderr, "done reading...\n");
19033N/A+ fprintf (stderr, "removing input handler...\n");
19033N/A+ }
19033N/A+ XtRemoveInput (*id);
19033N/A+ pw->stdout_input_id = 0;
19033N/A+
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf (stderr, "passwd input handler() returning...done reading\n");
19033N/A+
19033N/A+ return;
19033N/A+ }
19033N/A+
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf (stderr, "Child sent message: %s\n", msg);
19033N/A+
19033N/A+ /* search for =, and if found, split msg & data into two strings there */
19033N/A+ data = strchr(msg, '=');
19033N/A+ if (data)
19033N/A+ {
19033N/A+ char *nl;
19033N/A+
19033N/A+ *data++ = 0;
19033N/A+
19033N/A+ /* strip trailing newline */
19033N/A+ nl = strchr (data, '\n');
19033N/A+ if (nl)
19033N/A+ *nl = '\0';
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ /* All the messages we currently expect require data! */
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf (stderr, "*** Invalid message: no data found, discarding\n");
19033N/A+
19033N/A+ return;
19033N/A+ }
19033N/A+
19033N/A+ if ((strcmp(msg, "input") == 0)) /* User input */
19033N/A+ {
19033N/A+ si->unlock_state = ul_finished;
19033N/A+ pw->got_passwd = TRUE;
19033N/A+ pw->passwd_string = strdup (data);
19033N/A+ memset (data, 0, strlen(data));
19033N/A+ }
19033N/A+ else if ((strcmp(msg, "ungrab_keyboard") == 0))
19033N/A+ {
19033N/A+ /* An accessibility helper needs to access the keyboard, so we have
19033N/A+ to release our grab - unfortunately this risks other apps acting
19033N/A+ on keys they shouldn't, so first we disable metacity keys that
19033N/A+ could allow getting back to the locked session windows, and hope
19033N/A+ we don't crash or die before restoring them later.
19033N/A+
19033N/A+ Other window managers are likely to be risky to use in this case.
19033N/A+ */
19033N/A+
19033N/A+ if (client == NULL)
19033N/A+ client = gconf_client_get_default();
19033N/A+
19033N/A+ if (global_switch_key == NULL)
19033N/A+ {
19033N/A+ global_switch_key =
19033N/A+ gconf_client_get_string (client, switch_windows_gconf_key, NULL);
19033N/A+
19033N/A+ if (global_switch_key && strncmp (global_switch_key, "dis", 3))
19033N/A+ gconf_client_set_string (client, switch_windows_gconf_key,
19033N/A+ "disabled", NULL);
19033N/A+ }
19033N/A+
19033N/A+ if (global_menu_key == NULL)
19033N/A+ {
19033N/A+ global_menu_key =
19033N/A+ gconf_client_get_string (client, main_menu_gconf_key, NULL);
19033N/A+
19033N/A+ if (global_menu_key && strncmp(global_menu_key, "dis", 3))
19033N/A+ gconf_client_set_string (client, main_menu_gconf_key,
19033N/A+ "disabled", NULL);
19033N/A+ }
19033N/A+
19033N/A+ XUngrabKeyboard (si->dpy, CurrentTime);
19033N/A+ XFlush (si->dpy);
19033N/A+ }
19033N/A+ else if ((strcmp(msg, "ungrab_pointer") == 0))
19033N/A+ {
19033N/A+ /* An accessibility helper needs to access the mouse, so we have
19033N/A+ to release our grab - this is simpler, since we don't worry about
19033N/A+ mouse gestures that may get through, though maybe we should...
19033N/A+ */
19033N/A+
19033N/A+ XUngrabPointer (si->dpy, CurrentTime);
19033N/A+ XFlush (si->dpy);
19033N/A+ }
19033N/A+ else /* Get a window id of an interesting window from the child */
19033N/A+ {
19033N/A+ Window window = strtoul (data, NULL, 0);
19033N/A+ int status;
19033N/A+
19033N/A+ if ((strcmp (msg, "dialog_win") == 0))
19033N/A+ {
19033N/A+ /* The unlock dialog itself */
19033N/A+ si->passwd_dialog = window;
19033N/A+ pw->got_windowid = True;
19033N/A+
19033N/A+ move_mouse_grab (si, si->passwd_dialog, pw->passwd_cursor,
19033N/A+ pw->prompt_screen->number);
19033N/A+ undo_vp_motion (si);
19033N/A+ passwd_animate_timer ((XtPointer) si, 0);
19033N/A+
19033N/A+ /* Flush queue of captured typeahead events */
19033N/A+ if (si->typeahead_events && si->num_typeahead_events)
19033N/A+ {
19033N/A+ int i;
19033N/A+
19033N/A+ for (i = 0; i < si->num_typeahead_events; i++)
19033N/A+ {
19033N/A+ si->typeahead_events[i].window = window;
19033N/A+ safe_XSendEvent (si->dpy, window, False, KeyPressMask,
19033N/A+ (XEvent *) &si->typeahead_events[i]);
19033N/A+ }
19033N/A+ si->num_typeahead_events = 0;
19033N/A+ }
20818N/A+ XGrabKeyboard (si->dpy, window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
20818N/A+ XGrabPointer (si->dpy, window, True, 0, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
20353N/A+ XFlush (si->dpy);
20353N/A+ XSetInputFocus (si->dpy, window, RevertToPointerRoot, CurrentTime);
20353N/A+ XSync (si->dpy, False);
19033N/A+ }
19033N/A+ else if ((strcmp (msg, "raise_win") == 0))
19033N/A+ {
19033N/A+ /* Accessibility helpers that need to be raised above the
19033N/A+ full-screen blanking window hiding the user's desktop */
19033N/A+ Window *newlist;
19033N/A+ Window overwin;
19033N/A+
19033N/A+ if ( (si->num_raise_wins + EXTRA_RAISE_WIN_SLOTS)
19033N/A+ >= si->max_raise_wins)
19033N/A+ {
19033N/A+ int raise_alloc = si->max_raise_wins + WIN_ALLOC_INCREMENT;
19033N/A+
19033N/A+ newlist = realloc(si->raise_wins, raise_alloc * sizeof(Window));
19033N/A+ if (newlist == NULL)
19033N/A+ return;
19033N/A+
19033N/A+ si->raise_wins = newlist;
19033N/A+ si->max_raise_wins = raise_alloc;
19033N/A+ }
19033N/A+
19033N/A+ overwin = check_raisedWid (si, window);
19033N/A+ if (overwin)
19033N/A+ {
19033N/A+ XWindowAttributes attrs;
19033N/A+ status = XGetWindowAttributes (si->dpy, overwin, &attrs);
19033N/A+
19033N/A+ if ( status && !attrs.override_redirect )
19033N/A+ {
19033N/A+ unsigned long valuemask = CWOverrideRedirect;
19033N/A+ XSetWindowAttributes setwinattr;
19033N/A+ setwinattr.override_redirect = True;
19033N/A+
19033N/A+ XChangeWindowAttributes (si->dpy, overwin,
19033N/A+ valuemask, &setwinattr);
19033N/A+
19033N/A+ if (si->num_override_wins >= si->max_override_wins)
19033N/A+ {
19033N/A+ int over_alloc
19033N/A+ = si->max_override_wins + WIN_ALLOC_INCREMENT;
19033N/A+
19033N/A+ newlist = realloc(si->override_wins,
19033N/A+ over_alloc * sizeof(Window));
19033N/A+ if (newlist == NULL)
19033N/A+ return;
19033N/A+
19033N/A+ si->override_wins = newlist;
19033N/A+ si->max_override_wins = over_alloc;
19033N/A+ }
19033N/A+
19033N/A+ si->override_wins[si->num_override_wins++] = overwin;
19033N/A+ }
19033N/A+ XMapSubwindows(si->dpy, overwin);
19033N/A+ si->raise_wins[si->num_raise_wins++] = overwin;
19033N/A+ }
19033N/A+ else
19033N/A+ si->raise_wins[si->num_raise_wins++] = window;
19033N/A+ } /* "raise_win" */
19033N/A+
19033N/A+ restack_my_windows(si, si->pw_data->prompt_screen, 0);
19033N/A+ }
19033N/A+}
19033N/A+
19033N/A+/* returns successful fork/exec */
19033N/A+Bool
19033N/A+spawn_external_passwd_process (saver_info *si, passwd_dialog_data *pw)
19033N/A+{
19033N/A+ saver_preferences *p = &si->prefs;
19033N/A+ pid_t forked;
19033N/A+ const char *command = LOCKDIR "/xscreensaver-lock";
19033N/A+ int stdin_pipe[2] = { -1, -1 };
19033N/A+ int stdout_pipe[2] = { -1, -1 };
19033N/A+
19033N/A+ si->passwd_pid = 0;
19033N/A+ pw->stdin_fd = pw->stdout_fd = -1;
19033N/A+ pw->got_windowid = False;
19033N/A+
19033N/A+ if (si->prefs.verbose_p)
19033N/A+ fprintf(stderr, "-->spawn_external_passwd()\n");
19033N/A+
19033N/A+ if (si->passwd_pid > 0)
19033N/A+ {
19033N/A+ if (si->prefs.verbose_p)
19033N/A+ fprintf (stderr,"pid %ld still exists. Killing it with SIGKILL\n",
19033N/A+ si->passwd_pid);
19033N/A+ kill_job (si, si->passwd_pid, SIGKILL);
19033N/A+ }
19033N/A+ si->passwd_pid = 0;
19033N/A+
19033N/A+ if (pipe (stdin_pipe) < 0)
19033N/A+ {
19033N/A+ perror ("pipe(stdin_pipe) failed!");
19033N/A+ return False;
19033N/A+ }
19033N/A+
19033N/A+ if (pipe (stdout_pipe) < 0)
19033N/A+ {
19033N/A+ perror ("pipe(stdout_pipe) failed!");
19033N/A+ close_and_invalidate (&stdin_pipe[0]);
19033N/A+ close_and_invalidate (&stdin_pipe[1]);
19033N/A+ return False;
19033N/A+ }
19033N/A+ switch ((int) (forked = fork ()))
19033N/A+ {
19033N/A+ case -1:
19033N/A+ fprintf (stderr, "%s: ", blurb ());
19033N/A+ perror ("couldn't fork");
19033N/A+
19033N/A+ close_and_invalidate (&stdin_pipe[0]);
19033N/A+ close_and_invalidate (&stdin_pipe[1]);
19033N/A+ close_and_invalidate (&stdout_pipe[0]);
19033N/A+ close_and_invalidate (&stdout_pipe[1]);
19033N/A+
19033N/A+ return False;
19033N/A+
19033N/A+ case 0:
19033N/A+ close (ConnectionNumber (si->dpy)); /* close display fd */
19033N/A+ /* limit_subproc_memory (p->inferior_memory_limit, p->verbose_p); */
19033N/A+ /* hack_subproc_environment (ssi); */ /* FIX $DISPLAY */
19033N/A+
19033N/A+ /* Inside Child Process */
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf (stderr, "%s: spawning \"%s\" in pid %lu.\n",
19033N/A+ blurb(), command, (unsigned long) getpid ());
19033N/A+
19033N/A+ close_and_invalidate (&stdin_pipe[1]);
19033N/A+ close_and_invalidate (&stdout_pipe[0]);
19033N/A+
19033N/A+ sane_dup2 (stdin_pipe[0], 0); /* Listen to Parent from here */
19033N/A+ sane_dup2 (stdout_pipe[1], 9); /* Talk to Parent from here */
19033N/A+
19033N/A+ /* Make sure we have relinquished setuid privs or lock dialog gtk
19033N/A+ * program will not run as libgtk is not setuid safe.
19033N/A+ */
19033N/A+ hack_uid (si);
19033N/A+
19033N/A+ exec_command (p->shell, command, 0);
19033N/A+ /* print_path_error (command); */
19033N/A+ fprintf (stderr, "%s: couldn't exec: %s\n",
19033N/A+ blurb (), command);
19033N/A+ abort ();
19033N/A+
19033N/A+ default:
19033N/A+ /* In Parent */
19033N/A+ make_job(forked, 0, command);
19033N/A+ close_and_invalidate (&stdin_pipe[0]);
19033N/A+ close_and_invalidate (&stdout_pipe[1]);
19033N/A+
19033N/A+ sane_dup2 (stdin_pipe[0], 0); /* Listen to Child from here */
19033N/A+ sane_dup2 (stdout_pipe[1], 13); /* Talk to Child from here */
19033N/A+
19033N/A+ pw->stdin_fd = stdin_pipe[1]; /* Talk to child from here */
19033N/A+ pw->stdout_fd = stdout_pipe[0]; /* Listen to Child from here */
19033N/A+ si->passwd_pid = forked;
19033N/A+
19033N/A+ /* Messages to child dialog are sent through this pipe/fd */
19033N/A+ pw->stdin_file = fdopen (pw->stdin_fd, "w");
19033N/A+ write_to_child (si, "Hello", NULL); /* Send a test message to Child */
19033N/A+
19033N/A+ /* Password from child dialog comes through this pipe/fd */
19033N/A+ pw->stdout_file = fdopen (pw->stdout_fd, "r");
19033N/A+
19033N/A+ pw->stdout_input_id = XtAppAddInput (si->app, pw->stdout_fd,
19033N/A+ (XtPointer) XtInputReadMask,
19033N/A+ handle_passwd_input, si);
19033N/A+
19033N/A+ /* Set global flag to indicate that lock dialog is visible */
19033N/A+ g_passwd_dialog_created = True;
19033N/A+ return True;
19033N/A+ }
19033N/A+
19033N/A+ /* shouldn't reach */
19033N/A+ abort ();
19033N/A+ return False;
19033N/A+}
19033N/A+#endif /* HAVE_XSCREENSAVER_LOCK */
19033N/A+
19033N/A static int
19033N/A new_passwd_window (saver_info *si)
19033N/A {
19033N/A passwd_dialog_data *pw;
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A Screen *screen;
19033N/A Colormap cmap;
19033N/A char *f;
19033N/A+#endif
19033N/A saver_screen_info *ssi = &si->screens [mouse_screen (si)];
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* si->pw_data is globally allocated and never freed when HAVE_XSS_LOCK */
19033N/A+ pw = si->pw_data;
19033N/A+ if (!spawn_external_passwd_process (si, pw))
19033N/A+ return -1;
19033N/A+ si->external_passwd = True;
19033N/A+#else
19033N/A pw = (passwd_dialog_data *) calloc (1, sizeof(*pw));
19033N/A if (!pw)
19033N/A return -1;
19033N/A@@ -199,17 +716,21 @@ new_passwd_window (saver_info *si)
19033N/A */
19033N/A pw->login_button_p = (si->prefs.new_login_command &&
19033N/A *si->prefs.new_login_command);
19033N/A+#endif
19033N/A
19033N/A pw->passwd_cursor = XCreateFontCursor (si->dpy, XC_top_left_arrow);
19033N/A
19033N/A pw->prompt_screen = ssi;
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A screen = pw->prompt_screen->screen;
19033N/A cmap = DefaultColormapOfScreen (screen);
19033N/A+#endif
19033N/A
19033N/A pw->show_stars_p = get_boolean_resource(si->dpy, "passwd.asterisks",
19033N/A "Boolean");
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A pw->heading_label = get_string_resource (si->dpy, "passwd.heading.label",
19033N/A "Dialog.Label.Label");
19033N/A pw->body_label = get_string_resource (si->dpy, "passwd.body.label",
19033N/A@@ -358,6 +879,7 @@ new_passwd_window (saver_info *si)
19033N/A if (pw->shadow_width == 0) pw->shadow_width = 4;
19033N/A if (pw->thermo_width == 0) pw->thermo_width = pw->shadow_width;
19033N/A
19033N/A+#endif /* ! HAVE_XSCREENSAVER_LOCK */
19033N/A
19033N/A /* We need to remember the mouse position and restore it afterward, or
19033N/A sometimes (perhaps only with Xinerama?) the mouse gets warped to
19033N/A@@ -422,12 +944,16 @@ make_passwd_window (saver_info *si,
19033N/A const char *prompt,
19033N/A Bool echo)
19033N/A {
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A XSetWindowAttributes attrs;
19033N/A unsigned long attrmask = 0;
19033N/A+#endif
19033N/A passwd_dialog_data *pw;
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A Screen *screen;
19033N/A Colormap cmap;
19033N/A Dimension max_string_width_px;
19033N/A+#endif
19033N/A saver_screen_info *ssi = &si->screens [mouse_screen (si)];
19033N/A
19033N/A cleanup_passwd_window (si);
19033N/A@@ -435,7 +961,12 @@ make_passwd_window (saver_info *si,
19033N/A if (! ssi) /* WTF? Trying to prompt while no screens connected? */
19033N/A return -1;
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* si->pw_data is globally allocated and never freed when HAVE_XSS_LOCK */
19033N/A+ if (!si->pw_data->got_windowid)
19033N/A+#else
19033N/A if (!si->pw_data)
19033N/A+#endif
19033N/A if (new_passwd_window (si) < 0)
19033N/A return -1;
19033N/A
19033N/A@@ -450,6 +981,29 @@ make_passwd_window (saver_info *si,
19033N/A blurb(), pw->prompt_screen->number,
19033N/A info_msg ? info_msg : "");
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* Wipe the old password, so we get prompted to enter new password. */
19033N/A+ if (pw->passwd_string)
19033N/A+ {
19033N/A+ memset(pw->passwd_string, 0, strlen (pw->passwd_string));
19033N/A+ free (pw->passwd_string);
19033N/A+ pw->passwd_string = NULL;
19033N/A+ }
19033N/A+
19033N/A+ if (info_msg)
19033N/A+ write_to_child (si, "ul_message", info_msg);
19033N/A+ if (prompt)
19033N/A+ {
19033N/A+ write_to_child (si, "ul_pamprompt", prompt);
19033N/A+
19033N/A+ if (echo)
19033N/A+ write_to_child (si, "ul_prompt_echo", "true");
19033N/A+ else if (pw->show_stars_p)
19033N/A+ write_to_child (si, "ul_prompt_echo", "stars");
19033N/A+ else
19033N/A+ write_to_child (si, "ul_prompt_echo", "false");
19033N/A+ }
19033N/A+#else
19033N/A screen = pw->prompt_screen->screen;
19033N/A cmap = DefaultColormapOfScreen (screen);
19033N/A
19033N/A@@ -687,11 +1241,13 @@ make_passwd_window (saver_info *si,
19033N/A if (cmap)
19033N/A XInstallColormap (si->dpy, cmap);
19033N/A draw_passwd_window (si);
19033N/A+#endif /* ! HAVE_XSCREENSAVER_LOCK */
19033N/A
19033N/A return 0;
19033N/A }
19033N/A
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A static void
19033N/A draw_passwd_window (saver_info *si)
19033N/A {
19033N/A@@ -1035,17 +1591,48 @@ draw_button(Display *dpy,
19033N/A draw_shaded_rectangle(dpy, dialog, x, y, width, height,
19033N/A shadow_width, shadow_light, shadow_dark);
19033N/A }
19033N/A+#endif /* !HAVE_XSCREENSAVER_LOCK */
19033N/A
19033N/A static void
19033N/A update_passwd_window (saver_info *si, const char *printed_passwd, float ratio)
19033N/A {
19033N/A passwd_dialog_data *pw = si->pw_data;
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A XGCValues gcv;
19033N/A GC gc1, gc2;
19033N/A int x, y;
19033N/A XRectangle rects[1];
19033N/A+#endif
19033N/A
19033N/A pw->ratio = ratio;
19033N/A+
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* Send countdown timer ratio to child lock dialog */
19033N/A+ if (si->passwd_dialog)
19033N/A+ {
19033N/A+ XEvent event;
19033N/A+
19033N/A+ event.xany.type = ClientMessage;
19033N/A+ event.xclient.display = si->dpy;
19033N/A+ event.xclient.window = si->passwd_dialog;
19033N/A+ event.xclient.message_type = XA_UNLOCK_RATIO;
19033N/A+ event.xclient.format = 32;
19033N/A+ memset (&event.xclient.data, 0, sizeof (event.xclient.data));
19033N/A+ event.xclient.data.l[0] = (long)(pw->ratio * 100);
19033N/A+ event.xclient.data.l[1] = 0;
19033N/A+ event.xclient.data.l[2] = 0;
19033N/A+
19033N/A+ if (!safe_XSendEvent (si->dpy, si->passwd_dialog, False, 0L, &event))
19033N/A+ fprintf (stderr, "%s: error sending ratio to lock dialog\n", blurb ());
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ if (si->prefs.verbose_p)
19033N/A+ fprintf (stderr,
19033N/A+ "-->update_passwd_window() lockdialog not created, returning!!\n");
19033N/A+ return;
19033N/A+ }
19033N/A+#else
19033N/A gcv.foreground = pw->passwd_foreground;
19033N/A gcv.font = pw->passwd_font->fid;
19033N/A gc1 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground|GCFont, &gcv);
19033N/A@@ -1187,6 +1774,7 @@ update_passwd_window (saver_info *si, const char *printed_passwd, float ratio)
19033N/A XFreeGC (si->dpy, gc1);
19033N/A XFreeGC (si->dpy, gc2);
19033N/A XSync (si->dpy, False);
19033N/A+#endif /* !HAVE_XSCREENSAVER_LOCK */
19033N/A }
19033N/A
19033N/A
19033N/A@@ -1218,6 +1806,9 @@ cleanup_passwd_window (saver_info *si)
19033N/A {
19033N/A passwd_dialog_data *pw;
19033N/A
19033N/A+ if (si->prefs.verbose_p)
19033N/A+ fprintf (stderr, "cleanup_passwd_window\n");
19033N/A+
19033N/A if (!(pw = si->pw_data))
19033N/A return;
19033N/A
19033N/A@@ -1234,7 +1825,12 @@ cleanup_passwd_window (saver_info *si)
19033N/A }
19033N/A
19033N/A memset (pw->typed_passwd, 0, sizeof(pw->typed_passwd));
19033N/A- memset (pw->passwd_string, 0, strlen(pw->passwd_string));
19033N/A+ if (pw->passwd_string)
19033N/A+ {
19033N/A+ memset (pw->passwd_string, 0, strlen(pw->passwd_string));
19033N/A+ free (pw->passwd_string);
19033N/A+ pw->passwd_string = NULL;
19033N/A+ }
19033N/A
19033N/A if (pw->timer)
19033N/A {
19033N/A@@ -1257,8 +1853,10 @@ destroy_passwd_window (saver_info *si)
19033N/A passwd_dialog_data *pw = si->pw_data;
19033N/A saver_screen_info *ssi = pw->prompt_screen;
19033N/A Colormap cmap = DefaultColormapOfScreen (ssi->screen);
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A Pixel black = BlackPixelOfScreen (ssi->screen);
19033N/A Pixel white = WhitePixelOfScreen (ssi->screen);
19033N/A+#endif
19033N/A XEvent event;
19033N/A
19033N/A cleanup_passwd_window (si);
19033N/A@@ -1274,6 +1872,81 @@ destroy_passwd_window (saver_info *si)
19033N/A si->cached_passwd = NULL;
19033N/A }
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* reset global flag to indicate passwd dialog is no longer there */
19033N/A+ g_passwd_dialog_created = False;
19033N/A+
19033N/A+ if (si->external_passwd)
19033N/A+ {
19033N/A+ /* kill the child etc. */
19033N/A+ write_to_child (si, "cmd_exit", NULL);
19033N/A+
19033N/A+ if (pw->stdin_file)
19033N/A+ fclose (pw->stdin_file);
19033N/A+ if (pw->stdin_fd != -1)
19033N/A+ close_and_invalidate (&pw->stdin_fd);
19033N/A+ if (pw->stdout_input_id)
19033N/A+ XtRemoveInput (pw->stdout_input_id);
19033N/A+ if (pw->stdout_file)
19033N/A+ fclose (pw->stdout_file);
19033N/A+ else if (pw->stdout_fd != -1)
19033N/A+ close_and_invalidate (&pw->stdout_fd);
19033N/A+
19033N/A+ if (si->passwd_pid)
19033N/A+ {
19033N/A+ kill_job (si, si->passwd_pid, SIGTERM);
19033N/A+ si->passwd_pid = 0;
19033N/A+ }
19033N/A+
19033N/A+ free (si->raise_wins);
19033N/A+ si->raise_wins = NULL;
19033N/A+ si->num_raise_wins = 0;
19033N/A+ si->max_raise_wins = 0;
19033N/A+
19033N/A+ if (si->override_wins)
19033N/A+ {
19033N/A+ int n;
19033N/A+
19033N/A+ unsigned long valuemask = CWOverrideRedirect;
19033N/A+ XSetWindowAttributes setwinattr;
19033N/A+ setwinattr.override_redirect = False;
19033N/A+
19033N/A+ for (n = 0; n < si->num_override_wins; n++)
19033N/A+ {
19033N/A+ XChangeWindowAttributes (si->dpy, si->override_wins[n],
19033N/A+ valuemask, &setwinattr);
19033N/A+ }
19033N/A+ free(si->override_wins);
19033N/A+ si->override_wins = NULL;
19033N/A+ }
19033N/A+ si->num_override_wins = 0;
19033N/A+ si->max_override_wins = 0;
19033N/A+
19033N/A+ si->pw_data->got_windowid = False;
19033N/A+ si->external_passwd = False;
19033N/A+
19033N/A+ /* restore any metacity keys we temporarily disabled */
19033N/A+ if (client)
19033N/A+ {
19033N/A+ if (global_switch_key)
19033N/A+ {
19033N/A+ gconf_client_set_string (client, switch_windows_gconf_key,
19033N/A+ global_switch_key, NULL);
19033N/A+ g_free(global_switch_key);
19033N/A+ global_switch_key = NULL;
19033N/A+ }
19033N/A+
19033N/A+ if (global_menu_key)
19033N/A+ {
19033N/A+ gconf_client_set_string (client, main_menu_gconf_key,
19033N/A+ global_menu_key, NULL);
19033N/A+ g_free(global_menu_key);
19033N/A+ global_menu_key = NULL;
19033N/A+ }
19033N/A+ }
19033N/A+ }
19033N/A+#endif /* HAVE_XSCREENSAVER_LOCK */
19033N/A+
19033N/A move_mouse_grab (si, RootWindowOfScreen (ssi->screen),
19033N/A ssi->cursor, ssi->number);
19033N/A
19033N/A@@ -1308,7 +1981,14 @@ destroy_passwd_window (saver_info *si)
19033N/A fprintf (stderr, "%s: %d: destroying password dialog.\n",
19033N/A blurb(), pw->prompt_screen->number);
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* Ignore X error if window was already closed by the child,
19033N/A+ and make sure any VisibilityNotify events are removed
19033N/A+ from the event queue before we forget the window id. */
19033N/A+ safe_XDestroyWindow (si->dpy, si->passwd_dialog);
19033N/A+#else
19033N/A XDestroyWindow (si->dpy, si->passwd_dialog);
19033N/A+#endif
19033N/A si->passwd_dialog = 0;
19033N/A }
19033N/A
19033N/A@@ -1319,6 +1999,7 @@ destroy_passwd_window (saver_info *si)
19033N/A pw->save_under = 0;
19033N/A }
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A if (pw->heading_label) free (pw->heading_label);
19033N/A if (pw->body_label) free (pw->body_label);
19033N/A if (pw->user_label) free (pw->user_label);
19033N/A@@ -1369,6 +2050,7 @@ destroy_passwd_window (saver_info *si)
19033N/A pw->logo_pixels = 0;
19033N/A pw->logo_npixels = 0;
19033N/A }
19033N/A+#endif /* ! HAVE_XSCREENSAVER_LOCK */
19033N/A
19033N/A if (pw->save_under)
19033N/A XFreePixmap (si->dpy, pw->save_under);
19033N/A@@ -1376,9 +2058,12 @@ destroy_passwd_window (saver_info *si)
19033N/A if (cmap)
19033N/A XInstallColormap (si->dpy, cmap);
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* si->pw_data is globally allocated and never freed when HAVE_XSS_LOCK */
19033N/A memset (pw, 0, sizeof(*pw));
19033N/A free (pw);
19033N/A si->pw_data = 0;
19033N/A+#endif
19033N/A }
19033N/A
19033N/A
19033N/A@@ -1391,6 +2076,49 @@ ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error)
19033N/A return 0;
19033N/A }
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+/* Catch errors from XRestackWindows, since there's an inherent race
19033N/A+ condition in which other clients can destroy windows between when
19033N/A+ we get the notification event and when we send the RestackWindows
19033N/A+ response to it. */
19033N/A+static Bool
19033N/A+safe_XRestackWindows(Display *dpy, Window windows[], int nwindows)
19033N/A+{
19033N/A+ XErrorHandler old_handler;
19033N/A+ XSync (dpy, False);
19033N/A+ error_handler_hit_p = False;
19033N/A+ old_handler = XSetErrorHandler (ignore_all_errors_ehandler);
19033N/A+
19033N/A+ XRestackWindows (dpy, windows, nwindows);
19033N/A+
19033N/A+ XSync (dpy, False);
19033N/A+ XSetErrorHandler (old_handler);
19033N/A+ XSync (dpy, False);
19033N/A+
19033N/A+ return (!error_handler_hit_p);
19033N/A+}
19033N/A+
19033N/A+static Bool
19033N/A+safe_XSendEvent(Display *dpy, Window w, Bool propagate,
19033N/A+ long event_mask, XEvent *event_send)
19033N/A+{
19033N/A+ Status status;
19033N/A+ XErrorHandler old_handler;
19033N/A+ XSync (dpy, False);
19033N/A+ error_handler_hit_p = False;
19033N/A+ old_handler = XSetErrorHandler (ignore_all_errors_ehandler);
19033N/A+
19033N/A+ status = XSendEvent (dpy, w, propagate, event_mask, event_send);
19033N/A+
19033N/A+ XSync (dpy, False);
19033N/A+ XSetErrorHandler (old_handler);
19033N/A+ XSync (dpy, False);
19033N/A+
19033N/A+ return (!error_handler_hit_p && status);
19033N/A+}
19033N/A+
19033N/A+#endif
19033N/A+
19033N/A
19033N/A #ifdef HAVE_XHPDISABLERESET
19033N/A /* This function enables and disables the C-Sh-Reset hot-key, which
19033N/A@@ -1592,6 +2320,17 @@ passwd_animate_timer (XtPointer closure, XtIntervalId *id)
19033N/A
19033N/A if (!pw) return;
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* We want to make sure dialog is up before we update countdown timer */
19033N/A+ if (!si->passwd_dialog)
19033N/A+ {
19033N/A+ if (si->prefs.verbose_p)
19033N/A+ fprintf (stderr,
19033N/A+ "-->passwd_animate_timer() returning..no dialog yet\n");
19033N/A+ return;
19033N/A+ }
19033N/A+#endif
19033N/A+
19033N/A pw->ratio -= (1.0 / ((double) si->prefs.passwd_timeout / (double) tick));
19033N/A if (pw->ratio < 0)
19033N/A {
19033N/A@@ -1611,6 +2350,7 @@ passwd_animate_timer (XtPointer closure, XtIntervalId *id)
19033N/A idle_timer ((XtPointer) si, 0);
19033N/A }
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A
19033N/A static XComposeStatus *compose_status;
19033N/A
19033N/A@@ -1688,11 +2428,13 @@ finished_typing_passwd (saver_info *si, passwd_dialog_data *pw)
19033N/A update_passwd_window (si, "", pw->ratio);
19033N/A }
19033N/A }
19033N/A+#endif /* !HAVE_XSCREENSAVER_LOCK */
19033N/A
19033N/A static void
19033N/A handle_passwd_key (saver_info *si, XKeyEvent *event)
19033N/A {
19033N/A passwd_dialog_data *pw = si->pw_data;
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A int pw_size = sizeof (pw->typed_passwd) - 1;
19033N/A char *typed_passwd = pw->typed_passwd;
19033N/A char s[2];
19033N/A@@ -1705,11 +2447,41 @@ handle_passwd_key (saver_info *si, XKeyEvent *event)
19033N/A s[1] = 0;
19033N/A
19033N/A pw->passwd_changed_p = True;
19033N/A+#endif /* !HAVE_XSCREENSAVER_LOCK */
19033N/A
19033N/A /* Add 10% to the time remaining every time a key is pressed. */
19033N/A pw->ratio += 0.1;
19033N/A if (pw->ratio > 1) pw->ratio = 1;
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ if (si->pw_data->got_windowid)
19033N/A+ {
19033N/A+ Bool status;
19033N/A+
19033N/A+ if (si->prefs.verbose_p)
19033N/A+ fprintf (stderr, "event loop..gotwindowid..and keypress event...\n");
19033N/A+
19033N/A+ event->window = si->passwd_dialog;
19033N/A+
19033N/A+ status = safe_XSendEvent (si->dpy, si->passwd_dialog,
19033N/A+ False, KeyPressMask, (XEvent *) event);
19033N/A+
19033N/A+ if (si->prefs.verbose_p)
19033N/A+ {
19033N/A+ if (status)
19033N/A+ fprintf (stderr, "sent key...\n");
19033N/A+ else
19033N/A+ fprintf (stderr, "error %d sending key...\n", status);
19033N/A+ }
19033N/A+ update_passwd_window (si, NULL, pw->ratio);
19033N/A+ }
19033N/A+ else
19033N/A+ {
19033N/A+ swallow_unlock_typeahead_events (si, (XEvent *) event);
19033N/A+ }
19033N/A+
19033N/A+#else /* !HAVE_XSCREENSAVER_LOCK */
19033N/A+
19033N/A switch (*s)
19033N/A {
19033N/A case '\010': case '\177': /* Backspace */
19033N/A@@ -1779,6 +2551,7 @@ handle_passwd_key (saver_info *si, XKeyEvent *event)
19033N/A {
19033N/A update_passwd_window (si, "", pw->ratio);
19033N/A }
19033N/A+#endif /* !HAVE_XSCREENSAVER_LOCK */
19033N/A }
19033N/A
19033N/A
19033N/A@@ -1801,7 +2574,9 @@ passwd_event_loop (saver_info *si)
19033N/A
19033N/A passwd_animate_timer ((XtPointer) si, 0);
19033N/A
19033N/A- while (si->unlock_state == ul_read)
19033N/A+ si->pw_data->got_passwd = FALSE;
19033N/A+
19033N/A+ while (si->unlock_state == ul_read && si->pw_data->got_passwd == FALSE)
19033N/A {
19033N/A XtAppNextEvent (si->app, &event.x_event);
19033N/A
19033N/A@@ -1842,12 +2617,17 @@ passwd_event_loop (saver_info *si)
19033N/A
19033N/A if (event.x_event.xany.window == si->passwd_dialog &&
19033N/A event.x_event.xany.type == Expose)
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ XtDispatchEvent (&event.x_event);
19033N/A+#else
19033N/A draw_passwd_window (si);
19033N/A+#endif /* !HAVE_XSCREENSAVER_LOCK */
19033N/A else if (event.x_event.xany.type == KeyPress)
19033N/A {
19033N/A handle_passwd_key (si, &event.x_event.xkey);
19033N/A si->pw_data->caps_p = (event.x_event.xkey.state & LockMask);
19033N/A }
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A else if (event.x_event.xany.type == ButtonPress ||
19033N/A event.x_event.xany.type == ButtonRelease)
19033N/A {
19033N/A@@ -1856,6 +2636,82 @@ passwd_event_loop (saver_info *si)
19033N/A if (si->pw_data->login_button_p)
19033N/A handle_login_button (si, &event.x_event);
19033N/A }
19033N/A+#endif /* !HAVE_XSCREENSAVER_LOCK */
19033N/A+
19033N/A+ /*
19033N/A+ 5077974 P1 "Bug 147583: Screen Lock unlocks because of GOK dwell movement in
19033N/A+ core pointer mode"
19033N/A+
19033N/A+ ScreenLock did not unlock the screen, but WM's XRestackWindow() did.
19033N/A+ Once WM/metacity fixes the problem, the code can be removed.
19033N/A+ The problem:
19033N/A+ repositioning the Wids in the wrong positions when
19033N/A+ 1. the window type is changed from NORMAL to DOCK or vice versa
19033N/A+ 2. the Wid is managed
19033N/A+ within the X window stack with or without screen-lock in a mixed Wids
19033N/A+ there are two temp. get-around solutions:
19033N/A+ 1. non-managed GOK or MAG Wid
19033N/A+ or
19033N/A+ 2. screensaver picks up the WM's restacking task and fixes the prevous
19033N/A+ restacking problem.
19033N/A+ the cons: there is a flashing screen when corepointer is touching
19033N/A+ GOK or MAG and mouse is moved in a fast way
19033N/A+ when GOK or MAG window type is DOCK only.
19033N/A+ and it is not a good temp. get-around solution.
19033N/A+ This is the only choice if WM did not want to fix the problem now
19033N/A+ and AT group did not want to use non-managed Wids.
19033N/A+ Now, GOK only supports 2nd USB/mouse/Dwell, corepointer is supposed
19033N/A+ not to be used, and GOK cannot disable it
19033N/A+ */
19033N/A+/*
19033N/A+ bugid 6769901,6839026: popup windows appearing through xscreensaver
19033N/A+*/
19033N/A+ else if (((event.x_event.xany.type == UnmapNotify)
19033N/A+ || (event.x_event.xany.type == MapNotify)
19033N/A+ || (event.x_event.xany.type == VisibilityNotify)
19033N/A+ || (event.x_event.xany.type == ConfigureNotify)
19033N/A+ || (event.x_event.xany.type == PropertyNotify)
19033N/A+ || (event.x_event.xany.type == CreateNotify)
19033N/A+ || (event.x_event.xany.type == ReparentNotify))
19033N/A+ && (si->passwd_dialog))
19033N/A+ {
19033N/A+ /* Find the handle of popup window
19033N/A+ * Note: we can not get handle of popup window with
19033N/A+ * event.xany.window, thats why we have switch cases.
19033N/A+ */
19033N/A+ Window wPopWin = 0;
19033N/A+
19033N/A+ switch(event.x_event.xany.type)
19033N/A+ {
19033N/A+ case ConfigureNotify:
19033N/A+ wPopWin = event.x_event.xconfigure.window;
19033N/A+ break;
19033N/A+ case CreateNotify:
19033N/A+ wPopWin = event.x_event.xcreatewindow.window;
19033N/A+ break;
19033N/A+ case VisibilityNotify:
19033N/A+ wPopWin = event.x_event.xvisibility.window;
19033N/A+ break;
19033N/A+ default:
19033N/A+ break;
19033N/A+ }
19033N/A+
19033N/A+ if (wPopWin)
19033N/A+ {
19033N/A+ saver_screen_info *ssi = find_screen_for_window (si, wPopWin);
19033N/A+
19033N/A+ /* This if case is for safety, it prevent screensaver stuck in
19033N/A+ * loop of ConfigureNotify
19033N/A+ */
19033N/A+ if ((wPopWin != si->passwd_dialog) && (ssi != NULL) &&
19033N/A+ (wPopWin != ssi->screensaver_window) &&
19033N/A+ (wPopWin != ssi->stderr_overlay_window))
19033N/A+ {
19033N/A+ restack_my_windows(si, ssi, wPopWin);
19033N/A+ }
19033N/A+ }
19033N/A+ }
19033N/A+ /* the above new code for restacking under the condition */
19033N/A else
19033N/A XtDispatchEvent (&event.x_event);
19033N/A }
19033N/A@@ -1881,8 +2737,13 @@ passwd_event_loop (saver_info *si)
19033N/A
19033N/A if (msg)
19033N/A {
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ write_to_child (si, "ul_message", msg);
19033N/A+ usleep (250000); /* 1/4 second */
19033N/A+#else
19033N/A si->pw_data->i_beam = 0;
19033N/A update_passwd_window (si, msg, 0.0);
19033N/A+#endif
19033N/A XSync (si->dpy, False);
19033N/A
19033N/A /* Swallow all pending KeyPress/KeyRelease events. */
19033N/A@@ -1898,6 +2759,10 @@ passwd_event_loop (saver_info *si)
19033N/A static void
19033N/A handle_typeahead (saver_info *si)
19033N/A {
19033N/A+/* HAVE_XSCREENSAVER_LOCK: typeahead events are flushed to the external
19033N/A+ dialog program in handle_passwd_input when we get the dialog_win notice
19033N/A+ that it has created the window */
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A passwd_dialog_data *pw = si->pw_data;
19033N/A int i;
19033N/A if (!si->unlock_typeahead)
19033N/A@@ -1918,6 +2783,7 @@ handle_typeahead (saver_info *si)
19033N/A
19033N/A free (si->unlock_typeahead);
19033N/A si->unlock_typeahead = 0;
19033N/A+#endif
19033N/A }
19033N/A
19033N/A
19033N/A@@ -2023,9 +2889,11 @@ gui_auth_conv(int num_msg,
19033N/A free(prompt_trimmed);
19033N/A }
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A compose_status = calloc (1, sizeof (*compose_status));
19033N/A if (!compose_status)
19033N/A goto fail;
19033N/A+#endif
19033N/A
19033N/A si->unlock_state = ul_read;
19033N/A
19033N/A@@ -2035,7 +2903,14 @@ gui_auth_conv(int num_msg,
19033N/A if (si->unlock_state == ul_cancel)
19033N/A goto fail;
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ if ((si->unlock_state != ul_time) && si->pw_data->passwd_string)
19033N/A+ responses[i].response = strdup (si->pw_data->passwd_string);
19033N/A+ else
19033N/A+ goto fail;
19033N/A+#else
19033N/A responses[i].response = strdup(si->pw_data->typed_passwd);
19033N/A+#endif
19033N/A
19033N/A /* Cache the first response to a PROMPT_NOECHO to save prompting for
19033N/A * each auth mechanism. */
19033N/A@@ -2043,8 +2918,10 @@ gui_auth_conv(int num_msg,
19033N/A auth_msgs[i].type == AUTH_MSGTYPE_PROMPT_NOECHO)
19033N/A si->cached_passwd = strdup(responses[i].response);
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A free (compose_status);
19033N/A compose_status = 0;
19033N/A+#endif
19033N/A }
19033N/A
19033N/A *resp = responses;
19033N/A@@ -2052,8 +2929,10 @@ gui_auth_conv(int num_msg,
19033N/A return (si->unlock_state == ul_finished) ? 0 : -1;
19033N/A
19033N/A fail:
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A if (compose_status)
19033N/A free (compose_status);
19033N/A+#endif
19033N/A
19033N/A if (responses)
19033N/A {
19033N/A@@ -2109,11 +2988,14 @@ auth_finished_cb (saver_info *si)
19033N/A if (XPending (si->dpy))
19033N/A {
19033N/A XNextEvent (si->dpy, &event);
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A if (event.xany.window == si->passwd_dialog &&
19033N/A event.xany.type == Expose)
19033N/A draw_passwd_window (si);
19033N/A- else if (event.xany.type == ButtonPress ||
19033N/A- event.xany.type == KeyPress)
19033N/A+ else
19033N/A+#endif
19033N/A+ if (event.xany.type == ButtonPress ||
19033N/A+ event.xany.type == KeyPress)
19033N/A break;
19033N/A XSync (si->dpy, False);
19033N/A }
19033N/Adiff --git xscreensaver-5.12/driver/passwd-pam.c xscreensaver-5.12/driver/passwd-pam.c
19033N/A--- xscreensaver-5.12/driver/passwd-pam.c
19033N/A+++ xscreensaver-5.12/driver/passwd-pam.c
19033N/A@@ -39,10 +39,16 @@
19033N/A #ifndef NO_LOCKING /* whole file */
19033N/A
19033N/A #include <stdlib.h>
19033N/A+#include <xscreensaver-intl.h>
19033N/A+
19033N/A #ifdef HAVE_UNISTD_H
19033N/A # include <unistd.h>
19033N/A #endif
19033N/A
19033N/A+#ifdef __sun
19033N/A+# include <deflt.h>
19033N/A+#endif
19033N/A+
19033N/A extern char *blurb(void);
19033N/A
19033N/A
19033N/A@@ -58,6 +64,7 @@ extern char *blurb(void);
19033N/A
19033N/A #include <sys/stat.h>
19033N/A
19033N/A+#include "dialog-data.h"
19033N/A #include "auth.h"
19033N/A
19033N/A extern sigset_t block_sigchld (void);
19033N/A@@ -82,7 +89,10 @@ extern void unblock_sigchld (void);
19033N/A #endif
19033N/A
19033N/A static int pam_conversation (int nmsgs,
19033N/A- const struct pam_message **msg,
19033N/A+#ifndef __sun
19033N/A+ const
19033N/A+#endif
19033N/A+ struct pam_message **msg,
19033N/A struct pam_response **resp,
19033N/A void *closure);
19033N/A
19033N/A@@ -183,6 +193,11 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
19033N/A struct pam_conv pc;
19033N/A sigset_t set;
19033N/A struct timespec timeout;
19033N/A+ int pam_auth_status = 0; /* Specific for pam_authenticate() status*/
19033N/A+ int acct_rc, setcred_rc, chauth_rc;
19033N/A+ int pam_flags = 0;
19033N/A+
19033N/A+ uid_t euid = geteuid();
19033N/A
19033N/A pc.conv = &pam_conversation;
19033N/A pc.appdata_ptr = (void *) si;
19033N/A@@ -191,6 +206,23 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
19033N/A `closure' argument to pc.conv always comes in as random garbage. */
19033N/A suns_pam_implementation_blows = (void *) si;
19033N/A
19033N/A+#ifdef __sun
19033N/A+ if (verbose_p)
19033N/A+ fprintf (stderr, "Before uid=%d euid=%d \n\n", getuid(), geteuid());
19033N/A+
19033N/A+ if (seteuid (0) != 0)
19033N/A+ {
19033N/A+ if (verbose_p)
19033N/A+ perror("Could not change euid to root, pam may not work!\n");
19033N/A+ }
19033N/A+
19033N/A+ if (verbose_p)
19033N/A+ {
19033N/A+ fprintf (stderr, "After seteuid(0) uid=%d euid=%d \n\n",
19033N/A+ getuid(), geteuid());
19033N/A+ fprintf (stderr, "PAM is using SERVICE_NAME=\"%s\"\n\n", service);
19033N/A+ }
19033N/A+#endif
19033N/A
19033N/A /* Initialize PAM.
19033N/A */
19033N/A@@ -201,11 +233,35 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
19033N/A status, PAM_STRERROR (pamh, status));
19033N/A if (status != PAM_SUCCESS) goto DONE;
19033N/A
19033N/A+#ifdef __sun
19033N/A+ /* Check /etc/default/login to see if we should add
19033N/A+ PAM_DISALLOW_NULL_AUTHTOK to pam_flags */
19033N/A+ if (defopen("/etc/default/login") == 0) {
19033N/A+ char *ptr;
19033N/A+ int flags = defcntl(DC_GETFLAGS, 0);
19033N/A+
19033N/A+ TURNOFF(flags, DC_CASE);
19033N/A+ (void) defcntl(DC_SETFLAGS, flags);
19033N/A+ if ((ptr = defread("PASSREQ=")) != NULL &&
19033N/A+ strcasecmp("YES", ptr) == 0)
19033N/A+ {
19033N/A+ pam_flags |= PAM_DISALLOW_NULL_AUTHTOK;
19033N/A+ }
19033N/A+
19033N/A+ (void) defopen((char *)NULL); /* close current file */
19033N/A+ }
19033N/A+#endif
19033N/A+
19033N/A /* #### We should set PAM_TTY to the display we're using, but we
19033N/A don't have that handy from here. So set it to :0.0, which is a
19033N/A good guess (and has the bonus of counting as a "secure tty" as
19033N/A far as PAM is concerned...)
19033N/A */
19033N/A+
19033N/A+/* From the pam trace and log file, it is found out that the
19033N/A+ Sun pam modules can drive itself.
19033N/A+*/
19033N/A+#ifndef __sun
19033N/A {
19033N/A char *tty = strdup (":0.0");
19033N/A status = pam_set_item (pamh, PAM_TTY, tty);
19033N/A@@ -214,6 +270,7 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
19033N/A blurb(), tty, status, PAM_STRERROR(pamh, status));
19033N/A free (tty);
19033N/A }
19033N/A+#endif
19033N/A
19033N/A /* Try to authenticate as the current user.
19033N/A We must turn off our SIGCHLD handler for the duration of the call to
19033N/A@@ -243,43 +300,101 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
19033N/A timeout.tv_sec = 0;
19033N/A timeout.tv_nsec = 1;
19033N/A set = block_sigchld();
19033N/A- status = pam_authenticate (pamh, 0);
19033N/A+ pam_auth_status = pam_authenticate (pamh, pam_flags);
19033N/A # ifdef HAVE_SIGTIMEDWAIT
19033N/A sigtimedwait (&set, NULL, &timeout);
19033N/A /* #### What is the portable thing to do if we don't have it? */
19033N/A # endif /* HAVE_SIGTIMEDWAIT */
19033N/A unblock_sigchld();
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* Send status message to unlock dialog */
19033N/A+ if (pam_auth_status == PAM_SUCCESS)
19033N/A+ {
19033N/A+ if (verbose_p)
19098N/A+ write_to_child (si, "ul_ok", PAM_STRERROR (pamh, pam_auth_status));
19033N/A+ }
19033N/A+ else if (si->unlock_state != ul_cancel && si->unlock_state != ul_time)
19033N/A+ {
19033N/A+ write_to_child (si, "ul_fail", PAM_STRERROR (pamh, pam_auth_status));
19033N/A+ }
19098N/A+ if (verbose_p)
19098N/A+ sleep (1);
19033N/A+#endif
19033N/A+
19033N/A+ if (verbose_p)
19033N/A+ fprintf (stderr, "after calling pam_authenticate state is: %s\n",
19033N/A+ si->unlock_state == ul_success ? "ul_success" : "ul_fail");
19033N/A+
19033N/A if (verbose_p)
19033N/A fprintf (stderr, "%s: pam_authenticate (...) ==> %d (%s)\n",
19033N/A- blurb(), status, PAM_STRERROR(pamh, status));
19033N/A+ blurb(), pam_auth_status, PAM_STRERROR(pamh, pam_auth_status));
19033N/A
19033N/A- if (status == PAM_SUCCESS) /* Win! */
19033N/A+ if (pam_auth_status == PAM_SUCCESS) /* Win! */
19033N/A {
19033N/A- int status2;
19033N/A+ /* perform PAM account validation procedures for login user only */
19033N/A+ acct_rc = pam_acct_mgmt(pamh, pam_flags);
19033N/A
19033N/A- /* We don't actually care if the account modules fail or succeed,
19033N/A- * but we need to run them anyway because certain pam modules
19033N/A- * depend on side effects of the account modules getting run.
19033N/A- */
19033N/A- status2 = pam_acct_mgmt (pamh, 0);
19033N/A+ /******************************************************************
19033N/A+ ignore other cases for the time being
19033N/A+ PAM_USER_UNKNOWN, PAM_AUTH_ERR, PAM_ACCT_EXPIRED
19033N/A+ (password mgn service module)
19033N/A+ same as pam_setcred(), focus on auth. service module only
19033N/A+ *****************************************************************/
19033N/A
19033N/A if (verbose_p)
19033N/A fprintf (stderr, "%s: pam_acct_mgmt (...) ==> %d (%s)\n",
19033N/A- blurb(), status2, PAM_STRERROR(pamh, status2));
19033N/A+ blurb(), acct_rc, PAM_STRERROR(pamh, acct_rc));
19033N/A+
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* Send status message to unlock dialog ***/
19033N/A+ if (acct_rc == PAM_SUCCESS)
19098N/A+ {
19098N/A+ if (verbose_p)
19098N/A+ write_to_child (si, "ul_acct_ok", PAM_STRERROR(pamh, acct_rc));
19098N/A+ }
19033N/A+ else
19033N/A+ write_to_child (si, "ul_acct_fail", PAM_STRERROR(pamh, acct_rc));
19033N/A+ if (verbose_p)
19033N/A+ sleep (1);
19033N/A+#endif
19033N/A
19033N/A /* HPUX for some reason likes to make PAM defines different from
19033N/A * everyone else's. */
19033N/A #ifdef PAM_AUTHTOKEN_REQD
19033N/A- if (status2 == PAM_AUTHTOKEN_REQD)
19033N/A+ if (acct_rc == PAM_AUTHTOKEN_REQD)
19033N/A #else
19033N/A- if (status2 == PAM_NEW_AUTHTOK_REQD)
19033N/A+ if (acct_rc == PAM_NEW_AUTHTOK_REQD)
19033N/A #endif
19033N/A {
19033N/A- status2 = pam_chauthtok (pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
19033N/A+ for (int i = 0; i < 3; i++)
19033N/A+ {
19033N/A+ chauth_rc = pam_chauthtok (pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
19033N/A+ if (chauth_rc == PAM_AUTHTOK_ERR ||
19033N/A+ chauth_rc == PAM_TRY_AGAIN )
19033N/A+ {
19033N/A+ i = 0;
19033N/A+ si->unlock_state = ul_read;
19033N/A+ }
19033N/A+ else break; /* get out of the loop */
19033N/A+ }
19033N/A+
19033N/A if (verbose_p)
19033N/A fprintf (stderr, "%s: pam_chauthtok (...) ==> %d (%s)\n",
19033N/A- blurb(), status2, PAM_STRERROR(pamh, status2));
19033N/A+ blurb(), chauth_rc, PAM_STRERROR(pamh, chauth_rc));
19033N/A+
19033N/A+ if (chauth_rc != PAM_SUCCESS)
19033N/A+ {
19033N/A+ pam_auth_status = chauth_rc;
19033N/A+ goto DONE;
19033N/A+ }
19033N/A+ }
19033N/A+ else if (acct_rc != PAM_SUCCESS)
19033N/A+ {
19033N/A+ pam_auth_status = acct_rc;
19033N/A+ write_to_child (si, "pw_acct_fail", PAM_STRERROR(pamh, acct_rc));
19033N/A+ sleep (3);
19033N/A+ goto DONE;
19033N/A }
19033N/A
19033N/A /* Each time we successfully authenticate, refresh credentials,
19098N/A@@ -291,24 +406,57 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
19033N/A says that the Linux PAM library ignores that one, and only refreshes
19033N/A credentials when using PAM_REINITIALIZE_CRED.
19033N/A */
19033N/A- status2 = pam_setcred (pamh, PAM_REINITIALIZE_CRED);
19033N/A+ setcred_rc = pam_setcred (pamh, PAM_REINITIALIZE_CRED);
19033N/A if (verbose_p)
19033N/A fprintf (stderr, "%s: pam_setcred (...) ==> %d (%s)\n",
19033N/A- blurb(), status2, PAM_STRERROR(pamh, status2));
19033N/A+ blurb(), setcred_rc, PAM_STRERROR(pamh, setcred_rc));
19033N/A+
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* Send status message to unlock dialog ***/
19033N/A+ if (setcred_rc == PAM_SUCCESS)
19098N/A+ {
19098N/A+ if (verbose_p)
19098N/A+ write_to_child (si, "ul_setcred_ok", PAM_STRERROR(pamh, setcred_rc));
19098N/A+ }
19033N/A+ else
19033N/A+ write_to_child (si, "ul_setcred_fail", PAM_STRERROR(pamh, setcred_rc));
19033N/A+ if (verbose_p)
19033N/A+ sleep (1);
19033N/A+#endif
19033N/A }
19033N/A
19033N/A DONE:
19033N/A if (pamh)
19033N/A {
19033N/A- int status2 = pam_end (pamh, status);
19033N/A- pamh = 0;
19033N/A+ int status2 = pam_end (pamh, pam_auth_status);
19033N/A+ pamh = NULL;
19033N/A if (verbose_p)
19033N/A fprintf (stderr, "%s: pam_end (...) ==> %d (%s)\n",
19033N/A blurb(), status2,
19033N/A (status2 == PAM_SUCCESS ? "Success" : "Failure"));
19033N/A }
19033N/A
19033N/A- if (status == PAM_SUCCESS)
19033N/A+ if (seteuid (euid) != 0)
19033N/A+ {
19033N/A+ if (verbose_p)
19033N/A+ perror("Error pam could not revert euid to user running as euid root,"
19033N/A+ " locking may not work now\n");
19033N/A+ }
19033N/A+
19033N/A+ if (verbose_p)
19033N/A+ fprintf (stderr,
19033N/A+ "<--end of pam_authenticate() returning ok_to_unblank = %d\n",
19033N/A+ (int) ((pam_auth_status == PAM_SUCCESS) ? True : False));
19033N/A+
19033N/A+ if (si->pw_data->passwd_string)
19033N/A+ {
19033N/A+ memset(si->pw_data->passwd_string, 0,
19033N/A+ strlen(si->pw_data->passwd_string));
19033N/A+ free (si->pw_data->passwd_string);
19033N/A+ si->pw_data->passwd_string = NULL;
19033N/A+ }
19033N/A+
19033N/A+ if (pam_auth_status == PAM_SUCCESS)
19033N/A si->unlock_state = ul_success; /* yay */
19033N/A else if (si->unlock_state == ul_cancel ||
19033N/A si->unlock_state == ul_time)
19098N/A@@ -334,6 +482,13 @@ pam_priv_init (int argc, char **argv, Bool verbose_p)
19033N/A const char file2[] = "/etc/pam.conf";
19033N/A struct stat st;
19033N/A
19033N/A+#ifdef __sun
19033N/A+ if (! verbose_p) /* SUN addition: only print warnings in verbose mode */
19033N/A+ { /* since they are rarely useful and mostly just */
19033N/A+ return True; /* cause confusion when users see them. */
19033N/A+ }
19033N/A+#endif
19033N/A+
19033N/A # ifndef S_ISDIR
19033N/A # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
19033N/A # endif
19098N/A@@ -360,6 +515,8 @@ pam_priv_init (int argc, char **argv, Bool verbose_p)
19033N/A break;
19033N/A }
19033N/A fclose (f);
19033N/A+
19033N/A+#ifndef __sun /* disable the misleading message */
19033N/A if (!ok)
19033N/A {
19033N/A fprintf (stderr,
19098N/A@@ -367,9 +524,11 @@ pam_priv_init (int argc, char **argv, Bool verbose_p)
19033N/A "%s: password authentication via PAM is unlikely to work.\n",
19033N/A blurb(), file2, PAM_SERVICE_NAME, blurb());
19033N/A }
19033N/A+#endif
19033N/A }
19033N/A /* else warn about file2 existing but being unreadable? */
19033N/A }
19033N/A+#ifndef __sun /* disable the misleading message */
19033N/A else
19033N/A {
19033N/A fprintf (stderr,
19098N/A@@ -377,15 +536,19 @@ pam_priv_init (int argc, char **argv, Bool verbose_p)
19033N/A "%s: password authentication via PAM is unlikely to work.\n",
19033N/A blurb(), file2, file, blurb());
19033N/A }
19033N/A+#endif
19033N/A
19033N/A /* Return true anyway, just in case. */
19033N/A return True;
19033N/A }
19033N/A
19033N/A
19033N/A-static int
19033N/A+int
19033N/A pam_conversation (int nmsgs,
19033N/A- const struct pam_message **msg,
19033N/A+#ifndef __sun
19033N/A+ const
19033N/A+#endif
19033N/A+ struct pam_message **msg,
19033N/A struct pam_response **resp,
19033N/A void *vsaver_info)
19033N/A {
19033N/Adiff --git xscreensaver-5.12/driver/passwd.c xscreensaver-5.12/driver/passwd.c
19033N/A--- xscreensaver-5.12/driver/passwd.c
19033N/A+++ xscreensaver-5.12/driver/passwd.c
19033N/A@@ -35,6 +35,7 @@
19033N/A
19033N/A #include <X11/Intrinsic.h>
19033N/A
19033N/A+#include "dialog-data.h"
19033N/A #include "xscreensaver.h"
19033N/A #include "auth.h"
19033N/A
19033N/Adiff --git xscreensaver-5.12/driver/setuid.c xscreensaver-5.12/driver/setuid.c
19033N/A--- xscreensaver-5.12/driver/setuid.c
19033N/A+++ xscreensaver-5.12/driver/setuid.c
19033N/A@@ -145,7 +145,10 @@ set_ids_by_number (uid_t uid, gid_t gid, char **message_ret)
19033N/A gid_errno = errno ? errno : -1;
19033N/A
19033N/A errno = 0;
19033N/A- if (setuid (uid) != 0)
19033N/A+/*mali if (setuid (uid) != 0)**we need root privs back at pam_authenticate
19033N/A+ this is causing to loose root priv for good, not good **/
19033N/A+
19033N/A+ if (seteuid (uid) != 0)
19033N/A uid_errno = errno ? errno : -1;
19033N/A
19033N/A if (uid_errno == 0 && gid_errno == 0 && sgs_errno == 0)
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@@ -243,7 +243,11 @@ show_job_list (void)
19033N/A
19033N/A static void clean_job_list (void);
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+struct screenhack_job *
19033N/A+#else
19033N/A static struct screenhack_job *
19033N/A+#endif
19033N/A make_job (pid_t pid, int screen, const char *cmd)
19033N/A {
19033N/A struct screenhack_job *job = (struct screenhack_job *) malloc (sizeof(*job));
19033N/A@@ -407,7 +411,11 @@ unblock_sigchld (void)
19033N/A block_sigchld_handler--;
19033N/A }
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+int
19033N/A+#else
19033N/A static int
19033N/A+#endif
19033N/A kill_job (saver_info *si, pid_t pid, int signal)
19033N/A {
19033N/A saver_preferences *p = &si->prefs;
19033N/A@@ -590,9 +598,14 @@ describe_dead_child (saver_info *si, pid_t kid, int wait_status)
19033N/A mention them) if we've just killed the subprocess. But mention them
19033N/A if they happen on their own.
19033N/A */
19033N/A- if (!job ||
19033N/A- (exit_status != 0 &&
19033N/A- (p->verbose_p || job->status != job_killed)))
19033N/A+
19033N/A+ if ((!job
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ && kid != si->passwd_pid
19033N/A+#endif /* HAVE_XSCREENSAVER_LOCK */
19033N/A+ ) ||
19033N/A+ (exit_status != 0 &&
19033N/A+ (p->verbose_p || (job && job->status != job_killed))))
19033N/A {
19033N/A /* Don't call fprintf() from signal handlers, as it might malloc.
19033N/A fprintf (stderr,
19033N/A@@ -632,8 +645,12 @@ describe_dead_child (saver_info *si, pid_t kid, int wait_status)
19033N/A else if (WIFSIGNALED (wait_status))
19033N/A {
19033N/A if (p->verbose_p ||
19033N/A- !job ||
19033N/A- job->status != job_killed ||
19033N/A+ (!job
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ && kid != si->passwd_pid
19033N/A+#endif /* HAVE_XSCREENSAVER_LOCK */
19033N/A+ ) ||
19033N/A+ (job && job->status != job_killed) ||
19033N/A WTERMSIG (wait_status) != SIGTERM)
19033N/A {
19033N/A /* Don't call fprintf() from signal handlers, as it might malloc.
19033N/A@@ -701,12 +718,20 @@ describe_dead_child (saver_info *si, pid_t kid, int wait_status)
19033N/A /* Clear out the pid so that screenhack_running_p() knows it's dead.
19033N/A */
19033N/A if (!job || job->status == job_dead)
19033N/A+ {
19033N/A for (i = 0; i < si->nscreens; i++)
19033N/A {
19033N/A saver_screen_info *ssi = &si->screens[i];
19033N/A if (kid == ssi->pid)
19033N/A ssi->pid = 0;
19033N/A }
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ if (kid == si->passwd_pid)
19033N/A+ {
19033N/A+ si->passwd_pid = 0;
19033N/A+ }
19033N/A+#endif
19033N/A+ }
19033N/A }
19033N/A
19033N/A #else /* VMS */
19033N/Adiff --git xscreensaver-5.12/driver/timers.c xscreensaver-5.12/driver/timers.c
19033N/A--- xscreensaver-5.12/driver/timers.c
19033N/A+++ xscreensaver-5.12/driver/timers.c
19033N/A@@ -47,6 +47,8 @@
19033N/A #endif /* HAVE_RANDR */
19033N/A
19033N/A #include "xscreensaver.h"
19033N/A+#include "types.h"
19033N/A+#include "dialog-data.h"
19033N/A
19033N/A #undef ABS
19033N/A #define ABS(x)((x)<0?-(x):(x))
19033N/A@@ -60,6 +62,11 @@ static Bool proc_interrupts_activity_p (saver_info *si);
19033N/A #endif /* HAVE_PROC_INTERRUPTS */
19033N/A
19033N/A static void check_for_clock_skew (saver_info *si);
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+static void watchdog_timer (XtPointer closure, XtIntervalId *id);
19033N/A+extern Bool g_passwd_dialog_created;
19033N/A+extern Bool ok_to_unblank;
19033N/A+#endif
19033N/A
19033N/A
19033N/A void
19033N/A@@ -255,7 +262,11 @@ cycle_timer (XtPointer closure, XtIntervalId *id)
19033N/A crash. So, restart the thing once an hour. */
19033N/A how_long = 1000 * 60 * 60;
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ if (si->external_passwd)
19033N/A+#else
19033N/A if (si->dbox_up_p)
19033N/A+#endif
19033N/A {
19033N/A if (p->verbose_p)
19033N/A fprintf (stderr, "%s: dialog box up; delaying hack change.\n",
19033N/A@@ -308,7 +319,28 @@ activate_lock_timer (XtPointer closure, XtIntervalId *id)
19033N/A
19033N/A if (p->verbose_p)
19033N/A fprintf (stderr, "%s: timed out; activating lock.\n", blurb());
19033N/A- set_locked_p (si, True);
19033N/A+
19033N/A+ if (si->locked_p)
19033N/A+ {
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf (stderr,
19033N/A+ "-->activate_lock_timer returning because screen already locked\n");
19033N/A+ return;
19033N/A+ }
19033N/A+
19033N/A+ /* Make sure screen is blanked before posting dialog box */
19033N/A+ if (si->screen_blanked_p)
19033N/A+ {
19033N/A+ set_locked_p (si, True);
19033N/A+ ok_to_unblank = unlock_p (si);
19033N/A+ if (ok_to_unblank == True)
19033N/A+ {
19033N/A+ set_locked_p(si,False);
19033N/A+ unblank_screen(si);
19033N/A+ }
19033N/A+ }
19033N/A+ else /* blanking of screen failed reset lock flag */
19033N/A+ set_locked_p (si, False);
19033N/A }
19033N/A
19033N/A
19033N/A@@ -587,14 +619,30 @@ dispatch_event (saver_info *si, XEvent *event)
19033N/A }
19033N/A
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+void /* called from lock.c */
19033N/A+#else
19033N/A static void
19033N/A+#endif
19033N/A swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
19033N/A {
19033N/A XEvent event;
19033N/A char buf [100];
19033N/A int i = 0;
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ if (!si->typeahead_events)
19033N/A+ {
19033N/A+ /* Allocate enough space for 10 keys to be queued - if we get more
19033N/A+ than that before the dialog is ready, it's most likely the user
19033N/A+ left something sitting on the keyboard, and won't want them. */
19033N/A+ si->typeahead_events = calloc(10, sizeof(XKeyEvent));
19033N/A+ if (si->typeahead_events == NULL)
19033N/A+ return;
19033N/A+ }
19033N/A+#else
19033N/A memset (buf, 0, sizeof(buf));
19033N/A+#endif
19033N/A
19033N/A event = *e;
19033N/A
19033N/A@@ -607,10 +655,12 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
19033N/A if (size != 1) continue;
19033N/A switch (*s)
19033N/A {
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK /* Let these be queued with the rest */
19033N/A case '\010': case '\177': /* Backspace */
19033N/A if (i > 0) i--;
19033N/A break;
19033N/A case '\025': case '\030': /* Erase line */
19033N/A+#endif
19033N/A case '\012': case '\015': /* Enter */
19033N/A case '\033': /* ESC */
19033N/A i = 0;
19033N/A@@ -620,7 +670,17 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
19033N/A break; /* ignore space at beginning of line */
19033N/A /* else, fall through */
19033N/A default:
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* Queue events to replay once dialog is ready */
19033N/A+ if (si->num_typeahead_events < 10)
19033N/A+ memcpy (&si->typeahead_events[si->num_typeahead_events++],
19033N/A+ &event, sizeof(XKeyEvent));
19033N/A+ else
19033N/A+ XBell (si->dpy, 0);
19033N/A+ i = 1; /* so that spaces are accepted after the beginning */
19033N/A+#else
19033N/A buf [i++] = *s;
19033N/A+#endif
19033N/A break;
19033N/A }
19033N/A }
19033N/A@@ -628,6 +688,7 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
19033N/A } while (i < sizeof(buf)-1 &&
19033N/A XCheckMaskEvent (si->dpy, KeyPressMask, &event));
19033N/A
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK
19033N/A buf[i] = 0;
19033N/A
19033N/A if (si->unlock_typeahead)
19033N/A@@ -642,6 +703,7 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
19033N/A si->unlock_typeahead = 0;
19033N/A
19033N/A memset (buf, 0, sizeof(buf));
19033N/A+#endif /* HAVE_XSCREENSAVER_LOCK */
19033N/A }
19033N/A
19033N/A
19033N/A@@ -818,7 +880,10 @@ sleep_until_idle (saver_info *si, Bool until_idle_p)
19033N/A
19033N/A case ClientMessage:
19033N/A if (handle_clientmessage (si, &event.x_event, until_idle_p))
19033N/A- goto DONE;
19033N/A+ {
19033N/A+ si->emergency_lock_p = True;
19033N/A+ goto DONE;
19033N/A+ }
19033N/A break;
19033N/A
19033N/A case CreateNotify:
19033N/A@@ -831,6 +896,47 @@ sleep_until_idle (saver_info *si, Bool until_idle_p)
19033N/A }
19033N/A break;
19033N/A
19033N/A+ case VisibilityNotify:
19033N/A+ {
19033N/A+ int k;
19033N/A+
19033N/A+ if (p->debug_p)
19033N/A+ {
19033N/A+ fprintf (stderr,
19033N/A+ "************************************\n"
19033N/A+ "-->sleep_until_idle() event:VisibilityNotify\n"
19033N/A+ "\t Window of VisibilityNotify:%x\n"
19033N/A+ "\t until_idle_p=%d g_passwd_dialog_created=%d\n",
19033N/A+ event.x_event.xvisibility.window,
19033N/A+ until_idle_p, g_passwd_dialog_created);
19033N/A+ fflush(stderr);
19033N/A+ }
19033N/A+
19033N/A+ /* Don't raise root window when passwd dialog wants to come up */
19033N/A+ if (g_passwd_dialog_created == 0 && !until_idle_p)
19033N/A+ {
19033N/A+ if (event.x_event.xvisibility.state != VisibilityUnobscured)
19033N/A+ {
19033N/A+ for (k = 0; k < si->nscreens; k++)
19033N/A+ {
19033N/A+ saver_screen_info *ssi = &si->screens[k];
19033N/A+ XClearWindow (si->dpy, ssi->screensaver_window);
19033N/A+ clear_stderr (ssi);
19033N/A+ XMapRaised (si->dpy, ssi->screensaver_window);
19033N/A+ }
19033N/A+ if (p->debug_p)
19033N/A+ {
19033N/A+ fprintf (stderr,
19033N/A+ "A window is trying to popup.\n"
19033N/A+ "Raising saver root Window.\n"
19033N/A+ "************************************\n");
19033N/A+ fflush(stderr);
19033N/A+ }
19033N/A+ }
19033N/A+ }
19033N/A+ break;
19033N/A+ }
19033N/A+
19033N/A case KeyPress:
19033N/A case ButtonPress:
19033N/A /* Ignore release events so that hitting ESC at the password dialog
19033N/A@@ -1419,7 +1525,11 @@ watchdog_timer (XtPointer closure, XtIntervalId *id)
19033N/A {
19033N/A Bool running_p = screenhack_running_p (si);
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ if (si->external_passwd)
19033N/A+#else
19033N/A if (si->dbox_up_p)
19033N/A+#endif
19033N/A {
19033N/A if (si->prefs.debug_p)
19033N/A fprintf (stderr, "%s: dialog box is up: not raising screen.\n",
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@@ -248,12 +248,30 @@ struct saver_info {
19033N/A
19033N/A int unlock_failures; /* Counts failed login attempts while the
19033N/A screen is locked. */
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ Window *raise_wins; /* List of windows to raise above the */
19033N/A+ int num_raise_wins; /* virtual root/hack display, such as */
19033N/A+ int max_raise_wins; /* accessibility helpers */
19033N/A+
19033N/A+ Window *override_wins; /* Windows we had to unset the */
19033N/A+ int num_override_wins; /* override_redirect attribute on and */
19033N/A+ int max_override_wins; /* need to restore it on after unlock. */
19033N/A+
19033N/A+
19033N/A+ pid_t passwd_pid; /* The pid of the password dialog child if we
19033N/A+ are running an external process for it. */
19033N/A+ Bool external_passwd;
19033N/A+
19033N/A+ XKeyEvent *typeahead_events; /* Like unlock_typeahead, but as raw events */
19033N/A+ int num_typeahead_events;
19033N/A+#else
19033N/A
19033N/A char *unlock_typeahead; /* If the screen is locked, and the user types
19033N/A a character, we assume that it is the first
19033N/A character of the password. It's stored here
19033N/A for the password dialog to use to populate
19033N/A itself. */
19033N/A+#endif /* HAVE_XSCREENSAVER_LOCK */
19033N/A
19033N/A char *user; /* The user whose session is locked. */
19033N/A char *cached_passwd; /* Cached password, used to avoid multiple
19033N/Adiff --git xscreensaver-5.12/driver/windows.c xscreensaver-5.12/driver/windows.c
19033N/A--- xscreensaver-5.12/driver/windows.c
19033N/A+++ xscreensaver-5.12/driver/windows.c
19117N/A@@ -1081,8 +1081,12 @@ safe_XConfigureWindow (Display *dpy, Window window,
19033N/A return (!error_handler_hit_p);
19033N/A }
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+Bool
19033N/A+#else
19033N/A /* This might not be necessary, but just in case. */
19033N/A static Bool
19033N/A+#endif
19033N/A safe_XDestroyWindow (Display *dpy, Window window)
19033N/A {
19033N/A XErrorHandler old_handler;
19117N/A@@ -1096,6 +1100,14 @@ safe_XDestroyWindow (Display *dpy, Window window)
19033N/A XSetErrorHandler (old_handler);
19033N/A XSync (dpy, False);
19033N/A
19033N/A+ /* clear any queued VisibilityNotify events so we don't cause XErrors
19033N/A+ later when we try to process them and find the windowid is invalid */
19033N/A+ XEvent event;
19033N/A+ while (XCheckWindowEvent(dpy, window, VisibilityChangeMask, &event))
19033N/A+ {
19033N/A+ /* discard event */ ;
19033N/A+ }
19033N/A+
19033N/A return (!error_handler_hit_p);
19033N/A }
19033N/A
19117N/A@@ -1210,6 +1222,7 @@ initialize_screensaver_window_1 (saver_screen_info *ssi)
19033N/A */
19033N/A attrs.event_mask = (KeyPressMask | KeyReleaseMask |
19033N/A ButtonPressMask | ButtonReleaseMask |
19033N/A+ VisibilityChangeMask |
19033N/A PointerMotionMask);
19033N/A
19033N/A attrs.backing_store = NotUseful;
19117N/A@@ -1481,6 +1494,9 @@ raise_window (saver_info *si,
19033N/A saver_preferences *p = &si->prefs;
19033N/A int i;
19033N/A
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf(stderr,"-->raise_window()\n");
19033N/A+
19033N/A if (si->demoing_p)
19033N/A inhibit_fade = True;
19033N/A
19117N/A@@ -1695,6 +1711,9 @@ unblank_screen (saver_info *si)
19033N/A Bool unfade_p = (si->fading_possible_p && p->unfade_p);
19033N/A int i;
19033N/A
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf(stderr,"-->unblank_screen()\n");
19033N/A+
19033N/A monitor_power_on (si);
19033N/A reset_watchdog_timer (si, False);
19033N/A
19117N/A@@ -1983,7 +2002,7 @@ select_visual (saver_screen_info *ssi, const char *visual_name)
19033N/A maybe_transfer_grabs (ssi, old_w, ssi->screensaver_window, ssi->number);
19033N/A
19033N/A /* Now we can destroy the old window without horking our grabs. */
19033N/A- XDestroyWindow (si->dpy, old_w);
19033N/A+ safe_XDestroyWindow (si->dpy, old_w);
19033N/A
19033N/A if (p->verbose_p)
19033N/A fprintf (stderr, "%s: %d: destroyed old saver window 0x%lx.\n",
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@@ -156,6 +156,8 @@
19033N/A #include <X11/StringDefs.h>
19033N/A #include <X11/Shell.h>
19033N/A #include <X11/Xos.h>
19033N/A+#include <gconf/gconf-client.h>
19033N/A+#include <glib.h>
19033N/A #include <time.h>
19033N/A #include <sys/time.h>
19033N/A #include <netdb.h> /* for gethostbyname() */
19033N/A@@ -217,6 +219,7 @@
19033N/A #endif /* HAVE_RANDR */
19033N/A
19033N/A
19033N/A+#include "dialog-data.h"
19033N/A #include "xscreensaver.h"
19033N/A #include "version.h"
19033N/A #include "yarandom.h"
19117N/A@@ -228,11 +231,28 @@
19033N/A
19033N/A saver_info *global_si_kludge = 0; /* I hate C so much... */
19033N/A
19033N/A+/* Globals */
19033N/A+Bool ok_to_unblank = False;
19033N/A+
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+/* Global storage for gtk passwd lock dialog
19033N/A+ * we assign this to si->pw_data and this is needed
19033N/A+ * to set user/passwd labels on gtk lock dialog by
19033N/A+ * pam conv function.
19033N/A+ */
19033N/A+passwd_dialog_data mygtkpwd;
19033N/A+passwd_dialog_data *ptr_mygtkpwd = &mygtkpwd;
19033N/A+#endif
19033N/A+
19033N/A char *progname = 0;
19033N/A char *progclass = 0;
19033N/A XrmDatabase db = 0;
19117N/A
19117N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+Atom XA_UNLOCK_RATIO;
19033N/A+#endif
19117N/A+
19033N/A
19033N/A static XrmOptionDescRec options [] = {
19117N/A
19117N/A@@ -630,6 +650,9 @@ connect_to_server (saver_info *si, int *argc, char **argv)
19117N/A { &XA_XSETROOT_ID, "_XSETROOT_ID" },
19117N/A { &XA_ESETROOT_PMAP_ID, "ESETROOT_PMAP_ID" },
19117N/A { &XA_XROOTPMAP_ID, "_XROOTPMAP_ID" },
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19117N/A+ { &XA_UNLOCK_RATIO, "UNLOCK_RATIO" },
19033N/A+#endif
19117N/A { NULL, NULL } /* Must be last to terminate list */
19117N/A };
19117N/A const struct atom_request *atom_lists[3] = { NULL, NULL, NULL };
19117N/A@@ -1105,8 +1128,36 @@ static void
19033N/A main_loop (saver_info *si)
19033N/A {
19033N/A saver_preferences *p = &si->prefs;
19033N/A- Bool ok_to_unblank;
19033N/A+ /* Bool ok_to_unblank; made this a global flag, gets set in timers.c */
19033N/A int i;
19033N/A+ const char *modulesptr = NULL;
19033N/A+
19033N/A+/*
19033N/A+** CR4784055(P1)locked-screen dialog is inaccessible to Gnopernicus
19033N/A+** voice for each type-in char in the password field of
19033N/A+** pop-up dialog
19033N/A+*/
19033N/A+
19033N/A+ /* BUG #6573182
19033N/A+ ** g_type_init should be done before calling gconf_client routines
19033N/A+ ** so that xscreensaver does not dump core if gconf daemon is not running.
19033N/A+ */
19033N/A+ g_type_init ();
19033N/A+
19033N/A+ /*
19033N/A+ ** 6395649 at-spi-registryd starts when screen is locked even
19033N/A+ ** when accessible device support is off(SR)
19033N/A+ ** per AT core gp suggestion
19033N/A+ ** GTK_MODULES is set only if at support is enabled
19033N/A+ */
19033N/A+
19033N/A+ if (gconf_client_get_bool(gconf_client_get_default(),
19033N/A+ "/desktop/gnome/interface/accessibility", NULL))
19033N/A+ {
19033N/A+ modulesptr = getenv ("GTK_MODULES");
19033N/A+ if (!modulesptr || modulesptr [0] == '\0')
19033N/A+ putenv ("GTK_MODULES=gail:atk-bridge");
19033N/A+ }
19033N/A
19033N/A while (1)
19033N/A {
19117N/A@@ -1137,6 +1188,17 @@ main_loop (saver_info *si)
19033N/A fprintf (stderr, "%s: idle with blanking disabled at %s.\n",
19033N/A blurb(), timestring());
19033N/A
19033N/A+ /* 6221109 Changing mode from disable to anything else,
19033N/A+ doesn't lock screen.
19033N/A+
19033N/A+ This is Disable Screen Saver mode, in this mode we dont lock
19033N/A+ screen, but si->locked_p is already set to True, since someone
19033N/A+ tried to lock screen, reset it to False, else when we change
19033N/A+ mode from disable and try to lock screen, xscreensaver thinks
19033N/A+ screen is already locked and doesnt lock screen anymore.
19033N/A+ */
19033N/A+ set_locked_p (si, False);
19033N/A+
19033N/A /* Go around the loop and wait for the next bout of idleness,
19033N/A or for the init file to change, or for a remote command to
19033N/A come in, or something.
19117N/A@@ -1198,6 +1260,7 @@ main_loop (saver_info *si)
19033N/A blurb());
19033N/A
19033N/A schedule_wakeup_event (si, retry, p->debug_p);
19033N/A+ set_locked_p(si, False);
19033N/A continue;
19033N/A }
19033N/A }
19117N/A@@ -1246,7 +1309,17 @@ main_loop (saver_info *si)
19033N/A p->lock_p && /* and locking is enabled */
19033N/A !si->locking_disabled_p && /* and locking is possible */
19033N/A lock_timeout == 0) /* and locking is not timer-deferred */
19033N/A- set_locked_p (si, True); /* then lock right now. */
19033N/A+ {
19033N/A+ if (p->debug_p)
19033N/A+ fprintf(stderr, "going to lock screen B\n");
19033N/A+ set_locked_p (si, True); /* then lock right now. */
19033N/A+ ok_to_unblank = unlock_p(si);
19033N/A+ if (ok_to_unblank == True)
19033N/A+ {
19033N/A+ set_locked_p (si, False);
19033N/A+ goto DONE;
19033N/A+ }
19033N/A+ }
19033N/A
19033N/A /* locked_p might be true already because of the above, or because of
19033N/A the LOCK ClientMessage. But if not, and if we're supposed to lock
19117N/A@@ -1261,10 +1334,7 @@ main_loop (saver_info *si)
19033N/A }
19033N/A #endif /* !NO_LOCKING */
19033N/A
19033N/A-
19033N/A- ok_to_unblank = True;
19033N/A do {
19033N/A-
19033N/A check_for_leaks ("blanked A");
19033N/A sleep_until_idle (si, False); /* until not idle */
19033N/A check_for_leaks ("blanked B");
19117N/A@@ -1274,6 +1344,13 @@ main_loop (saver_info *si)
19033N/A #ifndef NO_LOCKING
19033N/A /* Maybe unlock the screen.
19033N/A */
19033N/A+ if (si->demoing_p) goto DONE; /* in demoing mode and user wants out
19033N/A+ unblank screen */
19033N/A+
19033N/A+ /* This is when blank timeout has happened but lock timeout hasnt
19033N/A+ and user gets active. Simply get him out of the blank screen. */
19033N/A+ if (si->screen_blanked_p && !si->locked_p) goto DONE;
19033N/A+
19033N/A if (si->locked_p)
19033N/A {
19033N/A saver_screen_info *ssi = si->default_screen;
19117N/A@@ -1285,7 +1362,20 @@ main_loop (saver_info *si)
19033N/A suspend_screenhack (&si->screens[i], True); /* suspend */
19033N/A XUndefineCursor (si->dpy, ssi->screensaver_window);
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ /* Prevents lock dialog posting on non blanked screen */
19033N/A+ if (!si->screen_blanked_p) /* locked_p is true, so blank now */
19033N/A+ blank_screen (si);
19033N/A+ if (si->screen_blanked_p) /* if blanking successful, call PAM */
19033N/A+ {
19033N/A+ set_locked_p (si, True);
19033N/A+ ok_to_unblank = unlock_p(si);
19033N/A+ }
19033N/A+ else /* blanking failed, probably couldn't grab keyboard/mouse */
19033N/A+ set_locked_p (si, False);
19033N/A+#else
19033N/A ok_to_unblank = unlock_p (si);
19033N/A+#endif
19033N/A
19033N/A si->dbox_up_p = False;
19033N/A XDefineCursor (si->dpy, ssi->screensaver_window, ssi->cursor);
19117N/A@@ -1310,6 +1400,7 @@ main_loop (saver_info *si)
19033N/A
19033N/A } while (!ok_to_unblank);
19033N/A
19033N/A+DONE:
19033N/A
19033N/A if (p->verbose_p)
19033N/A fprintf (stderr, "%s: unblanking screen at %s.\n",
19117N/A@@ -1375,7 +1466,19 @@ main (int argc, char **argv)
19033N/A textdomain (GETTEXT_PACKAGE);
19033N/A #endif /* ENABLE_NLS */
19033N/A
19033N/A+#if defined(ENABLE_NLS) && defined(HAVE_XSCREENSAVER_LOCK)
19033N/A+ /* Gtk unlock dialog needs to be sent UTF-8 text to display */
19033N/A+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
19033N/A+#endif
19033N/A+
19033N/A memset(si, 0, sizeof(*si));
19033N/A+
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+/* Initialize and point si to pw_data i.e. the lock dialog struct */
19033N/A+ memset(ptr_mygtkpwd, 0, sizeof(*ptr_mygtkpwd));
19033N/A+ si->pw_data = ptr_mygtkpwd;
19033N/A+#endif
19033N/A+
19033N/A global_si_kludge = si; /* I hate C so much... */
19033N/A
19033N/A fix_fds();
19117N/A@@ -1385,7 +1488,9 @@ main (int argc, char **argv)
19033N/A
19033N/A save_argv (argc, argv);
19033N/A set_version_string (si, &argc, argv);
19033N/A+#ifndef HAVE_XSCREENSAVER_LOCK /* moved below for external lock */
19033N/A privileged_initialization (si, &argc, argv);
19033N/A+#endif
19033N/A hack_environment (si);
19033N/A
19033N/A spasswd = getpwuid(getuid());
19117N/A@@ -1408,6 +1513,10 @@ main (int argc, char **argv)
19033N/A print_banner (si);
19033N/A
19033N/A load_init_file(si->dpy, p); /* must be before initialize_per_screen_info() */
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+ privileged_initialization (si, &argc, argv);
19033N/A+#endif
19033N/A+
19033N/A blurb_timestamp_p = p->timestamp_p; /* kludge */
19033N/A initialize_per_screen_info (si, shell); /* also sets si->fading_possible_p */
19033N/A
19117N/A@@ -1659,8 +1768,12 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
19033N/A Atom type = 0;
19033N/A Window window = event->xclient.window;
19033N/A
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf(stderr, "handle_clientmessage\n");
19033N/A+
19033N/A /* Preferences might affect our handling of client messages. */
19033N/A maybe_reload_init_file (si);
19033N/A+ XSync (si->dpy, False);
19033N/A
19033N/A if (event->xclient.message_type != XA_SCREENSAVER ||
19033N/A event->xclient.format != 32)
19117N/A@@ -1933,10 +2046,18 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
19033N/A : "locking.");
19033N/A sprintf (buf, "LOCK ClientMessage received; %s", response);
19033N/A clientmessage_response (si, window, False, buf, response);
19033N/A+
19033N/A+ if (p->verbose_p)
19033N/A+ fprintf(stderr, "going to lock screen A\n");
19033N/A+
19033N/A set_locked_p (si, True);
19033N/A+ si->emergency_lock_p = True;
19033N/A si->selection_mode = 0;
19033N/A si->demoing_p = False;
19033N/A
19033N/A+ return True; /* dont set lock_id to 0,
19033N/A+ causes to go in lock in main_loop above */
19033N/A+
19033N/A if (si->lock_id) /* we're doing it now, so lose the timeout */
19033N/A {
19033N/A XtRemoveTimeOut (si->lock_id);
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@@ -164,6 +164,12 @@ extern Bool select_visual (saver_screen_info *ssi, const char *visual_name);
19033N/A extern void store_saver_status (saver_info *si);
19033N/A extern const char *signal_name (int signal);
19033N/A
19033N/A+#ifdef HAVE_XSCREENSAVER_LOCK
19033N/A+extern int kill_job (saver_info *si, pid_t pid, int signal);
19033N/A+extern struct screenhack_job *make_job (pid_t pid, int screen,
19033N/A+ const char *cmd);
19033N/A+#endif
19033N/A+
19033N/A /* =======================================================================
19033N/A subprocs diagnostics
19033N/A ======================================================================= */
19033N/A