summaryrefslogtreecommitdiffstats
path: root/login-utils/login.c
diff options
context:
space:
mode:
authorKarel Zak2017-12-04 12:31:29 +0100
committerKarel Zak2017-12-04 12:31:29 +0100
commite6b32e7d1adf2a0c09743d71dfdbe2742c5884ac (patch)
treee631579086849fb00cfbafb24c57b358610c3a3f /login-utils/login.c
parentfallocate: remove typo (diff)
downloadkernel-qcow2-util-linux-e6b32e7d1adf2a0c09743d71dfdbe2742c5884ac.tar.gz
kernel-qcow2-util-linux-e6b32e7d1adf2a0c09743d71dfdbe2742c5884ac.tar.xz
kernel-qcow2-util-linux-e6b32e7d1adf2a0c09743d71dfdbe2742c5884ac.zip
login: add LOGIN_PLAIN_PROMPT to login.defs
We have command line option -H to disable hostname in login prompt. Unfortunately, in same cases (e.g. telnetd) it's impossible to specify login(1) command line options due to hardcoded execl()... This patch introduces LOGIN_PLAIN_PROMPT boolean for /etc/login.defs to suppress hostname in the prompt. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/login.c')
-rw-r--r--login-utils/login.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/login-utils/login.c b/login-utils/login.c
index cc1400246..09ee8f8ea 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -677,7 +677,8 @@ static void loginpam_err(pam_handle_t *pamh, int retcode)
}
/*
- * Composes "<host> login: " string; or returns "login: " if -H is given.
+ * Composes "<host> login: " string; or returns "login: " if -H is given or
+ * LOGIN_PLAIN_PROMPT=yes configured.
*/
static const char *loginpam_get_prompt(struct login_context *cxt)
{
@@ -685,11 +686,16 @@ static const char *loginpam_get_prompt(struct login_context *cxt)
char *prompt, *dflt_prompt = _("login: ");
size_t sz;
- if (cxt->nohost || !(host = get_thishost(cxt, NULL)))
+ if (cxt->nohost)
+ return dflt_prompt; /* -H on command line */
+
+ if (getlogindefs_bool("LOGIN_PLAIN_PROMPT", 0) == 1)
return dflt_prompt;
- sz = strlen(host) + 1 + strlen(dflt_prompt) + 1;
+ if (!(host = get_thishost(cxt, NULL)))
+ return dflt_prompt;
+ sz = strlen(host) + 1 + strlen(dflt_prompt) + 1;
prompt = xmalloc(sz);
snprintf(prompt, sz, "%s %s", host, dflt_prompt);