diff options
author | George Lebl <jirka@5z.com> | 2003-06-06 18:24:58 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2003-06-06 18:24:58 +0000 |
commit | fcdbd53b0c8c0714742eb18e04f09d32b3ff4152 (patch) | |
tree | 9a60c3a376fa4b7ebcfa8d866131b5dce2852ffa /daemon | |
parent | ccdef3015c675592ee06ffe6636ad2ffd1b01ae7 (diff) | |
download | gdm-fcdbd53b0c8c0714742eb18e04f09d32b3ff4152.tar.gz |
add a query for the capslock state in the greeter
Fri Jun 06 11:21:44 2003 George Lebl <jirka@5z.com>
* daemon/gdm.h, gui/gdmlogin.c, gui/greeter/greeter.c,
gui/greeter/greeter_item_capslock.[ch]: add a query for the capslock
state in the greeter
* daemon/verify-*.c: fix #71496 by checking the capslock state
before telling the user that he should make sure it's off. Also
only say "invalid username or password" if we actually did ask for
a password, else the message would be silly indeed (note that
the check if we did ask for password is a silly hack, but the
verify-pam.c code is a large set of silly hacks and as such it's
ok to add yet another one)
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gdm.h | 1 | ||||
-rw-r--r-- | daemon/verify-crypt.c | 58 | ||||
-rw-r--r-- | daemon/verify-pam.c | 52 | ||||
-rw-r--r-- | daemon/verify-shadow.c | 60 |
4 files changed, 118 insertions, 53 deletions
diff --git a/daemon/gdm.h b/daemon/gdm.h index 8e5fbf54..328c4a44 100644 --- a/daemon/gdm.h +++ b/daemon/gdm.h @@ -107,6 +107,7 @@ enum { #define GDM_NOFOCUS 'f' /* Don't focus the login window (optional) */ #define GDM_FOCUS 'F' /* Allow focus on the login window again (optional) */ #define GDM_SAVEDIE '!' /* Save wm order and die (and set busy cursor) */ +#define GDM_QUERY_CAPSLOCK 'Q' /* Is capslock on? */ /* Different login interruptions */ #define GDM_INTERRUPT_TIMED_LOGIN 'T' diff --git a/daemon/verify-crypt.c b/daemon/verify-crypt.c index 0ac9fae6..41bdc516 100644 --- a/daemon/verify-crypt.c +++ b/daemon/verify-crypt.c @@ -42,6 +42,35 @@ extern gboolean GdmAllowRoot; extern gboolean GdmAllowRemoteRoot; extern gint GdmRetryDelay; +static void +print_cant_auth_errbox (void) +{ + gboolean is_capslock = FALSE; + const char *basemsg; + char *msg; + char *ret; + + ret = gdm_slave_greeter_ctl (GDM_QUERY_CAPSLOCK, ""); + if ( ! ve_string_empty (ret)) + is_capslock = TRUE; + g_free (ret); + + basemsg = _("\nIncorrect username or password. " + "Letters must be typed in the correct " + "case."); + if (is_capslock) { + msg = g_strconcat (basemsg, " ", + _("Please make sure the " + "Caps Lock key is not " + "enabled."), + NULL); + } else { + msg = g_strdup (basemsg); + } + gdm_slave_greeter_ctl_no_ret (GDM_ERRBOX, msg); + g_free (msg); +} + /** * gdm_verify_user: * @username: Name of user or NULL if we should ask @@ -111,17 +140,10 @@ gdm_verify_user (GdmDisplay *d, if (pwent == NULL) { sleep (GdmRetryDelay); - gdm_error (_("Couldn't authenticate user")); - /* FIXME: Hmm, how are we sure that the login is username - * and password. That is the most common case but not - * necessarily true, this message needs to be changed - * to allow for such cases */ - auth_errmsg = g_strdup_printf - (_("\nIncorrect username or password. " - "Letters must be typed in the correct case. " - "Please be sure the Caps Lock key is not enabled")); - gdm_slave_greeter_ctl_no_ret (GDM_ERRBOX, auth_errmsg); - g_free (auth_errmsg); + gdm_error (_("Couldn't authenticate user \"%s\""), login); + + print_cant_auth_errbox (); + g_free (login); g_free (passwd); g_free (ppasswd); @@ -132,16 +154,10 @@ gdm_verify_user (GdmDisplay *d, if (ppasswd == NULL || (ppasswd[0] != '\0' && strcmp (crypt (passwd, ppasswd), ppasswd) != 0)) { sleep (GdmRetryDelay); - /* FIXME: Hmm, how are we sure that the login is username - * and password. That is the most common case but not - * necessarily true, this message needs to be changed - * to allow for such cases */ - auth_errmsg = g_strdup_printf - (_("\nIncorrect username or password. " - "Letters must be typed in the correct case. " - "Please be sure the Caps Lock key is not enabled")); - gdm_slave_greeter_ctl_no_ret (GDM_ERRBOX, auth_errmsg); - g_free (auth_errmsg); + gdm_error (_("Couldn't authenticate user \"%s\""), login); + + print_cant_auth_errbox (); + g_free (login); g_free (passwd); g_free (ppasswd); diff --git a/daemon/verify-pam.c b/daemon/verify-pam.c index 990f1a60..a240bc93 100644 --- a/daemon/verify-pam.c +++ b/daemon/verify-pam.c @@ -48,8 +48,12 @@ static pam_handle_t *pamh = NULL; static GdmDisplay *cur_gdm_disp = NULL; +/* this is a hack */ static char *tmp_PAM_USER = NULL; +/* this is another hack */ +static gboolean did_we_ask_for_password = FALSE; + static char *selected_user = NULL; void @@ -189,6 +193,8 @@ gdm_verify_pam_conv (int num_msg, const struct pam_message **msg, break; case PAM_PROMPT_ECHO_OFF: + if (strcmp (m, _("Password:")) == 0) + did_we_ask_for_password = TRUE; /* PAM requested textual input with echo off */ s = gdm_slave_greeter_ctl (GDM_NOECHO, m); if (gdm_slave_greeter_check_interruption ()) { @@ -423,7 +429,6 @@ gdm_verify_user (GdmDisplay *d, gboolean error_msg_given = FALSE; gboolean credentials_set = FALSE; gboolean started_timer = FALSE; - char *auth_errmsg; /* start the timer for timed logins */ if ( ! ve_string_empty (GdmTimedLogin) && @@ -457,6 +462,8 @@ authenticate_again: g_free (tmp_PAM_USER); tmp_PAM_USER = NULL; + did_we_ask_for_password = FALSE; + gdm_verify_select_user (NULL); /* Start authentication session */ if ((pamerr = pam_authenticate (pamh, 0)) != PAM_SUCCESS) { @@ -597,15 +604,39 @@ authenticate_again: /* I'm not sure yet if I should display this message for any other issues - heeten */ if (pamerr == PAM_AUTH_ERR || pamerr == PAM_USER_UNKNOWN) { - /* FIXME: Hmm, how are we sure that the login is username - * and password. That is the most common case but not - * necessarily true, this message needs to be changed - * to allow for such cases */ - auth_errmsg = - _("\nIncorrect username or password. " - "Letters must be typed in the correct case. " - "Please make sure the Caps Lock key is not enabled."); - gdm_slave_greeter_ctl_no_ret (GDM_ERRBOX, auth_errmsg); + gboolean is_capslock = FALSE; + const char *basemsg; + char *msg; + char *ret; + + ret = gdm_slave_greeter_ctl (GDM_QUERY_CAPSLOCK, ""); + if ( ! ve_string_empty (ret)) + is_capslock = TRUE; + g_free (ret); + + /* Only give this message if we actually asked for + password, otherwise it would be silly to say that + the password may have been wrong */ + if (did_we_ask_for_password) { + basemsg = _("\nIncorrect username or password. " + "Letters must be typed in the correct " + "case."); + } else { + basemsg = _("\nAuthentication failed. " + "Letters must be typed in the correct " + "case."); + } + if (is_capslock) { + msg = g_strconcat (basemsg, " ", + _("Please make sure the " + "Caps Lock key is not " + "enabled."), + NULL); + } else { + msg = g_strdup (basemsg); + } + gdm_slave_greeter_ctl_no_ret (GDM_ERRBOX, msg); + g_free (msg); } else { gdm_slave_greeter_ctl_no_ret (GDM_ERRDLG, _("Authentication failed")); } @@ -666,6 +697,7 @@ gdm_verify_setup_user (GdmDisplay *d, const gchar *login, const gchar *display, } /* Start authentication session */ + did_we_ask_for_password = FALSE; if ((pamerr = pam_authenticate (pamh, 0)) != PAM_SUCCESS) { if (gdm_slave_should_complain ()) { gdm_error (_("Couldn't authenticate user")); diff --git a/daemon/verify-shadow.c b/daemon/verify-shadow.c index 9b1ce5d1..344a3e2c 100644 --- a/daemon/verify-shadow.c +++ b/daemon/verify-shadow.c @@ -43,6 +43,35 @@ extern gboolean GdmAllowRoot; extern gboolean GdmAllowRemoteRoot; extern gint GdmRetryDelay; +static void +print_cant_auth_errbox (void) +{ + gboolean is_capslock = FALSE; + const char *basemsg; + char *msg; + char *ret; + + ret = gdm_slave_greeter_ctl (GDM_QUERY_CAPSLOCK, ""); + if ( ! ve_string_empty (ret)) + is_capslock = TRUE; + g_free (ret); + + basemsg = _("\nIncorrect username or password. " + "Letters must be typed in the correct " + "case."); + if (is_capslock) { + msg = g_strconcat (basemsg, " ", + _("Please make sure the " + "Caps Lock key is not " + "enabled."), + NULL); + } else { + msg = g_strdup (basemsg); + } + gdm_slave_greeter_ctl_no_ret (GDM_ERRBOX, msg); + g_free (msg); +} + /** * gdm_verify_user: * @username: Name of user or NULL if we should ask @@ -58,7 +87,7 @@ extern gint GdmRetryDelay; gchar * gdm_verify_user (GdmDisplay *d, const char *username, const gchar *display, gboolean local) { - gchar *login, *passwd, *ppasswd, *auth_errmsg; + gchar *login, *passwd, *ppasswd; struct passwd *pwent; struct spwd *sp; @@ -129,17 +158,10 @@ gdm_verify_user (GdmDisplay *d, const char *username, const gchar *display, gboo if (pwent == NULL) { sleep (GdmRetryDelay); - gdm_error (_("Couldn't authenticate user")); - /* FIXME: Hmm, how are we sure that the login is username - * and password. That is the most common case but not - * necessarily true, this message needs to be changed - * to allow for such cases */ - auth_errmsg = g_strdup_printf - (_("\nIncorrect username or password. " - "Letters must be typed in the correct case. " - "Please make sure the Caps Lock key is not enabled.")); - gdm_slave_greeter_ctl_no_ret (GDM_ERRBOX, auth_errmsg); - g_free (auth_errmsg); + gdm_error (_("Couldn't authenticate user \"%s\""), login); + + print_cant_auth_errbox (); + g_free (login); g_free (passwd); g_free (ppasswd); @@ -150,16 +172,10 @@ gdm_verify_user (GdmDisplay *d, const char *username, const gchar *display, gboo if (ppasswd == NULL || (ppasswd[0] != '\0' && strcmp (crypt (passwd, ppasswd), ppasswd) != 0)) { sleep (GdmRetryDelay); - /* FIXME: Hmm, how are we sure that the login is username - * and password. That is the most common case but not - * necessarily true, this message needs to be changed - * to allow for such cases */ - auth_errmsg = g_strdup_printf - (_("\nIncorrect username or password. " - "Letters must be typed in the correct case. " - "Please make sure the Caps Lock key is not enabled.")); - gdm_slave_greeter_ctl_no_ret (GDM_ERRBOX, auth_errmsg); - g_free (auth_errmsg); + gdm_error (_("Couldn't authenticate user \"%s\""), login); + + print_cant_auth_errbox (); + g_free (login); g_free (passwd); g_free (ppasswd); |