]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: add support for LOGIN_PLAIN_PROMPT
authorKarel Zak <kzak@redhat.com>
Mon, 21 Mar 2022 12:19:38 +0000 (13:19 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 30 Mar 2022 09:14:30 +0000 (11:14 +0200)
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>
term-utils/Makemodule.am
term-utils/agetty.8.adoc
term-utils/agetty.c

index 119324f5b0608c4f1dc8583c42c973acf23b205f..07004d43ca1175f22d0d57aee704674d1287f3f8 100644 (file)
@@ -46,7 +46,8 @@ 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
@@ -54,6 +55,9 @@ agetty_LDADD = $(LDADD) libcommon.la
 if BSD
 agetty_LDADD += -lutil
 endif
+if HAVE_ECONF
+agetty_LDADD += -leconf
+endif
 endif # BUILD_AGETTY
 
 
index 123134e0973074e5b7e92553644b5dc25e219b12..7a298f723f9ee3eea0e6436afdae011e9fca957c 100644 (file)
@@ -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.
@@ -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.
index 5b673e638bdcb6e84263c2fa3e9d22f886238247..9b0812734e25c34044c041968dbcf2f0a58d0d81 100644 (file)
@@ -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>
@@ -48,6 +49,8 @@
 #include "color-names.h"
 #include "env.h"
 
+#include "logindefs.h"
+
 #ifdef USE_PLYMOUTH_SUPPORT
 # include "plymouth-ctrl.h"
 #endif
@@ -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);