index 4c4dee5..873299e 100644
@@ -2666,6 +2666,7 @@ if test "$with_gtk" = yes; then
pkg_check_version libglade-2.0 1.99.0
pkg_check_version gdk-pixbuf-2.0 2.0.0
pkg_check_version gdk-pixbuf-xlib-2.0 2.0.0
+ pkg_check_version gconf-2.0 2.6.1
if test "$have_gtk" = no; then
@@ -2681,6 +2682,14 @@ if test "$with_gtk" = yes; then
if test "$have_gtk" = yes; then
+#--- Begin SUNW addition
+ PKG_CHECK_MODULES([LOGINHELPER], [libloginhelper-1.0 >= 1.0],
+ [pkgs="$pkgs libloginhelper-1.0"
+ AC_DEFINE([HAVE_LOGINHELPER],[],
+ [Define this to use libloginhelper (atk
1.x only)])],
+ AC_DEFINE(HAVE_XSCREENSAVER_LOCK,[],[Define this to build the external lock dialog])
AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
[ac_cv_gtk_config_cflags=`$pkg_config --cflags $pkgs`])
AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
@@ -3933,6 +3942,16 @@ if test "$have_gtk" = yes; then
ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
+#--- Begin SUNW addition
+if test "$have_gtk" = yes; then
+ PREFERRED_LOCK_PROGRAM=xscreensaver-lock-Gtk
+ ALL_LOCK_PROGRAMS="$PREFERRED_LOCK_PROGRAM $ALL_LOCK_PROGRAMS"
+ LOCK_PROGRAM=xscreensaver-lock
if test "$have_kerberos" = yes; then
PASSWD_SRCS="$PASSWD_SRCS \$(KERBEROS_SRCS)"
@@ -4077,6 +4096,11 @@ AC_SUBST(INCLUDES)
AC_SUBST(PREFERRED_DEMO_PROGRAM)
AC_SUBST(ALL_DEMO_PROGRAMS)
+#--- Begin SUNW addition
+AC_SUBST(PREFERRED_LOCK_PROGRAM)
+AC_SUBST(ALL_LOCK_PROGRAMS)
@@ -4598,7 +4622,8 @@ HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
# Sanity check the hackdir
-for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command ; do
+# SUNW addition: added xscreensaver-lock to list on next line
+for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command xscreensaver-lock ; do
if test "${HACKDIR}" = "${bindir}/${bad_choice}" ; then
AC_MSG_ERROR([\"--with-hackdir=${bindir}/${bad_choice}\" won't work.
@@ -29,6 +29,7 @@ GTK_APPDIR = $(GTK_DATADIR)/applications
GTK_ICONDIR = $(GTK_DATADIR)/pixmaps
HACK_CONF_DIR = @HACK_CONF_DIR@
+LOCK_DIR = $(libexecdir)
@@ -42,6 +43,7 @@ SUBP_DEFS = $(DEFS) -DHACK_PATH='"@HACKDIR@"' \
GTK_DEFS = $(DEFS) -DDEFAULT_ICONDIR='"$(GTK_GLADEDIR)"' \
CONF_DEFS = -DHACK_CONFIGURATION_PATH='"$(HACK_CONF_DIR)"'
+LOCK_DEFS = $(DEFS) -DLOCKDIR=\"$(LOCK_DIR)\"
@@ -217,8 +221,8 @@ GETIMG_LIBS = $(LIBS) $(X_LIBS) $(XPM_LIBS) $(JPEG_LIBS) \
$(X_PRE_LIBS) -lXt -lX11 $(XMU_LIBS) -lXext $(X_EXTRA_LIBS)
EXES = xscreensaver xscreensaver-command xscreensaver-demo \
- xscreensaver-getimage @EXES_OSX@
-EXES2 = @ALL_DEMO_PROGRAMS@
+ xscreensaver-getimage @EXES_OSX@ @LOCK_PROGRAM@
+EXES2 = @ALL_DEMO_PROGRAMS@ @ALL_LOCK_PROGRAMS@
SCRIPTS_1 = xscreensaver-getimage-file xscreensaver-getimage-video \
-TARFILES = $(EXTRAS) $(VMSFILES) $(SAVER_SRCS_1) \
+TARFILES = $(EXTRAS) $(VMSFILES) $(SAVER_SRCS_1) $(GTK_LOCK_SRCS) \
$(MOTIF_SRCS) $(GTK_SRCS) $(PWENT_SRCS) $(PWHELPER_SRCS) \
$(KERBEROS_SRCS) $(PAM_SRCS) $(LOCK_SRCS_1) $(DEMO_SRCS_1) \
$(CMD_SRCS) $(GETIMG_SRCS_1) $(PDF2JPEG_SRCS) $(HDRS) \
@@ -260,7 +264,7 @@ all: $(EXES) $(EXES2)
install: install-program install-ad install-scripts \
- install-gnome install-man install-xml install-pam
+ install-gnome install-man install-xml
uninstall: uninstall-program uninstall-ad \
uninstall-gnome uninstall-man uninstall-xml
@@ -272,6 +276,9 @@ install-program: $(EXES)
@if [ ! -d $(install_prefix)$(bindir) ]; then \
$(INSTALL_DIRS) $(install_prefix)$(bindir) ; \
+ @if [ -n "@LOCK_PROGRAM@" -a ! -d $(install_prefix)$(LOCK_DIR) ]; then \
+ $(INSTALL_DIRS) $(install_prefix)$(LOCK_DIR) ; \
@inst="$(INSTALL_PROGRAM)" ; \
if [ @NEED_SETUID@ = yes ]; then \
@@ -300,6 +307,12 @@ install-program: $(EXES)
echo $(INSTALL_PROGRAM) $$exe $(install_prefix)$(bindir)/$$exe ; \
$(INSTALL_PROGRAM) $$exe $(install_prefix)$(bindir)/$$exe ; \
+ @if [ -n "@LOCK_PROGRAM@" ]; then \
+ echo $(INSTALL_PROGRAM) xscreensaver-lock \
+ $(install_prefix)$(LOCK_DIR)/xscreensaver-lock ; \
+ $(INSTALL_PROGRAM) xscreensaver-lock \
+ $(install_prefix)$(LOCK_DIR)/xscreensaver-lock ; \
@if [ ! -d $(install_prefix)$(AD_DIR) ]; then \
@@ -736,7 +749,7 @@ $(SAVER_UTIL_OBJS):
# How we build object files in this directory.
- $(CC) -c $(INCLUDES) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(X_CFLAGS) $<
+ $(CC) -c $(INCLUDES) $(DEFS) $(CPPFLAGS) $(INTL_DEFS) $(CFLAGS) $(X_CFLAGS) $<
$(OBJCC) -c $(INCLUDES) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(X_CFLAGS) $<
$(CC) -c $(INCLUDES) $(CONF_DEFS) $(GTK_DEFS) $(CPPFLAGS) $(CFLAGS) $(X_CFLAGS) \
+# lock takes an extra -D option.
+ $(CC) -c $(INCLUDES) $(LOCK_DEFS) $(CFLAGS) $(X_CFLAGS) \
+# lock-Gtk takes extra -D and -I options.
+ $(CC) -c $(INCLUDES) -I$(ICON_SRC) $(GTK_DEFS) \
+ $(CFLAGS) $(X_CFLAGS) $(INTL_DEFS) \
# How we build the default app-defaults file into the program.
# The executables linked in this directory.
xscreensaver: $(SAVER_OBJS)
- $(CC) $(LDFLAGS) -o $@ $(SAVER_OBJS) $(SAVER_LIBS) $(INTL_LIBS)
+ $(CC) $(LDFLAGS) -o $@ $(SAVER_OBJS) $(SAVER_LIBS) $(INTL_LIBS) \
+ -lgconf-2 -lgobject-2.0 -lglib-2.0
xscreensaver-command: $(CMD_OBJS)
$(CC) $(LDFLAGS) -o $@ $(CMD_OBJS) $(CMD_LIBS)
@@ -792,6 +816,15 @@ xscreensaver-demo: @PREFERRED_DEMO_PROGRAM@
cp -p @PREFERRED_DEMO_PROGRAM@@EXEEXT@ $@@EXEEXT@ ; \
+xscreensaver-lock: @PREFERRED_LOCK_PROGRAM@
+ $(INSTALL_PROGRAM) @PREFERRED_LOCK_PROGRAM@ $@
+xscreensaver-lock-Gtk: $(GTK_LOCK_OBJS)
+ $(CC) $(LDFLAGS) -o $@ $(GTK_LOCK_OBJS) $(LIBS) $(X_LIBS) \
+ $(GTK_LIBS) $(XML_LIBS) $(X_PRE_LIBS) -lXt -lX11 \
xscreensaver-demo-Xm: $(DEMO_OBJS) $(MOTIF_OBJS)
$(CC) $(LDFLAGS) -o $@ $(DEMO_OBJS) $(MOTIF_OBJS) $(LIBS) $(X_LIBS) \
$(MOTIF_LIBS) $(INTL_LIBS) $(X_PRE_LIBS) -lXt -lX11 \
@@ -815,7 +848,7 @@ pdf2jpeg: $(PDF2JPEG_OBJS)
index 65e00f3..4fcbb34 100644
@@ -51,4 +51,8 @@ xss_authenticate(saver_info *si, Bool verbose_p);
auth_finished_cb (saver_info *si);
+#ifdef HAVE_XSCREENSAVER_LOCK
+extern int write_to_child (saver_info* si, const char* cmd, const char *msg);
# define G_MODULE_EXPORT /**/
#if defined(DEFAULT_ICONDIR) && !defined(GLADE_DIR)
# define GLADE_DIR DEFAULT_ICONDIR
@@ -5042,6 +5044,22 @@ main (int argc, char **argv)
+ /* Bug 147639: Gok cant automatically UI grab screensaver preferences */
+ GConfClient *client = gconf_client_get_default ();
+ /* check if accessibilty mode is enabled */
+ if (gconf_client_get_bool (client, KEY, NULL))
+ /* GTK Accessibility Module initialized */
+ const char *modulesptr = g_getenv ("GTK_MODULES");
+ if (!modulesptr || (modulesptr [0] == '\0'))
+ putenv ("GTK_MODULES=gail:atk-bridge");
/* Now that Xt has been initialized, and the resources have been read,
we can set our `progname' variable to something more in line with
+/* xscreensaver, Copyright (c) 1993-2008 Jamie Zawinski <jwz@jwz.org>
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+#ifndef __DIALOG_DATA_H__
+#define __DIALOG_DATA_H__
+#define MAX_BYTES_PER_CHAR 8 /* UTF-8 uses no more than 3, I think */
+#define MAX_PASSWD_CHARS 128 /* Longest possible passphrase */
+struct passwd_dialog_data {
+ saver_screen_info *prompt_screen;
+ int previous_mouse_x, previous_mouse_y;
+ /* "Characters" in the password may be a variable number of bytes long.
+ typed_passwd contains the raw bytes.
+ typed_passwd_char_size indicates the size in bytes of each character,
+ so that we can make backspace work.
+ char typed_passwd [MAX_PASSWD_CHARS * MAX_BYTES_PER_CHAR];
+ char typed_passwd_char_size [MAX_PASSWD_CHARS];
+ Dimension border_width;
+ Bool show_stars_p; /* "I regret that I have but one asterisk for my country."
+ -- Nathan Hale, 1776. */
+ /* The entry field shall only be displayed if prompt_label is not NULL */
+ mlstring *prompt_label;
+ Bool passwd_changed_p; /* Whether the user entry field needs redrawing */
+ Bool caps_p; /* Whether we saw a keypress with caps-lock on */
+#ifndef HAVE_XSCREENSAVER_LOCK
+ XFontStruct *heading_font;
+ XFontStruct *body_font;
+ XFontStruct *label_font;
+ XFontStruct *passwd_font;
+ XFontStruct *date_font;
+ XFontStruct *button_font;
+ XFontStruct *uname_font;
+ Pixel passwd_foreground;
+ Pixel passwd_background;
+ Pixel thermo_foreground;
+ Pixel thermo_background;
+ Pixel button_foreground;
+ Pixel button_background;
+ Dimension preferred_logo_width, logo_width;
+ Dimension preferred_logo_height, logo_height;
+ Dimension thermo_width;
+ Dimension internal_border;
+ Dimension shadow_width;
+ Dimension passwd_field_x, passwd_field_y;
+ Dimension passwd_field_width, passwd_field_height;
+ Dimension unlock_button_x, unlock_button_y;
+ Dimension unlock_button_width, unlock_button_height;
+ Dimension login_button_x, login_button_y;
+ Dimension login_button_width, login_button_height;
+ Dimension thermo_field_x, thermo_field_y;
+ Dimension thermo_field_height;
+ unsigned long *logo_pixels;
+#endif /* ! HAVE_XSCREENSAVER_LOCK */
+ Bool unlock_button_down_p;
+ Bool login_button_down_p;
+ Bool login_button_enabled_p;
+ Bool button_state_changed_p; /* Refers to both buttons */
+ Pixmap user_entry_pixmap;
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* extern passwd dialog stuff */
+ XtInputId stdout_input_id;
+ int stdin_fd; /* child's stdin - parent writes to this */
+ int stdout_fd; /* child's stdout - parent reads from this */
+ FILE *stdin_file; /* child's stdin - parent writes to this */
+ FILE *stdout_file; /* child's stdout - parent reads from this */
+#endif /* __DIALOG_DATA_H__ */
+/*
lock-Gtk.c -- a GTK+ password dialog for xscreensaver
+ * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski <jwz@jwz.org>
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+/* GTK+ locking code written by Jacob Berkman <jacob@ximian.com> for
+ * Copyright (c) 2002, 2010, Oracle
and/or its affiliates. All rights reserved.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *
and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+#ifdef HAVE_GTK2 /* whole file */
+#if GTK_CHECK_VERSION(2,14,0)
+# define GET_WINDOW(w) gtk_widget_get_window (w)
+# define GET_WINDOW(w) ((w)->window)
+static Atom XA_UNLOCK_RATIO;
+ GtkWidget *user_prompt_label;
+ GtkWidget *user_input_entry;
+ GtkWidget *pam_message_label;
+FILE *parent_file = NULL; /* child writes to parent on this */
+/* Send a command to the xscreensaver parent daemon
+ - msg - type of message - "input", "raise_wid", etc.
+ - data - data for message
+ - flush - whether to flush now or allow stdio to buffer
+ Message format sent to parent:
+ "msg\n" if no data, otherwise "msg=data\n"
+ Can be used to flush previously buffered messages by calling
+ with NULL msg & data, and TRUE for flush.
+write_to_parent (const char* msg, const char *data, gboolean flush)
+ fprintf (stderr, "-->Child write_to_parent() string to send is: %s=%s\n",
+ msg, data ? data : "(null)");
+ len = fprintf (parent_file, "%s=%s\n", msg, data);
+ len = fprintf (parent_file, "%s\n", msg);
+/* Send parent a message with a window id as the data */
+write_windowid (const char* msg, Window w)
+ char s[16]; /* more than long enough to hold a 32-bit integer + '\0' */
+ snprintf(s, sizeof(s), "0x%lx", w);
+ write_to_parent(msg, s, FALSE);
+load_unlock_logo_image (void)
+ if (stat (logofile, &statbuf) != 0)
+ logofile = DEFAULT_ICONDIR "/
logo-180.gif"; /* fallback */
+ return gtk_image_new_from_file (logofile);
+/* Create unlock dialog */
+make_dialog (gboolean center_pos)
+ GtkWidget *frame1, *frame2;
+ GtkWidget *hbox1, *hbox2;
+ GtkWidget *title_label, *msg_label, *prompt_label,
+ *user_label, *date_label, *pam_msg_label;
+ AtkObject *atk_title_label, *atk_prompt_label;
+ gchar *format_string_locale, *format_string_utf8;
+ time_t now = time (NULL);
+ server_xscreensaver_version (GDK_DISPLAY (), &version, &user, &host);
+ fprintf (stderr, "%s: no xscreensaver running on display %s, exiting.\n",
+ progname, gdk_get_display ());
+ gtk_widget_push_colormap (gdk_rgb_get_cmap ());
+ pwd = g_new0 (PasswdDialog, 1);
+ dialog = gtk_window_new (GTK_WINDOW_POPUP);
+ ** bugid: 5077989(P2)Bug 147580: password input dialogue obscures GOK
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+ bugid: 5002244: scr unlock dialog incompatible with MAG technique
+ ** 6182506: scr dialog is obscured by MAG window
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); /*mali99 irritating*/
+ /* AT-enabled dialog role = frame */
+ atk_dialog = gtk_widget_get_accessible (dialog);
+ atk_object_set_description (atk_dialog, _("screen unlock dialog"));
+ frame1 = g_object_new (GTK_TYPE_FRAME,
+ "shadow-type", GTK_SHADOW_OUT,
+ gtk_container_add (GTK_CONTAINER (dialog), frame1);
+ vbox = gtk_vbox_new (FALSE, 10);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
+ gtk_container_add (GTK_CONTAINER (frame1), vbox);
+ /* AT role= filler(default) */
+ hbox1 = gtk_hbox_new (FALSE, 5);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox1,
+ frame2 = g_object_new (GTK_TYPE_FRAME,
+ "shadow-type", GTK_SHADOW_ETCHED_IN,
+ gtk_box_pack_start (GTK_BOX (hbox1), frame2,
+ /* AT role= filler(default) */
+ image = load_unlock_logo_image ();
+ gtk_container_add (GTK_CONTAINER (frame2), image);
+ progress = g_object_new (GTK_TYPE_PROGRESS_BAR,
+ "orientation", GTK_PROGRESS_BOTTOM_TO_TOP,
+ gtk_box_pack_start (GTK_BOX (hbox1), progress,
+ pwd->progress = progress;
+ atk_object_set_description (gtk_widget_get_accessible (progress),
+ _("Percent of time you have left to unlock the screen."));
+ vbox2 = gtk_vbox_new (FALSE, 20);
+ gtk_box_pack_start (GTK_BOX (hbox1), vbox2,
+ s = g_markup_printf_escaped ("<span size=\"xx-large\"><b>%s </b></span>",
+ /* XScreenSaver foo label */
+ title_label = g_object_new (GTK_TYPE_LABEL,
+ gtk_box_pack_start (GTK_BOX (vbox2), title_label,
+ /* AT role = label prog name */
+ atk_title_label = gtk_widget_get_accessible (title_label);
+ atk_object_add_relationship (atk_title_label, ATK_RELATION_LABEL_FOR,
+ atk_object_add_relationship (atk_dialog, ATK_RELATION_LABELLED_BY,
+ /* This display is locked. */
+ msg_label = g_object_new (GTK_TYPE_LABEL,
+ "label", _("<b>This display is locked.</b>"),
+ pwd->msg_label = msg_label;
+ gtk_box_pack_start (GTK_BOX (vbox2), msg_label,
+ s = g_strdup_printf (_("User: %s"), user ? user : "");
+ user_label = g_object_new (GTK_TYPE_LABEL,
+ gtk_label_set_width_chars (GTK_LABEL (user_label), 35);
+ gtk_box_pack_start (GTK_BOX (vbox2), user_label, FALSE, FALSE, 0);
+ hbox2 = gtk_widget_new (GTK_TYPE_HBOX,
+ prompt_label = g_object_new (GTK_TYPE_LABEL,
+ /* blank space for prompt */
+ "justify", GTK_JUSTIFY_CENTER,
+ pwd->user_prompt_label = prompt_label;
+ entry = g_object_new (GTK_TYPE_ENTRY,
+ "activates-default", TRUE,
+ pwd->user_input_entry = entry;
+ /* gtk_widget_grab_focus (entry); */
+ atk_entry = gtk_widget_get_accessible (entry);
+ atk_object_set_role (atk_entry, ATK_ROLE_PASSWORD_TEXT);
+ /* AT role = label for input widget */
+ atk_prompt_label = gtk_widget_get_accessible (prompt_label);
+ atk_object_add_relationship (atk_prompt_label, ATK_RELATION_LABEL_FOR,
+ atk_object_add_relationship (atk_entry, ATK_RELATION_LABELLED_BY,
+ gtk_box_pack_start (GTK_BOX (hbox2), prompt_label, FALSE, FALSE, 0);
+ gtk_box_pack_end (GTK_BOX (hbox2), entry, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
+ pam_msg_label = g_object_new (GTK_TYPE_LABEL,
+ pwd->pam_message_label = pam_msg_label;
+ gtk_box_pack_start (GTK_BOX (vbox2), pam_msg_label, FALSE, FALSE, 0);
+ memset (buf, 0, sizeof (buf));
+ format_string_utf8 = _("%d-%b-%y (%a); %I:%M %p");
+ format_string_locale = g_locale_from_utf8 (format_string_utf8, -1,
+ strftime (buf, sizeof (buf) - 1, format_string_locale, tm);
+ g_free (format_string_locale);
+ utf8_format = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
+ s = g_markup_printf_escaped ("<small>%s</small>", utf8_format);
+ date_label = g_object_new (GTK_TYPE_LABEL,
+ gtk_box_pack_start (GTK_BOX (vbox2), date_label,
+ bbox = g_object_new (GTK_TYPE_HBUTTON_BOX,
+ "layout-style", GTK_BUTTONBOX_END,
+ button = gtk_button_new_from_stock (GTK_STOCK_OK);
+ gtk_box_pack_end (GTK_BOX (bbox), button,
+ gtk_widget_pop_colormap ();
+/* Callback for when user has finished entering input, even though
+ we don't display an "OK" button for them to click on */
+ok_clicked_cb (GtkWidget *button, PasswdDialog *pwd)
+ g_object_set (pwd->msg_label, "label", _("<b>Checking...</b>"), NULL);
+ s = gtk_entry_get_text (GTK_ENTRY (pwd->user_input_entry));
+ write_to_parent ("input", s, TRUE);
+ /* Reset password field to blank, else passwd field shows old passwd *'s,
+ visible when passwd is expired, and pam is walking the user to change
+ gtk_editable_delete_text (GTK_EDITABLE (pwd->user_input_entry), 0, -1);
+ gtk_widget_hide (pwd->user_input_entry);
+ gtk_widget_hide (pwd->user_prompt_label);
+connect_signals (PasswdDialog *pwd)
+ g_signal_connect (pwd->button, "clicked",
+ G_CALLBACK (ok_clicked_cb),
+ g_signal_connect (pwd->user_input_entry, "activate",
+ G_CALLBACK (ok_clicked_cb),
+ g_signal_connect (pwd->dialog, "delete-event",
+ G_CALLBACK (gtk_main_quit),
+dialog_filter_func (GdkXEvent *xevent, GdkEvent *gevent, gpointer data)
+ PasswdDialog *pwd = data;
+ XEvent *event = xevent;
+ return GDK_FILTER_CONTINUE;
+ /* CR 6176524 passwdTimeoutEnable for disabled user */
+ g_object_set (pwd->progress, "fraction", ratio, NULL);
+ return GDK_FILTER_REMOVE;
+handle_input (GIOChannel *source, GIOCondition cond, gpointer data)
+ PasswdDialog *pwd = data;
+ char *hmsg = NULL; /* This is the heading of lock
dialog..shows status */
+ status = g_io_channel_read_line (source, &str, NULL, NULL, NULL);
+ while (status == G_IO_STATUS_AGAIN);
+ if (status == G_IO_STATUS_ERROR)
+ g_message ("handle input() status_error %s\n",str);
+ if (status == G_IO_STATUS_EOF)
+ g_message ("handle input() status_eof %s\n",str);
+ if (status == G_IO_STATUS_NORMAL)
+ g_message ("handle input() status_normal %s\n",str);
+ Most likely, the returned error msg of g_io_channel_read_line(),
+
i.e str will not be translated into other locales ...
+ /* strip trailing newline */
+ char *nl = strrchr(str, '\n');
+ /* Handle commands from parent daemon */
+ if (((strncmp (str, "ul_", 3)) == 0))
+ /* search for =, and if found, split into two strings there */
+ char *msgstr = strchr(str, '='); /* Data sent with command */
+ if ((strcmp (str, "ul_ok") == 0))
+ hmsg = _("Authentication Successful!");
+ else if ((strcmp (str, "ul_acct_ok") == 0))
+ hmsg = _("PAM Account Management Also Successful!");
+ else if ((strcmp (str, "ul_setcred_fail") == 0))
+ hmsg = _("Just a Warning PAM Set Credential Failed!");
+ else if ((strcmp (str, "ul_setcred_ok") == 0))
+ hmsg = _("PAM Set Credential Also Successful!");
+ else if ((strcmp (str, "ul_acct_fail") == 0))
+ hmsg = _("Your Password has expired.");
+ else if ((strcmp (str, "ul_fail") == 0))
+ else if ((strcmp (str, "ul_read") == 0))
+ hmsg = _("Waiting for user input!");
+ else if ((strcmp (str, "ul_time") == 0))
+ hmsg = _("Timed Out!");
+ else if ((strcmp (str, "ul_null") == 0))
+ hmsg = _("Still Checking!");
+ else if ((strcmp (str, "ul_cancel") == 0))
+ hmsg = _("Authentication Cancelled!");
+ else if ((strcmp (str, "ul_pamprompt") == 0))
+ gtk_label_set_text (GTK_LABEL (pwd->user_prompt_label), msgstr);
+ gtk_widget_show (pwd->user_prompt_label);
+ msgstr = NULL; /* clear message so we don't show it twice */
+ else if ((strcmp (str, "ul_prompt_echo") == 0))
+ if ((strcmp (msgstr, "true") == 0))
+ gtk_entry_set_visibility
+ (GTK_ENTRY (pwd->user_input_entry), TRUE);
+ if ((strcmp (msgstr, "stars") == 0))
+ /* reset to default display of "*" or bullet */
+ gtk_entry_unset_invisible_char
+ (GTK_ENTRY (pwd->user_input_entry));
+ /* set to no display */
+ gtk_entry_set_invisible_char
+ (GTK_ENTRY (pwd->user_input_entry), 0);
+ gtk_entry_set_visibility
+ (GTK_ENTRY (pwd->user_input_entry), FALSE);
+ msgstr = NULL; /* clear message so we don't show it to user */
+ /* Show the entry field */
+ gtk_widget_show (pwd->user_input_entry);
+ gtk_widget_grab_focus (pwd->user_input_entry);
+ (gtk_widget_get_display (pwd->user_input_entry));
+ else if ((strcmp (str, "ul_message") == 0))
+ hmsg = NULL; /* only show msg */
+ /* Should not be others, but if so just show it */
+ label = g_markup_printf_escaped ("<b>%s</b>", hmsg);
+ g_object_set (pwd->msg_label, "label", label, NULL);
+ gtk_label_set_text (GTK_LABEL (pwd->pam_message_label), msgstr);
+ else if ((strcmp (str, "cmd_exit") == 0))
+ else /* something came through that didn't start with ul_ */
+ gtk_label_set_text (GTK_LABEL (pwd->pam_message_label), str);
+ return (status != G_IO_STATUS_EOF);
+main (int argc, char *argv[])
+ char *real_progname = argv[0];
+ const char *modulesptr = NULL;
+ const char *locale = NULL;
+ gboolean at_enable = FALSE; /* accessibility mode enabled ? */
+ Bonobo_ServerInfoList *server_list = NULL;
+ Accessibility_LoginHelper helper;
+ Accessibility_LoginHelper *helper_list = NULL;
+ gboolean center_position = TRUE; /* center dialog on screen? */
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ if (!setlocale (LC_ALL, ""))
+ fprintf (stderr, "%s: locale not supported by C library\n", real_progname);
+#endif /* ! HAVE_GTK2 */
+ s = strrchr (real_progname, '/');
+ if (s) real_progname = s+1;
+ progname = real_progname;
+ parent_file = fdopen(FD_TO_PARENT, "w");
+ fprintf (stderr, "%s: can't communicate with parent, exiting.\n",
+ gtk_init (&argc, &argv);
+ /* Intern the atoms that xscreensaver_command() needs.
+ Display *dpy = gdk_x11_get_default_xdisplay();
+ const struct atom_request unlock_atoms[] =
+ { &XA_UNLOCK_RATIO, "UNLOCK_RATIO" },
+ { NULL, NULL } /* Must be last to terminate list */
+ const struct atom_request *atom_lists[3] = { NULL, NULL, NULL };
+ atom_lists[0] = remote_control_atoms;
+ atom_lists[1] = unlock_atoms;
+ request_atoms (dpy, atom_lists);
+ putenv ("GTK_IM_MODULE=gtk-im-context-simple");
+ /* accessibility mode enabled ? */
+ client = gconf_client_get_default ();
+ at_enable = gconf_client_get_bool (client,
+ /* GTK Accessibility Module initialized */
+ modulesptr = g_getenv ("GTK_MODULES");
+ if (!modulesptr || modulesptr [0] == '\0')
+ putenv ("GTK_MODULES=gail:atk-bridge");
+ CORBA_exception_init (&ev);
+ if (!bonobo_init (&argc, argv))
+ g_error ("Can't initialize Bonobo");
+ /* bonobo-activation query lists existing instances */
+ server_list = bonobo_activation_query (
+ bonobo_debug_shutdown ();
+ g_error ("LoginHelper query failed : %s",
+ bonobo_exception_get_text (&ev));
+ /* not reached (below) because g_error exits */
+ CORBA_exception_free (&ev);
+ * 6182506: unlock dialog can be obscured by the magnifier window
+ * if it's always centered, so don't force that if any accessibility
+ if (server_list && server_list->_length)
+ center_position = FALSE;
+ } /* accessibility enabled */
+ pwd = make_dialog (center_position);
+ gtk_widget_show_all (pwd->dialog);
+ gtk_window_present (GTK_WINDOW (pwd->dialog));
+ gtk_widget_map (pwd->dialog);
+ gdk_display_sync (gtk_widget_get_display (pwd->dialog));
+ gdk_window_add_filter (GET_WINDOW (pwd->dialog), dialog_filter_func, pwd);
+ write_windowid ("dialog_win", GDK_WINDOW_XID (GET_WINDOW (pwd->dialog)));
+ if (server_list && server_list->_length)
+ g_message ("%d LoginHelpers are running.",
+ server_list ? server_list->_length : 0);
+ helper_list = g_new0 (Accessibility_LoginHelper, server_list->_length);
+ /* for each instance... */
+ for (i = 0; i < server_list->_length; i++)
+ Bonobo_ServerInfo info = server_list->_buffer[i];
+ server = bonobo_activation_activate_from_id (
+
info.iid, Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, NULL, &ev);
+ g_warning ("Error activating server %d: %s", i,
+ bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ else if (server == CORBA_OBJECT_NIL)
+ g_warning ("Activated server %d is NIL!", i);
+ helper = Bonobo_Unknown_queryInterface
+ g_warning ("Error performing interface query: %s",
+ bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ else if (helper == CORBA_OBJECT_NIL)
+ g_warning ("Activated an object which advertised LoginHelper but does not implement it!");
+ helper_list[i] = helper;
+ bonobo_object_release_unref (server, &ev);
+ if (helper && !BONOBO_EX (&ev))
+ /* ask the helper to go into safe mode */
+ safe = Accessibility_LoginHelper_setSafe (helper, TRUE, &ev);
+ g_warning ("setSafe(TRUE) failed: %s",
+ bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ /* get the raise window list (if the program went into safe mode) */
+ gboolean needs_windows_raised = FALSE;
+ Accessibility_LoginHelper_DeviceReqList *list;
+ /* does this helper need to have windows raised? */
+ list = Accessibility_LoginHelper_getDeviceReqs (helper, &ev);
+ g_warning ("Bonobo exception getting Device Requirements: %s",
+ bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ g_debug ("LoginHelper device requirements: ");
+ if (list->_length == 0)
+ for (j = 0; j < list->_length; j++)
+ switch (list->_buffer[j])
+ case Accessibility_LoginHelper_GUI_EVENTS:
+ g_debug (" - Needs access to the GUI event subsystem (
e.g. Xserver)");
+ case Accessibility_LoginHelper_CORE_KEYBOARD:
+ g_debug (" - Needs access to core keyboard device");
+ write_to_parent("ungrab_keyboard", "true", FALSE);
+ case Accessibility_LoginHelper_CORE_POINTER:
+ g_debug (" - Needs access to core pointer device");
+ write_to_parent("ungrab_pointer", "true", FALSE);
+ case Accessibility_LoginHelper_EXT_INPUT:
+ g_debug (" - Reads XInput extended input devices");
+ case Accessibility_LoginHelper_POST_WINDOWS:
+ g_debug (" - Posts windows");
+ needs_windows_raised = TRUE;
+ case Accessibility_LoginHelper_AUDIO_OUT:
+ g_debug (" - Writes to audio device");
+ case Accessibility_LoginHelper_AUDIO_IN:
+ g_debug (" - Reads from audio device");
+ case Accessibility_LoginHelper_LOCALHOST:
+ g_debug (" - Needs LOCALHOST network connection");
+ case Accessibility_LoginHelper_SERIAL_OUT:
+ g_debug (" - Needs to write to one or more serial ports");
+ if (needs_windows_raised)
+ Accessibility_LoginHelper_WindowList *windows
+ = Accessibility_LoginHelper_getRaiseWindows
+ g_warning ("getRaiseWindows failed: %s",
+ bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ g_debug ("%d windows need raising", windows->_length);
+ for (j = 0; j < windows->_length; j++)
+ Window wid = windows->_buffer[j].winID;
+ g_debug ("Window ID = 0x%lx", wid);
+ write_windowid ("raise_win", wid);
+ g_warning ("LoginHelper %d did not go into safe mode", i);
+ g_warning ("Error activating %s: %s",
+
info.iid, bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ g_warning ("no active instance of %s found",
info.iid);
+ } /* accessibility helpers active */
+ /* Flush dialog window ids & any messages about login helpers to parent */
+ write_to_parent(NULL, NULL, TRUE);
+ gtk_widget_grab_focus (pwd->user_input_entry);
+ ioc = g_io_channel_unix_new (0);
+ g_get_charset (&locale);
+ g_io_channel_set_encoding(ioc, locale, NULL);
+ g_io_add_watch (ioc, G_IO_IN | G_IO_HUP, handle_input, pwd);
+ /* Reset accessibility helpers back to non-safe mode now that we're done */
+ for (i = 0; i < server_list->_length; i++)
+ helper = helper_list[i];
+ /* really no need to check the return value this time */
+ Accessibility_LoginHelper_setSafe (helper, FALSE, &ev);
+ g_warning ("setSafe(FALSE) failed: %s",
+ bonobo_exception_get_text (&ev));
+ CORBA_exception_free (&ev);
+ CORBA_Object_release (helper, &ev);
+ CORBA_free (server_list);
+ bonobo_debug_shutdown ();
@@ -83,126 +88,631 @@ vms_passwd_valid_p(char *pw, Bool verbose_p)
typedef struct info_dialog_data info_dialog_data;
-#define MAX_BYTES_PER_CHAR 8 /* UTF-8 uses no more than 3, I think */
-#define MAX_PASSWD_CHARS 128 /* Longest possible passphrase */
-struct passwd_dialog_data {
- saver_screen_info *prompt_screen;
- int previous_mouse_x, previous_mouse_y;
- /* "Characters" in the password may be a variable number of bytes long.
- typed_passwd contains the raw bytes.
- typed_passwd_char_size indicates the size in bytes of each character,
- so that we can make backspace work.
- char typed_passwd [MAX_PASSWD_CHARS * MAX_BYTES_PER_CHAR];
- char typed_passwd_char_size [MAX_PASSWD_CHARS];
- Dimension border_width;
- Bool show_stars_p; /* "I regret that I have but one asterisk for my country."
- -- Nathan Hale, 1776. */
- /* The entry field shall only be displayed if prompt_label is not NULL */
- mlstring *prompt_label;
- Bool passwd_changed_p; /* Whether the user entry field needs redrawing */
- Bool caps_p; /* Whether we saw a keypress with caps-lock on */
- XFontStruct *heading_font;
- XFontStruct *body_font;
- XFontStruct *label_font;
- XFontStruct *passwd_font;
- XFontStruct *date_font;
- XFontStruct *button_font;
- XFontStruct *uname_font;
- Pixel passwd_foreground;
- Pixel passwd_background;
- Pixel thermo_foreground;
- Pixel thermo_background;
- Pixel button_foreground;
- Pixel button_background;
- Dimension preferred_logo_width, logo_width;
- Dimension preferred_logo_height, logo_height;
- Dimension thermo_width;
- Dimension internal_border;
- Dimension shadow_width;
- Dimension passwd_field_x, passwd_field_y;
- Dimension passwd_field_width, passwd_field_height;
- Dimension unlock_button_x, unlock_button_y;
- Dimension unlock_button_width, unlock_button_height;
- Dimension login_button_x, login_button_y;
- Dimension login_button_width, login_button_height;
- Dimension thermo_field_x, thermo_field_y;
- Dimension thermo_field_height;
- unsigned long *logo_pixels;
- Bool unlock_button_down_p;
- Bool login_button_down_p;
- Bool login_button_enabled_p;
- Bool button_state_changed_p; /* Refers to both buttons */
- Pixmap user_entry_pixmap;
+#ifndef HAVE_XSCREENSAVER_LOCK
static void draw_passwd_window (saver_info *si);
static void update_passwd_window (saver_info *si, const char *printed_passwd,
static void destroy_passwd_window (saver_info *si);
+static int ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error);
static void undo_vp_motion (saver_info *si);
+#ifndef HAVE_XSCREENSAVER_LOCK
static void finished_typing_passwd (saver_info *si, passwd_dialog_data *pw);
static void cleanup_passwd_window (saver_info *si);
static void restore_background (saver_info *si);
extern void xss_authenticate(saver_info *si, Bool verbose_p);
+#ifdef HAVE_XSCREENSAVER_LOCK
+#define WIN_ALLOC_INCREMENT 8 /* allocate entries in the window lists in
+ increments of 8 at a time for fewer
+ reallocs and less chance of malloc error
+#define EXTRA_RAISE_WIN_SLOTS 4 /* Need to leave four extra slots free in
+ raise_wins to allow calling XRestackWindows
+ when a window pops up without having to
+ realloc or copy to a new list.
+ These slots would be used by:
+ - stderr_overlay_window
+ - xscreensaver virtual root
+ - an interloper popup we need to hide
+extern Atom XA_UNLOCK_RATIO;
+Bool g_passwd_dialog_created = 0;
+GConfClient *client = NULL;
+static const char *switch_windows_gconf_key
+static char *global_switch_key = NULL;
+static const char *main_menu_gconf_key
+static char *global_menu_key = NULL;
+extern Bool safe_XDestroyWindow (Display *dpy, Window window);
+static Bool safe_XRestackWindows(Display *dpy, Window windows[], int nwindows);
+static Bool safe_XSendEvent(Display *dpy, Window w, Bool propagate,
+ long event_mask, XEvent *event_send);
+static void passwd_animate_timer (XtPointer closure, XtIntervalId *id);
+extern void swallow_unlock_typeahead_events (saver_info *si, XEvent *e);
+static saver_screen_info *
+find_screen_for_window (saver_info *si, Window wid)
+ saver_screen_info *ssi;
+ Window root, root_ret, parent_ret, *children = NULL;
+ unsigned int nchildren = 0;
+ status = XQueryTree (si->dpy, wid, &root_ret, &parent_ret,
+ &children, &nchildren);
+ if (status == 0) /* failed */
+ for (screen_no = 0; screen_no < si->nscreens; screen_no++)
+ ssi = &si->screens[screen_no];
+ root = RootWindowOfScreen (screen);
+ return NULL; /* Didn't match the root on any screen we know of - PUNT! */
+ 5083155 Unable to unlock screen when running dual-head MAG
+ adding dual or multiple heads for magnifier support
+ screen 0: loginhelp can pass the raisedWid of GOK or MAG or both
+ found: return its parent Wid (child of root)
+ other screen: MAG only if the target screen no > 0 is selected
+ found: restack on that screen
+check_raisedWid (saver_info *si, Window wid)
+ saver_screen_info *ssi;
+ Window root, root_ret, parent_ret, *children = NULL;
+ unsigned int nchildren = 0;
+ status = XQueryTree (si->dpy, wid, &root_ret, &parent_ret,
+ &children, &nchildren);
+ if (status == 0) /* failed */
+ for (screen_no = 0; screen_no < si->nscreens; screen_no++)
+ ssi = &si->screens[screen_no];
+ root = RootWindowOfScreen (screen);
+ if ( screen_no >= si->nscreens ) /* Didn't match the root on any screen */
+ return 0; /* we know of - PUNT! */
+ /* Climb the tree until we find an ancestor that's a child of root */
+ while ( root_ret != parent_ret )
+ status = XQueryTree (si->dpy, wid, &root_ret, &parent_ret,
+ &children, &nchildren);
+ if (status == 0) /* failed */
+ if ( ssi != si->pw_data->prompt_screen )
+ /* found in other screen (not the one with the unlock dialog),
+ implies MAG target screen, invoke XRestackWindow() there
+ Window screen_win[2] = { wid, ssi->screensaver_window };
+ safe_XRestackWindows(si->dpy, screen_win, 2);
+ return 0; /* no need to do the restack on prompt screen */
+/* Enforce window stacking order when a new window arrives.
+ Only allow raising windows the unlock dialog has told us to raise
+restack_my_windows (saver_info* si, saver_screen_info *ssi, Window newWin)
+ Window short_stack[EXTRA_RAISE_WIN_SLOTS];
+ /* If window is on another screen than the unlock dialog,
+ or we have list of no windows to raise */
+ if ((si->raise_wins == NULL) || (ssi != si->pw_data->prompt_screen))
+ restack_list = short_stack;
+ restack_list = si->raise_wins;
+ for (n = 0; n < si->num_raise_wins; n++)
+ if (si->raise_wins[n] == newWin)
+ if (si->passwd_dialog && (ssi == si->pw_data->prompt_screen))
+ restack_list[n++] = si->passwd_dialog;
+ if (si->passwd_dialog == newWin)
+ if (ssi->stderr_overlay_window)
+ restack_list[n++] = ssi->stderr_overlay_window;
+ if (ssi->stderr_overlay_window == newWin)
+ if (ssi->screensaver_window)
+ restack_list[n++] = ssi->screensaver_window;
+ if (ssi->screensaver_window == newWin)
+ /* If it's not in the allowed list, it goes behind
+ the screensaver_window. */
+ if (newWin && !allowed)
+ restack_list[n++] = newWin;
+ safe_XRestackWindows (si->dpy, restack_list, n);
+/* Send a command to the xscreensaver-lock child process
+ - msg - message to send, such as ul_ok
+ - data - additional data, such as string to display for this message,
+ Message format sent to child:
+ "msg\n" if no data, otherwise "msg=data\n"
+write_to_child (saver_info* si, const char* msg, const char *data)
+ fprintf (stderr, "Invalid null message written to child\n");
+ if (si->external_passwd && g_passwd_dialog_created &&
+ si->pw_data->stdin_fd != -1)
+ "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
+ "HAVE_SCRSVR_LOCK writing to fd:%d message is:\n%s=%s\n"
+ "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n",
+ si->pw_data->stdin_fd, msg, data ? data : "(null)");
+ len = fprintf (si->pw_data->stdin_file, "%s=%s\n", msg, data);
+ len = fprintf (si->pw_data->stdin_file, "%s\n", msg);
+ fflush (si->pw_data->stdin_file);
+ return (0); /* if we didn't write anything return 0 */
+sane_dup2 (int fd1, int fd2)
+ while (ret < 0 && errno == EINTR);
+close_and_invalidate (int *fd)
+handle_passwd_input (XtPointer xtdata, int *fd, XtInputId *id)
+ saver_info *si = (saver_info *)xtdata;
+ saver_preferences *p = &si->prefs;
+ passwd_dialog_data *pw = si->pw_data;
+ fprintf (stderr, "passwd input handler() fd=%d\n", *fd);
+ msg = fgets (buffer, sizeof (buffer), pw->stdout_file);
+ if (!msg) /* child closed pipe */
+ fprintf (stderr, "done reading...\n");
+ fprintf (stderr, "removing input handler...\n");
+ pw->stdout_input_id = 0;
+ fprintf (stderr, "Child sent message: %s\n", msg);
+ /* search for =, and if found, split msg & data into two strings there */
+ data = strchr(msg, '=');
+ /* strip trailing newline */
+ nl = strchr (data, '\n');
+ /* All the messages we currently expect require data! */
+ fprintf (stderr, "*** Invalid message: no data found, discarding\n");
+ if ((strcmp(msg, "input") == 0)) /* User input */
+ si->unlock_state = ul_finished;
+ pw->passwd_string = strdup (data);
+ memset (data, 0, strlen(data));
+ else if ((strcmp(msg, "ungrab_keyboard") == 0))
+ /* An accessibility helper needs to access the keyboard, so we have
+ to release our grab - unfortunately this risks other apps acting
+ on keys they shouldn't, so first we disable metacity keys that
+ could allow getting back to the locked session windows, and hope
+ we don't crash or die before restoring them later.
+ Other window managers are likely to be risky to use in this case.
+ client = gconf_client_get_default();
+ if (global_switch_key == NULL)
+ gconf_client_get_string (client, switch_windows_gconf_key, NULL);
+ if (global_switch_key && strncmp (global_switch_key, "dis", 3))
+ gconf_client_set_string (client, switch_windows_gconf_key,
+ if (global_menu_key == NULL)
+ gconf_client_get_string (client, main_menu_gconf_key, NULL);
+ if (global_menu_key && strncmp(global_menu_key, "dis", 3))
+ gconf_client_set_string (client, main_menu_gconf_key,
+ XUngrabKeyboard (si->dpy, CurrentTime);
+ else if ((strcmp(msg, "ungrab_pointer") == 0))
+ /* An accessibility helper needs to access the mouse, so we have
+ to release our grab - this is simpler, since we don't worry about
+ mouse gestures that may get through, though maybe we should...
+ XUngrabPointer (si->dpy, CurrentTime);
+ else /* Get a window id of an interesting window from the child */
+ Window window = strtoul (data, NULL, 0);
+ if ((strcmp (msg, "dialog_win") == 0))
+ /* The unlock dialog itself */
+ si->passwd_dialog = window;
+ pw->got_windowid = True;
+ move_mouse_grab (si, si->passwd_dialog, pw->passwd_cursor,
+ pw->prompt_screen->number);
+ passwd_animate_timer ((XtPointer) si, 0);
+ /* Flush queue of captured typeahead events */
+ if (si->typeahead_events && si->num_typeahead_events)
+ for (i = 0; i < si->num_typeahead_events; i++)
+ si->typeahead_events[i].window = window;
+ safe_XSendEvent (si->dpy, window, False, KeyPressMask,
+ (XEvent *) &si->typeahead_events[i]);
+ si->num_typeahead_events = 0;
+ XGrabKeyboard (si->dpy, window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
+ XGrabPointer (si->dpy, window, True, 0, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
+ XSetInputFocus (si->dpy, window, RevertToPointerRoot, CurrentTime);
+ XSync (si->dpy, False);
+ else if ((strcmp (msg, "raise_win") == 0))
+ /* Accessibility helpers that need to be raised above the
+ full-screen blanking window hiding the user's desktop */
+ if ( (si->num_raise_wins + EXTRA_RAISE_WIN_SLOTS)
+ int raise_alloc = si->max_raise_wins + WIN_ALLOC_INCREMENT;
+ newlist = realloc(si->raise_wins, raise_alloc * sizeof(Window));
+ si->raise_wins = newlist;
+ si->max_raise_wins = raise_alloc;
+ overwin = check_raisedWid (si, window);
+ XWindowAttributes attrs;
+ status = XGetWindowAttributes (si->dpy, overwin, &attrs);
+ unsigned long valuemask = CWOverrideRedirect;
+ XSetWindowAttributes setwinattr;
+ XChangeWindowAttributes (si->dpy, overwin,
+ valuemask, &setwinattr);
+ if (si->num_override_wins >= si->max_override_wins)
+ = si->max_override_wins + WIN_ALLOC_INCREMENT;
+ newlist = realloc(si->override_wins,
+ over_alloc * sizeof(Window));
+ si->override_wins = newlist;
+ si->max_override_wins = over_alloc;
+ si->override_wins[si->num_override_wins++] = overwin;
+ XMapSubwindows(si->dpy, overwin);
+ si->raise_wins[si->num_raise_wins++] = overwin;
+ si->raise_wins[si->num_raise_wins++] = window;
+ restack_my_windows(si, si->pw_data->prompt_screen, 0);
+spawn_external_passwd_process (saver_info *si, passwd_dialog_data *pw)
+ saver_preferences *p = &si->prefs;
+ const char *command = LOCKDIR "/xscreensaver-lock";
+ int stdin_pipe[2] = { -1, -1 };
+ int stdout_pipe[2] = { -1, -1 };
+ pw->stdin_fd = pw->stdout_fd = -1;
+ pw->got_windowid = False;
+ fprintf(stderr, "-->spawn_external_passwd()\n");
+ if (si->passwd_pid > 0)
+ fprintf (stderr,"pid %ld still exists. Killing it with SIGKILL\n",
+ kill_job (si, si->passwd_pid, SIGKILL);
+ if (pipe (stdin_pipe) < 0)
+ perror ("pipe(stdin_pipe) failed!");
+ if (pipe (stdout_pipe) < 0)
+ perror ("pipe(stdout_pipe) failed!");
+ close_and_invalidate (&stdin_pipe[0]);
+ close_and_invalidate (&stdin_pipe[1]);
+ switch ((int) (forked = fork ()))
+ fprintf (stderr, "%s: ", blurb ());
+ perror ("couldn't fork");
+ close_and_invalidate (&stdin_pipe[0]);
+ close_and_invalidate (&stdin_pipe[1]);
+ close_and_invalidate (&stdout_pipe[0]);
+ close_and_invalidate (&stdout_pipe[1]);
+ close (ConnectionNumber (si->dpy)); /* close display fd */
+ /* limit_subproc_memory (p->inferior_memory_limit, p->verbose_p); */
+ /* hack_subproc_environment (ssi); */ /* FIX $DISPLAY */
+ /* Inside Child Process */
+ fprintf (stderr, "%s: spawning \"%s\" in pid %lu.\n",
+ blurb(), command, (unsigned long) getpid ());
+ close_and_invalidate (&stdin_pipe[1]);
+ close_and_invalidate (&stdout_pipe[0]);
+ sane_dup2 (stdin_pipe[0], 0); /* Listen to Parent from here */
+ sane_dup2 (stdout_pipe[1], 9); /* Talk to Parent from here */
+ /* Make sure we have relinquished setuid privs or lock dialog gtk
+ * program will not run as libgtk is not setuid safe.
+ exec_command (p->shell, command, 0);
+ /* print_path_error (command); */
+ fprintf (stderr, "%s: couldn't exec: %s\n",
+ make_job(forked, 0, command);
+ close_and_invalidate (&stdin_pipe[0]);
+ close_and_invalidate (&stdout_pipe[1]);
+ sane_dup2 (stdin_pipe[0], 0); /* Listen to Child from here */
+ sane_dup2 (stdout_pipe[1], 13); /* Talk to Child from here */
+ pw->stdin_fd = stdin_pipe[1]; /* Talk to child from here */
+ pw->stdout_fd = stdout_pipe[0]; /* Listen to Child from here */
+ si->passwd_pid = forked;
+ /* Messages to child dialog are sent through this
pipe/fd */
+ pw->stdin_file = fdopen (pw->stdin_fd, "w");
+ write_to_child (si, "Hello", NULL); /* Send a test message to Child */
+ /* Password from child dialog comes through this
pipe/fd */
+ pw->stdout_file = fdopen (pw->stdout_fd, "r");
+ pw->stdout_input_id = XtAppAddInput (si->app, pw->stdout_fd,
+ (XtPointer) XtInputReadMask,
+ handle_passwd_input, si);
+ /* Set global flag to indicate that lock dialog is visible */
+ g_passwd_dialog_created = True;
+#endif /* HAVE_XSCREENSAVER_LOCK */
new_passwd_window (saver_info *si)
+#ifndef HAVE_XSCREENSAVER_LOCK
saver_screen_info *ssi = &si->screens [mouse_screen (si)];
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* si->pw_data is globally allocated and never freed when HAVE_XSS_LOCK */
+ if (!spawn_external_passwd_process (si, pw))
+ si->external_passwd = True;
pw = (passwd_dialog_data *) calloc (1, sizeof(*pw));
@@ -211,17 +721,21 @@ new_passwd_window (saver_info *si)
pw->passwd_cursor = XCreateFontCursor (si->dpy, XC_top_left_arrow);
+#ifndef HAVE_XSCREENSAVER_LOCK
screen = pw->prompt_screen->screen;
cmap = DefaultColormapOfScreen (screen);
+#ifndef HAVE_XSCREENSAVER_LOCK
@@ -376,6 +890,7 @@ new_passwd_window (saver_info *si)
if (pw->shadow_width == 0) pw->shadow_width = 4;
if (pw->thermo_width == 0) pw->thermo_width = pw->shadow_width;
+#endif /* ! HAVE_XSCREENSAVER_LOCK */
/* We need to remember the mouse position and restore it afterward, or
sometimes (perhaps only with Xinerama?) the mouse gets warped to
@@ -442,12 +957,16 @@ make_passwd_window (saver_info *si,
+#ifndef HAVE_XSCREENSAVER_LOCK
XSetWindowAttributes attrs;
unsigned long attrmask = 0;
+#ifndef HAVE_XSCREENSAVER_LOCK
Dimension max_string_width_px;
saver_screen_info *ssi = &si->screens [mouse_screen (si)];
cleanup_passwd_window (si);
@@ -455,7 +974,12 @@ make_passwd_window (saver_info *si,
if (! ssi) /* WTF? Trying to prompt while no screens connected? */
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* si->pw_data is globally allocated and never freed when HAVE_XSS_LOCK */
+ if (!si->pw_data->got_windowid)
if (new_passwd_window (si) < 0)
@@ -470,6 +994,29 @@ make_passwd_window (saver_info *si,
blurb(), pw->prompt_screen->number,
info_msg ? info_msg : "");
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* Wipe the old password, so we get prompted to enter new password. */
+ memset(pw->passwd_string, 0, strlen (pw->passwd_string));
+ free (pw->passwd_string);
+ pw->passwd_string = NULL;
+ write_to_child (si, "ul_message", info_msg);
+ write_to_child (si, "ul_pamprompt", prompt);
+ write_to_child (si, "ul_prompt_echo", "true");
+ else if (pw->show_stars_p)
+ write_to_child (si, "ul_prompt_echo", "stars");
+ write_to_child (si, "ul_prompt_echo", "false");
screen = pw->prompt_screen->screen;
cmap = DefaultColormapOfScreen (screen);
@@ -721,11 +1268,13 @@ make_passwd_window (saver_info *si,
XInstallColormap (si->dpy, cmap);
+#endif /* ! HAVE_XSCREENSAVER_LOCK */
+#ifndef HAVE_XSCREENSAVER_LOCK
draw_passwd_window (saver_info *si)
@@ -1071,17 +1620,48 @@ draw_button(Display *dpy,
draw_shaded_rectangle(dpy, dialog, x, y, width, height,
shadow_width, shadow_light, shadow_dark);
+#endif /* !HAVE_XSCREENSAVER_LOCK */
update_passwd_window (saver_info *si, const char *printed_passwd, float ratio)
passwd_dialog_data *pw = si->pw_data;
+#ifndef HAVE_XSCREENSAVER_LOCK
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* Send countdown timer ratio to child lock dialog */
+ if (!safe_XSendEvent (si->dpy, si->passwd_dialog, False, 0L, &event))
+ fprintf (stderr, "%s: error sending ratio to lock dialog\n", blurb ());
+ "-->update_passwd_window() lockdialog not created, returning!!\n");
gc1 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground|GCFont, &gcv);
@@ -1226,6 +1806,7 @@ update_passwd_window (saver_info *si, const char *printed_passwd, float ratio)
+#endif /* !HAVE_XSCREENSAVER_LOCK */
@@ -1257,6 +1838,9 @@ cleanup_passwd_window (saver_info *si)
+ fprintf (stderr, "cleanup_passwd_window\n");
@@ -1274,7 +1858,13 @@ cleanup_passwd_window (saver_info *si)
memset (pw->typed_passwd, 0, sizeof(pw->typed_passwd));
memset (pw->typed_passwd_char_size, 0, sizeof(pw->typed_passwd_char_size));
- memset (pw->passwd_string, 0, strlen(pw->passwd_string));
+ memset (pw->passwd_string, 0, strlen(pw->passwd_string));
+ free (pw->passwd_string);
+ pw->passwd_string = NULL;
@@ -1297,8 +1887,10 @@ destroy_passwd_window (saver_info *si)
passwd_dialog_data *pw = si->pw_data;
saver_screen_info *ssi = pw->prompt_screen;
Colormap cmap = DefaultColormapOfScreen (ssi->screen);
+#ifndef HAVE_XSCREENSAVER_LOCK
Pixel black = BlackPixelOfScreen (ssi->screen);
Pixel white = WhitePixelOfScreen (ssi->screen);
cleanup_passwd_window (si);
@@ -1314,6 +1906,81 @@ destroy_passwd_window (saver_info *si)
si->cached_passwd = NULL;
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* reset global flag to indicate passwd dialog is no longer there */
+ g_passwd_dialog_created = False;
+ if (si->external_passwd)
+ /* kill the child etc. */
+ write_to_child (si, "cmd_exit", NULL);
+ fclose (pw->stdin_file);
+ if (pw->stdin_fd != -1)
+ close_and_invalidate (&pw->stdin_fd);
+ if (pw->stdout_input_id)
+ XtRemoveInput (pw->stdout_input_id);
+ fclose (pw->stdout_file);
+ else if (pw->stdout_fd != -1)
+ close_and_invalidate (&pw->stdout_fd);
+ kill_job (si, si->passwd_pid, SIGTERM);
+ si->num_raise_wins = 0;
+ si->max_raise_wins = 0;
+ unsigned long valuemask = CWOverrideRedirect;
+ XSetWindowAttributes setwinattr;
+ for (n = 0; n < si->num_override_wins; n++)
+ XChangeWindowAttributes (si->dpy, si->override_wins[n],
+ valuemask, &setwinattr);
+ free(si->override_wins);
+ si->override_wins = NULL;
+ si->num_override_wins = 0;
+ si->max_override_wins = 0;
+ si->pw_data->got_windowid = False;
+ si->external_passwd = False;
+ /* restore any metacity keys we temporarily disabled */
+ gconf_client_set_string (client, switch_windows_gconf_key,
+ global_switch_key, NULL);
+ g_free(global_switch_key);
+ global_switch_key = NULL;
+ gconf_client_set_string (client, main_menu_gconf_key,
+ global_menu_key, NULL);
+ g_free(global_menu_key);
+ global_menu_key = NULL;
+#endif /* HAVE_XSCREENSAVER_LOCK */
move_mouse_grab (si, RootWindowOfScreen (ssi->screen),
ssi->cursor, ssi->number);
@@ -1348,7 +2015,14 @@ destroy_passwd_window (saver_info *si)
fprintf (stderr, "%s: %d: destroying password dialog.\n",
blurb(), pw->prompt_screen->number);
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* Ignore X error if window was already closed by the child,
+ and make sure any VisibilityNotify events are removed
+ from the event queue before we forget the window id. */
+ safe_XDestroyWindow (si->dpy, si->passwd_dialog);
XDestroyWindow (si->dpy, si->passwd_dialog);
@@ -1359,6 +2033,7 @@ destroy_passwd_window (saver_info *si)
+#ifndef HAVE_XSCREENSAVER_LOCK
if (pw->heading_label) free (pw->heading_label);
if (pw->body_label) free (pw->body_label);
if (pw->user_label) free (pw->user_label);
@@ -1409,6 +2084,7 @@ destroy_passwd_window (saver_info *si)
+#endif /* ! HAVE_XSCREENSAVER_LOCK */
XFreePixmap (si->dpy, pw->save_under);
@@ -1416,9 +2092,12 @@ destroy_passwd_window (saver_info *si)
XInstallColormap (si->dpy, cmap);
+#ifndef HAVE_XSCREENSAVER_LOCK
+ /* si->pw_data is globally allocated and never freed when HAVE_XSS_LOCK */
memset (pw, 0, sizeof(*pw));
@@ -1435,6 +2114,49 @@ ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error)
#endif /* HAVE_XF86MISCSETGRABKEYSSTATE || HAVE_XF86VMODE */
+#ifdef HAVE_XSCREENSAVER_LOCK
+/* Catch errors from XRestackWindows, since there's an inherent race
+ condition in which other clients can destroy windows between when
+ we get the notification event and when we send the RestackWindows
+safe_XRestackWindows(Display *dpy, Window windows[], int nwindows)
+ XErrorHandler old_handler;
+ error_handler_hit_p = False;
+ old_handler = XSetErrorHandler (ignore_all_errors_ehandler);
+ XRestackWindows (dpy, windows, nwindows);
+ XSetErrorHandler (old_handler);
+ return (!error_handler_hit_p);
+safe_XSendEvent(Display *dpy, Window w, Bool propagate,
+ long event_mask, XEvent *event_send)
+ XErrorHandler old_handler;
+ error_handler_hit_p = False;
+ old_handler = XSetErrorHandler (ignore_all_errors_ehandler);
+ status = XSendEvent (dpy, w, propagate, event_mask, event_send);
+ XSetErrorHandler (old_handler);
+ return (!error_handler_hit_p && status);
#ifdef HAVE_XHPDISABLERESET
/* This function enables and disables the C-Sh-Reset hot-key, which
@@ -1636,6 +2358,17 @@ passwd_animate_timer (XtPointer closure, XtIntervalId *id)
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* We want to make sure dialog is up before we update countdown timer */
+ if (!si->passwd_dialog)
@@ -1655,6 +2388,7 @@ passwd_animate_timer (XtPointer closure, XtIntervalId *id)
idle_timer ((XtPointer) si, 0);
+#ifndef HAVE_XSCREENSAVER_LOCK
static XComposeStatus *compose_status;
@@ -1732,6 +2466,7 @@ finished_typing_passwd (saver_info *si, passwd_dialog_data *pw)
update_passwd_window (si, "", pw->ratio);
+#endif /* !HAVE_XSCREENSAVER_LOCK */
handle_passwd_key (saver_info *si, XKeyEvent *event)
@@ -1739,7 +2474,8 @@ handle_passwd_key (saver_info *si, XKeyEvent *event)
passwd_dialog_data *pw = si->pw_data;
unsigned char decoded [MAX_BYTES_PER_CHAR * 10]; /* leave some slack */
+#ifndef HAVE_XSCREENSAVER_LOCK
/* XLookupString may return more than one character via XRebindKeysym;
and on some systems it returns multi-byte UTF-8 characters (contrary
to its documentation, which says it returns only Latin1.)
@@ -1773,11 +2509,40 @@ handle_passwd_key (saver_info *si, XKeyEvent *event)
decoded[decoded_size] = 0;
pw->passwd_changed_p = True;
+#endif /* !HAVE_XSCREENSAVER_LOCK */
/* Add 10% to the time remaining every time a key is pressed. */
if (pw->ratio > 1) pw->ratio = 1;
+#ifdef HAVE_XSCREENSAVER_LOCK
+ if (si->pw_data->got_windowid)
+ event->window = si->passwd_dialog;
+ status = safe_XSendEvent (si->dpy, si->passwd_dialog,
+ False, KeyPressMask, (XEvent *) event);
+ fprintf (stderr, "sent key...\n");
+ fprintf (stderr, "error %d sending key...\n", status);
+ update_passwd_window (si, NULL, pw->ratio);
+ swallow_unlock_typeahead_events (si, (XEvent *) event);
+#else /* !HAVE_XSCREENSAVER_LOCK */
if (decoded_size == 1) /* Handle single-char commands */
@@ -1867,6 +2632,7 @@ handle_passwd_key (saver_info *si, XKeyEvent *event)
update_passwd_window (si, "", pw->ratio);
+#endif /* !HAVE_XSCREENSAVER_LOCK */
@@ -1890,7 +2656,9 @@ passwd_event_loop (saver_info *si)
passwd_animate_timer ((XtPointer) si, 0);
reset_watchdog_timer (si, False); /* Disable watchdog while dialog up */
- while (si->unlock_state == ul_read)
+ si->pw_data->got_passwd = FALSE;
+ while (si->unlock_state == ul_read && si->pw_data->got_passwd == FALSE)
@@ -1931,12 +2699,17 @@ passwd_event_loop (saver_info *si)
+#ifdef HAVE_XSCREENSAVER_LOCK
+#endif /* !HAVE_XSCREENSAVER_LOCK */
+#ifndef HAVE_XSCREENSAVER_LOCK
@@ -1945,6 +2718,82 @@ passwd_event_loop (saver_info *si)
if (si->pw_data->login_button_p)
+#endif /* !HAVE_XSCREENSAVER_LOCK */
+ 5077974 P1 "Bug 147583: Screen Lock unlocks because of GOK dwell movement in
+ ScreenLock did not unlock the screen, but WM's XRestackWindow() did.
+ Once
WM/metacity fixes the problem, the code can be removed.
+ repositioning the Wids in the wrong positions when
+ 1. the window type is changed from NORMAL to DOCK or vice versa
+ within the X window stack with or without screen-lock in a mixed Wids
+ there are two temp. get-around solutions:
+ 1. non-managed GOK or MAG Wid
+ 2. screensaver picks up the WM's restacking task and fixes the prevous
+ the cons: there is a flashing screen when corepointer is touching
+ GOK or MAG and mouse is moved in a fast way
+ when GOK or MAG window type is DOCK only.
+ and it is not a good temp. get-around solution.
+ This is the only choice if WM did not want to fix the problem now
+ and AT group did not want to use non-managed Wids.
+ not to be used, and GOK cannot disable it
+ bugid 6769901,6839026: popup windows appearing through xscreensaver
+ && (si->passwd_dialog))
+ /* Find the handle of popup window
+ * Note: we can not get handle of popup window with
+ saver_screen_info *ssi = find_screen_for_window (si, wPopWin);
+ /* This if case is for safety, it prevent screensaver stuck in
+ * loop of ConfigureNotify
+ if ((wPopWin != si->passwd_dialog) && (ssi != NULL) &&
+ (wPopWin != ssi->screensaver_window) &&
+ (wPopWin != ssi->stderr_overlay_window))
+ restack_my_windows(si, ssi, wPopWin);
+ /* the above new code for restacking under the condition */
@@ -1970,8 +2819,13 @@ passwd_event_loop (saver_info *si)
+#ifdef HAVE_XSCREENSAVER_LOCK
+ write_to_child (si, "ul_message", msg);
+ usleep (250000); /* 1/4 second */
update_passwd_window (si, msg, 0.0);
@@ -1989,6 +2843,10 @@ passwd_event_loop (saver_info *si)
handle_typeahead (saver_info *si)
+/* HAVE_XSCREENSAVER_LOCK: typeahead events are flushed to the external
+ dialog program in handle_passwd_input when we get the dialog_win notice
+ that it has created the window */
+#ifndef HAVE_XSCREENSAVER_LOCK
passwd_dialog_data *pw = si->pw_data;
if (!si->unlock_typeahead)
@@ -2016,6 +2874,7 @@ handle_typeahead (saver_info *si)
free (si->unlock_typeahead);
si->unlock_typeahead = 0;
@@ -2121,9 +2980,11 @@ gui_auth_conv(int num_msg,
+#ifndef HAVE_XSCREENSAVER_LOCK
compose_status = calloc (1, sizeof (*compose_status));
si->unlock_state = ul_read;
@@ -2133,7 +2994,14 @@ gui_auth_conv(int num_msg,
if (si->unlock_state == ul_cancel)
+#ifdef HAVE_XSCREENSAVER_LOCK
+ if ((si->unlock_state != ul_time) && si->pw_data->passwd_string)
+ responses[i].response = strdup (si->pw_data->passwd_string);
responses[i].response = strdup(si->pw_data->typed_passwd);
/* Cache the first response to a PROMPT_NOECHO to save prompting for
* each auth mechanism. */
@@ -2141,8 +3009,10 @@ gui_auth_conv(int num_msg,
auth_msgs[i].type == AUTH_MSGTYPE_PROMPT_NOECHO)
si->cached_passwd = strdup(responses[i].response);
+#ifndef HAVE_XSCREENSAVER_LOCK
@@ -2150,9 +3020,11 @@ gui_auth_conv(int num_msg,
return (si->unlock_state == ul_finished) ? 0 : -1;
+#ifndef HAVE_XSCREENSAVER_LOCK
@@ -2213,11 +3085,14 @@ auth_finished_cb (saver_info *si)
XNextEvent (si->dpy, &event);
+#ifndef HAVE_XSCREENSAVER_LOCK
@@ -2226,7 +3101,7 @@ auth_finished_cb (saver_info *si)
+ if (si->pw_data && si->pw_data->prompt_screen)
destroy_passwd_window (si);
index 0c60d50..93c73f1 100644
#ifndef NO_LOCKING /* whole file */
extern char *blurb(void);
@@ -58,6 +64,7 @@ extern char *blurb(void);
extern sigset_t block_sigchld (void);
@@ -82,7 +89,10 @@ extern void unblock_sigchld (void);
static int pam_conversation (int nmsgs,
- const struct pam_message **msg,
+ struct pam_message **msg,
struct pam_response **resp,
@@ -183,6 +193,11 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
+ int pam_auth_status = 0; /* Specific for pam_authenticate() status*/
+ int acct_rc, setcred_rc, chauth_rc;
+ uid_t euid = geteuid();
@@ -191,6 +206,23 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
`closure' argument to
pc.conv always comes in as random garbage. */
suns_pam_implementation_blows = (void *) si;
+ fprintf (stderr, "Before uid=%d euid=%d \n\n", getuid(), geteuid());
+ perror("Could not change euid to root, pam may not work!\n");
+ fprintf (stderr, "After seteuid(0) uid=%d euid=%d \n\n",
+ fprintf (stderr, "PAM is using SERVICE_NAME=\"%s\"\n\n", service);
@@ -201,11 +233,35 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
status, PAM_STRERROR (pamh, status));
if (status != PAM_SUCCESS) goto DONE;
+ PAM_DISALLOW_NULL_AUTHTOK to pam_flags */
+ int flags = defcntl(DC_GETFLAGS, 0);
+ TURNOFF(flags, DC_CASE);
+ (void) defcntl(DC_SETFLAGS, flags);
+ if ((ptr = defread("PASSREQ=")) != NULL &&
+ strcasecmp("YES", ptr) == 0)
+ pam_flags |= PAM_DISALLOW_NULL_AUTHTOK;
+ (void) defopen((char *)NULL); /* close current file */
/* #### We should set PAM_TTY to the display we're using, but we
don't have that handy from here. So set it to :0.0, which is a
good guess (and has the bonus of counting as a "secure tty" as
far as PAM is concerned...)
+/* From the pam trace and log file, it is found out that the
+ Sun pam modules can drive itself.
char *tty = strdup (":0.0");
status = pam_set_item (pamh, PAM_TTY, tty);
@@ -214,6 +270,7 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
blurb(), tty, status, PAM_STRERROR(pamh, status));
/* Try to authenticate as the current user.
We must turn off our SIGCHLD handler for the duration of the call to
@@ -243,56 +300,102 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
- status = pam_authenticate (pamh, 0);
+ pam_auth_status = pam_authenticate (pamh, pam_flags);
# ifdef HAVE_SIGTIMEDWAIT
sigtimedwait (&set, NULL, &timeout);
/* #### What is the portable thing to do if we don't have it? */
# endif /* HAVE_SIGTIMEDWAIT */
- fprintf (stderr, "%s: pam_authenticate (...) ==> %d (%s)\n",
- blurb(), status, PAM_STRERROR(pamh, status));
- if (status == PAM_SUCCESS) /* Win! */
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* Send status message to unlock dialog */
+ if (pam_auth_status == PAM_SUCCESS)
- /* On most systems, it doesn't matter whether the account modules
- are run, or whether they fail or succeed.
+ write_to_child (si, "ul_ok", PAM_STRERROR (pamh, pam_auth_status));
+ else if (si->unlock_state != ul_cancel && si->unlock_state != ul_time)
+ write_to_child (si, "ul_fail", PAM_STRERROR (pamh, pam_auth_status));
- On some systems, the account modules fail, because they were
- never configured properly, but it's necessary to run them anyway
- because certain PAM modules depend on side effects of the account
- modules having been run.
+ fprintf (stderr, "after calling pam_authenticate state is: %s\n",
+ si->unlock_state == ul_success ? "ul_success" : "ul_fail");
- And on still other systems, the account modules are actually
- used, and failures in them should be considered to be true!
+ fprintf (stderr, "%s: pam_authenticate (...) ==> %d (%s)\n",
+ blurb(), pam_auth_status, PAM_STRERROR(pamh, pam_auth_status));
- - We run the account modules on all systems.
- - Whether we ignore them is a configure option.
+ if (pam_auth_status == PAM_SUCCESS) /* Win! */
+ /* perform PAM account validation procedures for login user only */
+ acct_rc = pam_acct_mgmt(pamh, pam_flags);
- It's all kind of a mess.
- status2 = pam_acct_mgmt (pamh, 0);
+ /******************************************************************
+ ignore other cases for the time being
+ PAM_USER_UNKNOWN, PAM_AUTH_ERR, PAM_ACCT_EXPIRED
+ (password mgn service module)
+ same as pam_setcred(), focus on auth. service module only
+ *****************************************************************/
fprintf (stderr, "%s: pam_acct_mgmt (...) ==> %d (%s)\n",
- blurb(), status2, PAM_STRERROR(pamh, status2));
+ blurb(), acct_rc, PAM_STRERROR(pamh, acct_rc));
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* Send status message to unlock dialog ***/
+ if (acct_rc == PAM_SUCCESS)
+ write_to_child (si, "ul_acct_ok", PAM_STRERROR(pamh, acct_rc));
+ write_to_child (si, "ul_acct_fail", PAM_STRERROR(pamh, acct_rc));
/* HPUX for some reason likes to make PAM defines different from
#ifdef PAM_AUTHTOKEN_REQD
- if (status2 == PAM_AUTHTOKEN_REQD)
+ if (acct_rc == PAM_AUTHTOKEN_REQD)
- if (status2 == PAM_NEW_AUTHTOK_REQD)
+ if (acct_rc == PAM_NEW_AUTHTOK_REQD)
- status2 = pam_chauthtok (pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
+ for (i = 0; i < 3; i++)
+ chauth_rc = pam_chauthtok (pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
+ if (chauth_rc == PAM_AUTHTOK_ERR ||
+ chauth_rc == PAM_TRY_AGAIN )
+ si->unlock_state = ul_read;
+ else break; /* get out of the loop */
fprintf (stderr, "%s: pam_chauthtok (...) ==> %d (%s)\n",
- blurb(), status2, PAM_STRERROR(pamh, status2));
+ blurb(), chauth_rc, PAM_STRERROR(pamh, chauth_rc));
+ if (chauth_rc != PAM_SUCCESS)
+ pam_auth_status = chauth_rc;
+ else if (acct_rc != PAM_SUCCESS)
+ pam_auth_status = acct_rc;
+ write_to_child (si, "pw_acct_fail", PAM_STRERROR(pamh, acct_rc));
/* If 'configure' requested that we believe the results of PAM
@@ -306,30 +409,68 @@ pam_try_unlock(saver_info *si, Bool verbose_p,
/* Each time we successfully authenticate, refresh credentials,
failure and blunder along; it shouldn't matter.
Note: this used to be PAM_REFRESH_CRED instead of
PAM_REINITIALIZE_CRED, but Jason Heiss <jheiss@ee.washington.edu>
says that the Linux PAM library ignores that one, and only refreshes
credentials when using PAM_REINITIALIZE_CRED.
- status2 = pam_setcred (pamh, PAM_REINITIALIZE_CRED);
+ setcred_rc = pam_setcred (pamh, PAM_REINITIALIZE_CRED);
+ setcred_rc = pam_setcred (pamh, PAM_REFRESH_CRED);
fprintf (stderr, "%s: pam_setcred (...) ==> %d (%s)\n",
- blurb(), status2, PAM_STRERROR(pamh, status2));
+ blurb(), setcred_rc, PAM_STRERROR(pamh, setcred_rc));
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* Send status message to unlock dialog ***/
+ if (setcred_rc == PAM_SUCCESS)
+ write_to_child (si, "ul_setcred_ok", PAM_STRERROR(pamh, setcred_rc));
+ write_to_child (si, "ul_setcred_fail", PAM_STRERROR(pamh, setcred_rc));
- int status2 = pam_end (pamh, status);
+ int status2 = pam_end (pamh, pam_auth_status);
fprintf (stderr, "%s: pam_end (...) ==> %d (%s)\n",
(status2 == PAM_SUCCESS ? "Success" : "Failure"));
- if (status == PAM_SUCCESS)
+ if (seteuid (euid) != 0)
+ perror("Error pam could not revert euid to user running as euid root,"
+ " locking may not work now\n");
+ "<--end of pam_authenticate() returning ok_to_unblank = %d\n",
+ (int) ((pam_auth_status == PAM_SUCCESS) ? True : False));
+ if (si->pw_data->passwd_string)
+ memset(si->pw_data->passwd_string, 0,
+ strlen(si->pw_data->passwd_string));
+ free (si->pw_data->passwd_string);
+ si->pw_data->passwd_string = NULL;
+ if (pam_auth_status == PAM_SUCCESS)
si->unlock_state = ul_success; /* yay */
else if (si->unlock_state == ul_cancel ||
si->unlock_state == ul_time)
@@ -355,6 +496,13 @@ pam_priv_init (int argc, char **argv, Bool verbose_p)
+ if (! verbose_p) /* SUN addition: only print warnings in verbose mode */
+ { /* since they are rarely useful and mostly just */
+ return True; /* cause confusion when users see them. */
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
@@ -381,6 +529,8 @@ pam_priv_init (int argc, char **argv, Bool verbose_p)
+#ifndef __sun /* disable the misleading message */
@@ -388,9 +538,11 @@ pam_priv_init (int argc, char **argv, Bool verbose_p)
"%s: password authentication via PAM is unlikely to work.\n",
blurb(), file2, PAM_SERVICE_NAME, blurb());
/* else warn about file2 existing but being unreadable? */
+#ifndef __sun /* disable the misleading message */
@@ -398,15 +550,19 @@ pam_priv_init (int argc, char **argv, Bool verbose_p)
"%s: password authentication via PAM is unlikely to work.\n",
blurb(), file2, file, blurb());
/* Return true anyway, just in case. */
pam_conversation (int nmsgs,
- const struct pam_message **msg,
+ struct pam_message **msg,
struct pam_response **resp,
index ac5a3f0..0618642 100644
@@ -145,7 +145,10 @@ set_ids_by_number (uid_t uid, gid_t gid, char **message_ret)
gid_errno = errno ? errno : -1;
+/*mali if (setuid (uid) != 0)**we need root privs back at pam_authenticate
+ this is causing to loose root priv for good, not good **/
+ if (seteuid (uid) != 0)
uid_errno = errno ? errno : -1;
if (uid_errno == 0 && gid_errno == 0 && sgs_errno == 0)
@@ -243,7 +243,11 @@ show_job_list (void)
static void clean_job_list (void);
+#ifdef HAVE_XSCREENSAVER_LOCK
static struct screenhack_job *
make_job (pid_t pid, int screen, const char *cmd)
struct screenhack_job *job = (struct screenhack_job *) malloc (sizeof(*job));
@@ -413,7 +417,11 @@ unblock_sigchld (void)
+#ifdef HAVE_XSCREENSAVER_LOCK
kill_job (saver_info *si, pid_t pid, int signal)
saver_preferences *p = &si->prefs;
@@ -598,9 +606,14 @@ describe_dead_child (saver_info *si, pid_t kid, int wait_status)
mention them) if we've just killed the subprocess. But mention them
if they happen on their own.
- (p->verbose_p || job->status != job_killed)))
+#ifdef HAVE_XSCREENSAVER_LOCK
+ && kid != si->passwd_pid
+#endif /* HAVE_XSCREENSAVER_LOCK */
+ (p->verbose_p || (job && job->status != job_killed))))
/* Don't call fprintf() from signal handlers, as it might malloc.
@@ -640,8 +653,12 @@ describe_dead_child (saver_info *si, pid_t kid, int wait_status)
else if (WIFSIGNALED (wait_status))
- job->status != job_killed ||
+#ifdef HAVE_XSCREENSAVER_LOCK
+ && kid != si->passwd_pid
+#endif /* HAVE_XSCREENSAVER_LOCK */
+ (job && job->status != job_killed) ||
WTERMSIG (wait_status) != SIGTERM)
/* Don't call fprintf() from signal handlers, as it might malloc.
@@ -709,12 +726,20 @@ describe_dead_child (saver_info *si, pid_t kid, int wait_status)
/* Clear out the pid so that screenhack_running_p() knows it's dead.
if (!job || job->status == job_dead)
for (i = 0; i < si->nscreens; i++)
saver_screen_info *ssi = &si->screens[i];
+#ifdef HAVE_XSCREENSAVER_LOCK
+ if (kid == si->passwd_pid)
index 81c8adb..9afc752 100644
#define ABS(x)((x)<0?-(x):(x))
@@ -60,6 +62,11 @@ static Bool proc_interrupts_activity_p (saver_info *si);
#endif /* HAVE_PROC_INTERRUPTS */
static void check_for_clock_skew (saver_info *si);
+#ifdef HAVE_XSCREENSAVER_LOCK
+static void watchdog_timer (XtPointer closure, XtIntervalId *id);
+extern Bool g_passwd_dialog_created;
+extern Bool ok_to_unblank;
@@ -257,7 +264,11 @@ cycle_timer (XtPointer closure, XtIntervalId *id)
crash. So, restart the thing once an hour. */
how_long = 1000 * 60 * 60;
+#ifdef HAVE_XSCREENSAVER_LOCK
+ if (si->external_passwd)
fprintf (stderr, "%s: dialog box up; delaying hack change.\n",
@@ -310,7 +321,28 @@ activate_lock_timer (XtPointer closure, XtIntervalId *id)
fprintf (stderr, "%s: timed out; activating lock.\n", blurb());
- set_locked_p (si, True);
+ "-->activate_lock_timer returning because screen already locked\n");
+ /* Make sure screen is blanked before posting dialog box */
+ if (si->screen_blanked_p)
+ set_locked_p (si, True);
+ ok_to_unblank = unlock_p (si);
+ if (ok_to_unblank == True)
+ set_locked_p(si,False);
+ else /* blanking of screen failed reset lock flag */
+ set_locked_p (si, False);
@@ -616,14 +648,30 @@ dispatch_event (saver_info *si, XEvent *event)
+#ifdef HAVE_XSCREENSAVER_LOCK
+void /* called from
lock.c */
swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
+#ifdef HAVE_XSCREENSAVER_LOCK
+ if (!si->typeahead_events)
+ /* Allocate enough space for 10 keys to be queued - if we get more
+ than that before the dialog is ready, it's most likely the user
+ left something sitting on the keyboard, and won't want them. */
+ si->typeahead_events = calloc(10, sizeof(XKeyEvent));
+ if (si->typeahead_events == NULL)
memset (buf, 0, sizeof(buf));
@@ -636,10 +684,12 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
+#ifndef HAVE_XSCREENSAVER_LOCK /* Let these be queued with the rest */
case '\010': case '\177': /* Backspace */
case '\025': case '\030': /* Erase line */
case '\012': case '\015': /* Enter */
@@ -649,7 +699,17 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
break; /* ignore space at beginning of line */
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* Queue events to replay once dialog is ready */
+ if (si->num_typeahead_events < 10)
+ memcpy (&si->typeahead_events[si->num_typeahead_events++],
+ &event, sizeof(XKeyEvent));
+ i = 1; /* so that spaces are accepted after the beginning */
@@ -657,6 +717,7 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
} while (i < sizeof(buf)-1 &&
XCheckMaskEvent (si->dpy, KeyPressMask, &event));
+#ifndef HAVE_XSCREENSAVER_LOCK
if (si->unlock_typeahead)
@@ -671,6 +732,7 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
si->unlock_typeahead = 0;
memset (buf, 0, sizeof(buf));
+#endif /* HAVE_XSCREENSAVER_LOCK */
@@ -854,6 +916,7 @@ sleep_until_idle (saver_info *si, Bool until_idle_p)
+ si->emergency_lock_p = True;
@@ -868,6 +931,47 @@ sleep_until_idle (saver_info *si, Bool until_idle_p)
+ "************************************\n"
+ "-->sleep_until_idle() event:VisibilityNotify\n"
+ "\t Window of VisibilityNotify:%x\n"
+ "\t until_idle_p=%d g_passwd_dialog_created=%d\n",
+ until_idle_p, g_passwd_dialog_created);
+ /* Don't raise root window when passwd dialog wants to come up */
+ if (g_passwd_dialog_created == 0 && !until_idle_p)
+ for (k = 0; k < si->nscreens; k++)
+ saver_screen_info *ssi = &si->screens[k];
+ XClearWindow (si->dpy, ssi->screensaver_window);
+ XMapRaised (si->dpy, ssi->screensaver_window);
+ "A window is trying to popup.\n"
+ "Raising saver root Window.\n"
+ "************************************\n");
/* Ignore release events so that hitting ESC at the password dialog
@@ -1565,7 +1669,11 @@ watchdog_timer (XtPointer closure, XtIntervalId *id)
Bool running_p = screenhack_running_p (si);
+#ifdef HAVE_XSCREENSAVER_LOCK
+ if (si->external_passwd)
fprintf (stderr, "%s: dialog box is up: not raising screen.\n",
@@ -275,12 +275,30 @@ struct saver_info {
int unlock_failures; /* Counts failed login attempts while the
time_t unlock_failure_time; /* Time of first failed login attempt. */
+#ifdef HAVE_XSCREENSAVER_LOCK
+ Window *raise_wins; /* List of windows to raise above the */
+ int num_raise_wins; /* virtual
root/hack display, such as */
+ int max_raise_wins; /* accessibility helpers */
+ Window *override_wins; /* Windows we had to unset the */
+ int num_override_wins; /* override_redirect attribute on and */
+ int max_override_wins; /* need to restore it on after unlock. */
+ pid_t passwd_pid; /* The pid of the password dialog child if we
+ are running an external process for it. */
+ XKeyEvent *typeahead_events; /* Like unlock_typeahead, but as raw events */
+ int num_typeahead_events;
char *unlock_typeahead; /* If the screen is locked, and the user types
a character, we assume that it is the first
character of the password. It's stored here
for the password dialog to use to populate
+#endif /* HAVE_XSCREENSAVER_LOCK */
char *user; /* The user whose session is locked. */
char *cached_passwd; /* Cached password, used to avoid multiple
index 6acaddb..51e4c6a 100644
@@ -1082,8 +1082,12 @@ safe_XConfigureWindow (Display *dpy, Window window,
return (!error_handler_hit_p);
+#ifdef HAVE_XSCREENSAVER_LOCK
/* This might not be necessary, but just in case. */
safe_XDestroyWindow (Display *dpy, Window window)
XErrorHandler old_handler;
@@ -1097,6 +1101,14 @@ safe_XDestroyWindow (Display *dpy, Window window)
XSetErrorHandler (old_handler);
+ /* clear any queued VisibilityNotify events so we don't cause XErrors
+ later when we try to process them and find the windowid is invalid */
+ while (XCheckWindowEvent(dpy, window, VisibilityChangeMask, &event))
return (!error_handler_hit_p);
@@ -1211,6 +1223,7 @@ initialize_screensaver_window_1 (saver_screen_info *ssi)
ButtonPressMask | ButtonReleaseMask |
@@ -1482,6 +1495,9 @@ raise_window (saver_info *si,
saver_preferences *p = &si->prefs;
+ fprintf(stderr,"-->raise_window()\n");
@@ -1696,6 +1712,9 @@ unblank_screen (saver_info *si)
Bool unfade_p = (si->fading_possible_p && p->unfade_p);
+ fprintf(stderr,"-->unblank_screen()\n");
monitor_power_on (si, True);
reset_watchdog_timer (si, False);
@@ -1984,7 +2003,7 @@ select_visual (saver_screen_info *ssi, const char *visual_name)
maybe_transfer_grabs (ssi, old_w, ssi->screensaver_window, ssi->number);
/* Now we can destroy the old window without horking our grabs. */
- XDestroyWindow (si->dpy, old_w);
+ safe_XDestroyWindow (si->dpy, old_w);
fprintf (stderr, "%s: %d: destroyed old saver window 0x%lx.\n",
index 06f5c13..33d357a 100644
#include <
netdb.h> /* for gethostbyname() */
saver_info *global_si_kludge = 0; /* I hate C so much... */
+Bool ok_to_unblank = False;
+#ifdef HAVE_XSCREENSAVER_LOCK
+/* Global storage for gtk passwd lock dialog
+ * we assign this to si->pw_data and this is needed
+passwd_dialog_data mygtkpwd;
+passwd_dialog_data *ptr_mygtkpwd = &mygtkpwd;
+#ifdef HAVE_XSCREENSAVER_LOCK
static XrmOptionDescRec options [] = {
@@ -670,6 +690,9 @@ connect_to_server (saver_info *si, int *argc, char **argv)
{ &XA_ESETROOT_PMAP_ID, "ESETROOT_PMAP_ID" },
{ &XA_XROOTPMAP_ID, "_XROOTPMAP_ID" },
{ &XA_NET_WM_USER_TIME, "_NET_WM_USER_TIME" },
+#ifdef HAVE_XSCREENSAVER_LOCK
+ { &XA_UNLOCK_RATIO, "UNLOCK_RATIO" },
{ NULL, NULL } /* Must be last to terminate list */
const struct atom_request *atom_lists[3] = { NULL, NULL, NULL };
@@ -1164,8 +1187,36 @@ static void
main_loop (saver_info *si)
saver_preferences *p = &si->prefs;
+ /* Bool ok_to_unblank; made this a global flag, gets set in
timers.c */
+ const char *modulesptr = NULL;
+** CR4784055(P1)locked-screen dialog is inaccessible to Gnopernicus
+** voice for each type-in char in the password field of
+ ** g_type_init should be done before calling gconf_client routines
+ ** so that xscreensaver does not dump core if gconf daemon is not running.
+ ** 6395649 at-spi-registryd starts when screen is locked even
+ ** when accessible device support is off(SR)
+ ** per AT core gp suggestion
+ ** GTK_MODULES is set only if at support is enabled
+ if (gconf_client_get_bool(gconf_client_get_default(),
+ modulesptr = getenv ("GTK_MODULES");
+ if (!modulesptr || modulesptr [0] == '\0')
+ putenv ("GTK_MODULES=gail:atk-bridge");
@@ -1196,6 +1247,17 @@ main_loop (saver_info *si)
fprintf (stderr, "%s: idle with blanking disabled at %s.\n",
+ /* 6221109 Changing mode from disable to anything else,
+ This is Disable Screen Saver mode, in this mode we dont lock
+ screen, but si->locked_p is already set to True, since someone
+ tried to lock screen, reset it to False, else when we change
+ mode from disable and try to lock screen, xscreensaver thinks
+ screen is already locked and doesnt lock screen anymore.
+ set_locked_p (si, False);
/* Go around the loop and wait for the next bout of idleness,
or for the init file to change, or for a remote command to
@@ -1267,6 +1329,7 @@ main_loop (saver_info *si)
set_locked_p (si, False);
schedule_wakeup_event (si, retry, p->debug_p);
+ set_locked_p(si, False);
@@ -1329,7 +1392,17 @@ main_loop (saver_info *si)
p->lock_p && /* and locking is enabled */
!si->locking_disabled_p && /* and locking is possible */
lock_timeout == 0) /* and locking is not timer-deferred */
- set_locked_p (si, True); /* then lock right now. */
+ fprintf(stderr, "going to lock screen B\n");
+ set_locked_p (si, True); /* then lock right now. */
+ ok_to_unblank = unlock_p(si);
+ if (ok_to_unblank == True)
+ set_locked_p (si, False);
/* locked_p might be true already because of the above, or because of
the LOCK ClientMessage. But if not, and if we're supposed to lock
@@ -1344,10 +1417,7 @@ main_loop (saver_info *si)
check_for_leaks ("blanked A");
sleep_until_idle (si, False); /* until not idle */
check_for_leaks ("blanked B");
@@ -1357,6 +1427,13 @@ main_loop (saver_info *si)
/* Maybe unlock the screen.
+ if (si->demoing_p) goto DONE; /* in demoing mode and user wants out
+ /* This is when blank timeout has happened but lock timeout hasnt
+ and user gets active. Simply get him out of the blank screen. */
+ if (si->screen_blanked_p && !si->locked_p) goto DONE;
saver_screen_info *ssi = si->default_screen;
@@ -1368,7 +1445,20 @@ main_loop (saver_info *si)
suspend_screenhack (&si->screens[i], True); /* suspend */
XUndefineCursor (si->dpy, ssi->screensaver_window);
+#ifdef HAVE_XSCREENSAVER_LOCK
+ /* Prevents lock dialog posting on non blanked screen */
+ if (!si->screen_blanked_p) /* locked_p is true, so blank now */
+ if (si->screen_blanked_p) /* if blanking successful, call PAM */
+ set_locked_p (si, True);
+ ok_to_unblank = unlock_p(si);
+ set_locked_p (si, False);
ok_to_unblank = unlock_p (si);
XDefineCursor (si->dpy, ssi->screensaver_window, ssi->cursor);
@@ -1393,6 +1483,7 @@ main_loop (saver_info *si)
} while (!ok_to_unblank);
fprintf (stderr, "%s: unblanking screen at %s.\n",
@@ -1477,7 +1568,19 @@ main (int argc, char **argv)
textdomain (GETTEXT_PACKAGE);
+#if defined(ENABLE_NLS) && defined(HAVE_XSCREENSAVER_LOCK)
+ /* Gtk unlock dialog needs to be sent UTF-8 text to display */
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
memset(si, 0, sizeof(*si));
+#ifdef HAVE_XSCREENSAVER_LOCK
+/* Initialize and point si to pw_data
i.e. the lock dialog struct */
+ memset(ptr_mygtkpwd, 0, sizeof(*ptr_mygtkpwd));
+ si->pw_data = ptr_mygtkpwd;
global_si_kludge = si; /* I hate C so much... */
@@ -1487,7 +1590,9 @@ main (int argc, char **argv)
set_version_string (si, &argc, argv);
+#ifndef HAVE_XSCREENSAVER_LOCK /* moved below for external lock */
privileged_initialization (si, &argc, argv);
spasswd = getpwuid(getuid());
@@ -1510,6 +1615,10 @@ main (int argc, char **argv)
load_init_file(si->dpy, p); /* must be before initialize_per_screen_info() */
+#ifdef HAVE_XSCREENSAVER_LOCK
+ privileged_initialization (si, &argc, argv);
blurb_timestamp_p = p->timestamp_p; /* kludge */
initialize_per_screen_info (si, shell); /* also sets si->fading_possible_p */
@@ -1762,8 +1871,12 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
+ fprintf(stderr, "handle_clientmessage\n");
/* Preferences might affect our handling of client messages. */
maybe_reload_init_file (si);
+ XSync (si->dpy, False);
@@ -2055,10 +2168,14 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
sprintf (buf, "LOCK ClientMessage received; %s", response);
clientmessage_response (si, window, False, buf, response);
+ fprintf(stderr, "going to lock screen A\n");
/* Note that this leaves things in a slightly inconsistent state:
we are blanked but not locked. And blanking might actually
fail if we can't get the grab. */
+ si->emergency_lock_p = True;
/* Have to set the time or xscreensaver-command doesn't
report the LOCK state change. */
@@ -2067,6 +2184,9 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
+ return True; /* dont set lock_id to 0,
+ causes to go in lock in main_loop above */
if (si->lock_id) /* we're doing it now, so lose the timeout */
XtRemoveTimeOut (si->lock_id);
@@ -164,6 +164,12 @@ extern Bool select_visual (saver_screen_info *ssi, const char *visual_name);
extern void store_saver_status (saver_info *si);
extern const char *signal_name (int signal);
+#ifdef HAVE_XSCREENSAVER_LOCK
+extern int kill_job (saver_info *si, pid_t pid, int signal);
+extern struct screenhack_job *make_job (pid_t pid, int screen,
/* =======================================================================
======================================================================= */