diff --git a/src/vlock/auth.c b/src/vlock/auth.c index 25efb5e..cb8f057 100644 --- a/src/vlock/auth.c +++ b/src/vlock/auth.c @@ -37,6 +37,8 @@ #define LONG_DELAY 10 /* Delay after other PAM errors, in seconds. */ #define SHORT_DELAY 1 +/* Max length of hostname. */ +#define HOSTNAME_MAX 256 static int do_account_password_management(pam_handle_t *pamh) @@ -60,6 +62,9 @@ do_account_password_management(pam_handle_t *pamh) int get_password(pam_handle_t *pamh, const char *username, const char *tty) { uid_t uid = getuid(); + char hostname[HOSTNAME_MAX]; + hostname[HOSTNAME_MAX - 1] = '\0'; + gethostname(hostname, HOSTNAME_MAX - 1); for (;;) { int rc; @@ -83,8 +88,8 @@ int get_password(pam_handle_t *pamh, const char *username, const char *tty) printf(_("The entire console display is now completely locked by %s.\n"), username); } else { - printf(_("The %s is now locked by %s.\n"), tty, - username); + printf(_("The %s on %s is now locked by %s.\n"), tty, + hostname, username); if (is_vt) puts(_("Use Alt-function keys to switch to other virtual consoles.")); }