/etc/ttys seems to be a rather archaic concept that is not meant to
exist on Linux. Nevertheless it does. glibc has getttynam() which
correctly parses /etc/ttys. So let's give it a try before falling back
to the built in defaults. One can set the terminal type for a
specific tty using e.g.:
echo 'ttyS0 "" xterm' > /etc/ttys
[kzak@redhat.com: - improve configure.ac part
- log error on failed strdup()]
Signed-off-by: Karel Zak <kzak@redhat.com>
getrandom \
getrlimit \
getsgnam \
+ getttynam \
inotify_init \
jrand48 \
lchown \
# include <sys/param.h>
#endif
+#ifdef HAVE_GETTTYNAM
+# include <ttyent.h>
+#endif
+
#if defined(__FreeBSD_kernel__)
# include <pty.h>
# ifdef HAVE_UTMP_H
if (tcgetattr(STDIN_FILENO, tp) < 0)
log_err(_("%s: failed to get terminal attributes: %m"), tty);
+#ifdef HAVE_GETTTYNAM
+ if (!op->term) {
+ struct ttyent *ent = getttynam(tty);
+ /* a bit nasty as it's never freed */
+ if (ent && ent->ty_type) {
+ op->term = strdup(ent->ty_type);
+ if (!op->term)
+ log_err(_("failed to allocate memory: %m"));
+ }
+ }
+#endif
+
#if defined (__s390__) || defined (__s390x__)
if (!op->term) {
/*