Ottre Tux's lil' helper
Joined: 23 Dec 2012 Posts: 129
|
Posted: Thu Jan 17, 2013 11:01 am Post subject: Customising the pre-login prompt |
|
|
I wasn't happy with the "<hostname> login: " pre-login prompt.
I wanted "Username: " instead so I patched the packages that provide the prompt:
1) sys-apps/shadow. /bin/login belongs to this package and provides the secondary prompt, and an error message, if you enter your password wrong.
Code: |
--- shadow-4.1.4.3/src/login.c
+++ shadow-4.1.4.3/src/login.c
@@ -742,17 +742,17 @@
char hostn[256];
char loginprompt[256]; /* That's one hell of a prompt :) */
- /* Make the login prompt look like we want it */
- if (gethostname (hostn, sizeof (hostn)) == 0) {
- snprintf (loginprompt,
- sizeof (loginprompt),
- _("%s login: "), hostn);
- } else {
- strncpy (loginprompt, _("login: "),
- sizeof (loginprompt));
- }
-
- retcode = pam_set_item (pamh, PAM_USER_PROMPT, loginprompt);
+ /* Make the login prompt look like we want it
+ * if (gethostname (hostn, sizeof (hostn)) == 0) {
+ * snprintf (loginprompt,
+ * sizeof (loginprompt),
+ * _("%s login: "), hostn);
+ * } else {
+ * strncpy (loginprompt, _("login: "),
+ * sizeof (loginprompt));
+ * }
+ */
+ retcode = pam_set_item (pamh, PAM_USER_PROMPT, "Try again. Username: ");
PAM_FAIL_CHECK;
/* if we didn't get a user on the command line,
@@ -829,8 +829,9 @@
close (audit_fd);
#endif /* WITH_AUDIT */
- (void) puts ("");
- (void) puts (_("Login incorrect"));
+ /* (void) puts ("");
+ * (void) puts (_("Login incorrect"));
+ */
if (failcount >= retries) {
SYSLOG ((LOG_NOTICE,
|
2) sys-apps/util-linux. /sbin/agetty belongs to this package and provides the main prompt.
Code: |
--- util-linux-2.21.2/term-utils/agetty.c
+++ util-linux-2.21.2/term-utils/agetty.c
@@ -99,7 +99,7 @@
#endif
/* Login prompt. */
-#define LOGIN "login: "
+#define LOGIN "Username: "
#define LOGIN_ARGV_MAX 16 /* Numbers of args for login */
/* Some shorthands for control characters. */
|
I copied the packages to my local overlay, re-emerged them, and everything works fine.
However, I was wondering if there is an easier way of customising the pre-login prompt, without patching anything?
After googling a bit for answers, these are possible solutions:
1) I use PAM. Is it possible to have the pam_issue module override the /bin/login secondary prompt?
2) Is there an alternative to agetty that lets me set the main prompt in the /etc/inittab file?
Any help would be much appreciated. |
|