Skip to content

Commit

Permalink
agetty: add support for LOGIN_PLAIN_PROMPT
Browse files Browse the repository at this point in the history
login(1) and agetty(8) are usually used together to log-in user. The
initial login prompt is printed by agetty. login(1) can suppress
hostname in the prompt by LOGIN_PLAIN_PROMPT=no (/etc/login.defs), but
for agetty it's necessary to use --nohostname. It's pretty unfriendly
for system admins. Let's share the same setting between all tools.

Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information
karelzak committed Mar 30, 2022
1 parent 420bce8 commit 556925f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion term-utils/Makemodule.am
Expand Up @@ -46,14 +46,18 @@ if BUILD_AGETTY
sbin_PROGRAMS += agetty
MANPAGES += term-utils/agetty.8
dist_noinst_DATA += term-utils/agetty.8.adoc
agetty_SOURCES = term-utils/agetty.c
agetty_SOURCES = term-utils/agetty.c \
lib/logindefs.c
if USE_PLYMOUTH_SUPPORT
agetty_SOURCES += lib/plymouth-ctrl.c
endif
agetty_LDADD = $(LDADD) libcommon.la
if BSD
agetty_LDADD += -lutil
endif
if HAVE_ECONF
agetty_LDADD += -leconf
endif
endif # BUILD_AGETTY


Expand Down
11 changes: 10 additions & 1 deletion term-utils/agetty.8.adoc
Expand Up @@ -157,7 +157,7 @@ Wait for the user or the modem to send a carriage-return or a linefeed character
Do not print hints about Num, Caps and Scroll Locks.

*--nohostname*::
By default the hostname will be printed. With this option enabled, no hostname at all will be shown.
By default the hostname will be printed. With this option enabled, no hostname at all will be shown. This seeting is also possible to able by LOGIN_PLAIN_PROMPT option in the _/etc/login.defs_ configuration file (see below for more details).

*--long-hostname*::
By default the hostname is only printed until the first dot. With this option enabled, the fully qualified hostname by *gethostname*(3P) or (if not found) by *getaddrinfo*(3) is shown.
Expand All @@ -182,6 +182,15 @@ Ask all running *agetty* instances to reload and update their displayed prompts,

include::man-common/help-version.adoc[]

== CONFIG FILE ITEMS
*agetty* reads the _/etc/login.defs_ configuration file (see *login.defs*(5)).
Note that the configuration file could be distributed with another package (usually shadow-utils).
The following configuration items are relevant for *aggety*:

*LOGIN_PLAIN_PROMPT* (boolean)::

Tell *agetty* that printing the hostname should be suppressed in the login: prompt. This is an alternative to the *--nohostname* command line option. The default value is _no_.

== EXAMPLE

This section shows examples for the process field of an entry in the _/etc/inittab_ file. You'll have to prepend appropriate values for the other fields. See *inittab*(5) for more details.
Expand Down
9 changes: 9 additions & 0 deletions term-utils/agetty.c
Expand Up @@ -31,6 +31,7 @@
#include <sys/socket.h>
#include <langinfo.h>
#include <grp.h>
#include <pwd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <ifaddrs.h>
Expand All @@ -48,6 +49,8 @@
#include "color-names.h"
#include "env.h"

#include "logindefs.h"

#ifdef USE_PLYMOUTH_SUPPORT
# include "plymouth-ctrl.h"
#endif
Expand Down Expand Up @@ -495,7 +498,13 @@ int main(int argc, char **argv)
if (options.flags & F_NOPROMPT) { /* --skip-login */
eval_issue_file(&issue, &options, &termios);
print_issue_file(&issue, &options, &termios);

} else { /* regular (auto)login */
if ((options.flags & F_NOHOSTNAME) == 0 &&
getlogindefs_bool("LOGIN_PLAIN_PROMPT", 0) == 1)
/* /etc/login.defs enbles --nohostname too */
options.flags |= F_NOHOSTNAME;

if (options.autolog) {
/* Autologin prompt */
eval_issue_file(&issue, &options, &termios);
Expand Down

0 comments on commit 556925f

Please sign in to comment.