[PATCH:xdm 2/5] Add echoPasswdChar resource to set character to display

Alan Coopersmith alan.coopersmith at oracle.com
Sat Feb 19 22:36:38 PST 2011


Stop hardcoding it to '*'.   Allows setting a resource with no value to
display " " to advance the cursor without drawing text.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 greeter/Login.c  |   11 ++++++++---
 greeter/Login.h  |    2 ++
 greeter/LoginP.h |    4 +++-
 man/xdm.man      |    6 ++++--
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/greeter/Login.c b/greeter/Login.c
index 2a73a9e..18a3f86 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -217,7 +217,9 @@ static XtResource resources[] = {
     {XtNallowRootLogin, XtCAllowRootLogin, XtRBoolean, sizeof(Boolean),
 	offset(allow_root_login), XtRImmediate, (XtPointer) True},
     {XtNechoPasswd, XtCEchoPasswd, XtRBoolean, sizeof(Boolean),
-	offset(echo_passwd), XtRImmediate, (XtPointer) False}
+	offset(echo_passwd), XtRImmediate, (XtPointer) False},
+    {XtNechoPasswdChar, XtCEchoPasswdChar, XtRString,	sizeof (char *),
+	offset(echo_passwd_char), XtRString, (XtPointer) "*" }
 };
 
 #undef offset
@@ -370,7 +372,7 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC gc)
 
 	while (i < length)
 	{
-	    text[i++] = '*';
+	    text[i++] = w->login.echo_passwd_char[0];
 	}
 
 	text[i] = 0;
@@ -491,7 +493,7 @@ realizeCursor (LoginWidget w, GC gc)
 	    int len = PROMPT_CURSOR(w, w->login.activePrompt) -
 		VALUE_SHOW_START(w, w->login.activePrompt);
 
-	    x += len*TEXT_WIDTH(text, "*", 1);
+	    x += len*TEXT_WIDTH(text, w->login.echo_passwd_char, 1);
 	}
 	else
 	{
@@ -1819,6 +1821,9 @@ SkipXpmLoad:
     VALUE_TEXT_MAX(w, LOGIN_PROMPT_PASSWORD)	= sizeof(w->login.data.passwd);
     VALUE_SHOW_START(w, LOGIN_PROMPT_PASSWORD)	= 0;
 
+    if (w->login.echo_passwd_char[0] == 0)
+	w->login.echo_passwd_char = " ";
+
     SetPrompt(gnew, LOGIN_PROMPT_PASSWORD, NULL, LOGIN_PROMPT_ECHO_OFF, False);
     SetPrompt(gnew, LOGIN_PROMPT_USERNAME, NULL, LOGIN_PROMPT_ECHO_ON, False);
 
diff --git a/greeter/Login.h b/greeter/Login.h
index 22529a5..9b5212c 100644
--- a/greeter/Login.h
+++ b/greeter/Login.h
@@ -101,6 +101,7 @@ from The Open Group.
 # define XtNallowNullPasswd	"allowNullPasswd"
 # define XtNallowRootLogin	"allowRootLogin"
 # define XtNechoPasswd		"echoPasswd"
+# define XtNechoPasswdChar	"echoPasswdChar"
 
 # define XtNface 		"face"
 # define XtCFace		"Face"
@@ -142,6 +143,7 @@ from The Open Group.
 # define XtCAllowNullPasswd	"AllowNullPasswd"
 # define XtCAllowRootLogin	"AllowRootLogin"
 # define XtCEchoPasswd		"EchoPasswd"
+# define XtCEchoPasswdChar	"EchoPasswdChar"
 
 # define XtNchangePasswdMessage	"changePasswdMessage"
 # define XtCChangePasswdMessage	"ChangePasswdMessage"
diff --git a/greeter/LoginP.h b/greeter/LoginP.h
index 3279110..ef2151d 100644
--- a/greeter/LoginP.h
+++ b/greeter/LoginP.h
@@ -130,8 +130,10 @@ typedef struct {
 	Boolean		allow_access;	/* disable access control on login */
 	Boolean		allow_null_passwd; /* allow null password on login */
 	Boolean		allow_root_login; /* allow root login */
-	/* show password as asterisks, i.e. '**...' */
+	/* option to display characters such as asterisks, i.e. '**...'
+	   for no-echo prompts like passwords */
 	Boolean		echo_passwd;
+	char *		echo_passwd_char;
 	XIC		xic;		/* input method of input context */
 	loginPromptData	prompts[NUM_PROMPTS];
     	time_t 		msgTimeout;
diff --git a/man/xdm.man b/man/xdm.man
index 721dade..994370d 100644
--- a/man/xdm.man
+++ b/man/xdm.man
@@ -1062,9 +1062,11 @@ if the account does not require a password at all.
 The default is ``false'', so only users that have passwords assigned can
 log in.
 .IP "\fBxlogin.Login.echoPasswd\fP"
-If set to ``true'', stars will be rendered instead of the password itself,
-i.e. '***...'.
+If set to ``true'', a placeholder character (echoPasswdChar) will be shown
+for fields normally set to not echo, such as password input.
 The default is ``false''.
+.IP "\fBxlogin.Login.echoPasswdChar\fP"
+Character to display if echoPasswd is true.  The default is ``*''.
 .IP "\fBxlogin.Login.translations\fP"
 This specifies the translations used for the login widget.  Refer to the X
 Toolkit documentation for a complete discussion on translations.  The default
-- 
1.7.3.2



More information about the xorg-devel mailing list