Commit Graph

113 Commits

Author SHA1 Message Date
Karel Zak 583627ef36 agetty: add support for \e in issue file to print \033
Suggested-by: Victor Ananjevsky <ananasik@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-11 12:33:57 +01:00
Karel Zak 5184d93630 agetty: don't ignore netlink on select()
agetty uses NETLINK_ROUTE to be notified about network interface
changes. Unfortunately, the code that monitor the netlink FD does not
increment number of the monitored file descriptors when call
select(2), so the netlink notifications are invisible for agetty.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1278906
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-24 17:44:38 +01:00
Sami Kerola c3a9f86fcd agetty: fix chown(3), chmod(3) and open(3) race
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-09 09:56:14 +01:00
Karel Zak a359830c1a agetty: cleanup plymouth usage [coverity scan]
* use macros for paths
* check open() return value

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 11:48:01 +02:00
Stef Walter e36deb6424 agetty: Reprompt once the network addresses change if address displayed
Several of the /etc/issue escape codes such as \4 and \6 depend on
the current addresses of the system that can change after the agetty
prompt is displayed.  This can cause stale data to be displayed
when a user looks at a VT, especially in cases of DHCP racing with
system start up.

Similar to the --reload mechanism, if we're displaying an address
in the issue output, and the user hasn't typed anything yet: then
redisplay the prompt with the new address.

We use netlink to watch for address changes. We only open the netlink
socket if we display an address in the issue file.
2015-07-20 11:17:23 +02:00
Karel Zak c2ef308bbf agetty: reload issue on --autologin --login-pause too
The current "agetty --reload" implementation does not refresh issue
file output on autologin. Let's support this use-case too.

Reported-by: Sitsofe Wheeler <sitsofe@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-09 12:45:52 +01:00
Karel Zak c9f5ec0faa agetty: make sure that reload file exists
agetty monitors /run/agetty.reload file, unfortunately if the file
does not exist when agetty starts up then "agetty" --reload does not
work. This patch forces agetty to create the file before inotify
is enabled.

Reported-by: Sitsofe Wheeler <sitsofe@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-09 12:26:55 +01:00
Karel Zak b28842ae67 agetty: support /usr/lib/os-release too
http://www.freedesktop.org/software/systemd/man/os-release.html

The file /etc/os-release takes precedence over /usr/lib/os-release.
Applications should check for the former, and exclusively use its data
if it exists, and only fall back to /usr/lib/os-release if it is
missing.

Reported-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-05 12:25:28 +01:00
Benno Schulenberg 54fefa078e textual: fix spellos and inconsistencies in several program messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26 11:17:55 +01:00
Sami Kerola 4ebac79f01 build-sys: fix make checkincludes warnings
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 21:57:53 +00:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Karel Zak 90d5285d8c agetty: use futimens, check for all in configure.ac
It seems better to warn about --reload in ./configure if futimens or
inotify_init1 are missing.

The patch also replaces futimes() with futimens() to make the code
compatible with Uclibc.

Addresses: https://github.com/karelzak/util-linux/issues/133
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-21 11:38:11 +01:00
Karel Zak 3c5ee57cd3 agetty: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-21 09:42:23 +01:00
Karel Zak 914047b498 agetty: keep the current baud before try 9600 on serial lines
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-21 09:03:00 +01:00
Karel Zak 14da9b1f3d agetty: don't ignore TERM
Fix command line parsing to not ignore term setting if no baud
specified, for example:

  /sbin/agetty ttyS0 vt100

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-21 08:43:14 +01:00
Karel Zak 8410cdd38a aggety: always set default serial line speed
* makes speeds table usage more robust
* don't call next_speed() for empty speeds table to avoid division by zero
* default to 9600 when port baud unspecified

Addresses: https://github.com/karelzak/util-linux/pull/131
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-20 10:56:03 +01:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Christoph Egger c32270d41f agetty: fixing FTBFS on !linux (Debian util-linux 2.20.1-1.2)
Handle vc flags missing on FreeBSD
Fix tty creation on kFreeBSD taking patch from 2.19

Addresses-Debian-Bug: #650185
2014-09-17 10:14:50 +02:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Stef Walter 6443dd43da agetty: Reprompt and reprint /etc/issue when asked
Add an 'agetty --reload' command which asks all running agetty
commands to display their prompts again.

Several of the /etc/issue escape codes such as \4 and \S depend on
variable data which can change after the agetty prompt is displayed.
This can cause stale data to be displayed when a user looks at a VT,
especially in cases of DHCP racing with system start up.

We never want this to occur once the user has started typing a
user name. So we detect when the user starts typing, after which
no further reprompting occurs after that point.

[kzak@redhat.com: - add #ifdefs to make it usable on non-inotify systems,
                  - use futimens() with NULL timespec
                  - add --reaload to usage()]

Signed-off-by: Stef Walter <stefw-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-28 16:33:33 +02:00
Samuel Thibault 88e0f3df66 build-sys: fixes for non-Linux systems
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-19 10:35:23 +02:00
Benjamin Robin 584c07449c agetty: Update help usage function
Signed-off-by: Benjamin Robin <dev@benjarobin.fr>
2014-05-18 02:48:14 +02:00
Benjamin Robin 6c77c7fac2 agetty: Fix implementation of option --nonewline. The flag F_NONL was never set.
Signed-off-by: Benjamin Robin <dev@benjarobin.fr>
2014-05-18 02:47:42 +02:00
Karel Zak 0f283438bf agetty: use the "best" interface for \4 and \6
The issue file escape sequences \4 and \6 prints the host IP when no
interface is specified. That's useless on some virtual machines where
gethostname()+getaddrinfo() returns 127.0.0.1.

The seems better to print IP of the "best" interface (UP, RUNNING, non-LOOPBACK)
and use gethostname() as painful fallback only.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1090935
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 15:23:42 +02:00
Karel Zak c6b3513942 agetty: fix odd check for chardev/tty
References: https://bugzilla.redhat.com/show_bug.cgi?id=1069902
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:28:48 +02:00
Werner Fink b9c7390948 agetty: beside virtual consoles support xvc and hvc device lines as well
For this approach do not use the ioctl TIOCMGET anymore as this
is for real serial lines only. But switch over to use the ioctl
KDGKBMODE as this is unique to the virtual console lines only.

Signed-off-by: Werner Fink <werner@suse.de>
2014-05-13 10:40:11 +02:00
Werner Fink f2bcda5183 agetty: better support of the special system consoles on S390
That is that there are several consoles, the /dev/ttyS0 which
is type of ibm3215 and a dumb terminal, then there is the device
/dev/3270/tty1 which can handle ANSI color escape sequences and is
a ibm327x terminal, and the /dev/ttyS1 which is a vt220 terminal.

The macro is_speed() in agetty.c allows to distinguish between the
terminal line (/dev)3270/tty1 and the speed options on the command
line used in

/run/systemd/generator/getty.target.wants/serial-getty@3270-tty1.service

which is a symbolic link to /usr/lib/systemd/system/serial-getty@.service

Signed-off-by: Werner Fink <werner@suse.de>
2014-05-13 10:39:40 +02:00
Werner Fink bb280f79f1 agetty: avoid that agetty nor sulogin are fooled by a running plymouth
The nowadays used plymouth locks the devices used for the system
console which causes that agetty as well as sulogin can not modify
the termios settings of e.g. the serial devices of the systenm console.

Signed-off-by: Werner Fink <werner@suse.de>
2014-05-13 10:36:49 +02:00
Karel Zak a5bd793996 include/c.h: prefer nanosleep() over usleep()
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.

The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.

The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-24 13:04:14 +01:00
Werner Fink fba8a53542 agetty: support the special terminal on first serial line on a S/390
which is due legacy reasons a block terminal of type 3270 or higher.
Whereas the second serial line on a S/390(x) is a real character
terminal which is compatible with VT220.

Signed-off-by: Werner Fink <werner@suse.de>
2013-12-02 11:07:32 +01:00
Sami Kerola f614b73c0e losetup, agetty: remove unnecessary if's before free()
Reference: http://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/useless-if-before-free
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-02 10:59:20 +01:00
Benno Schulenberg 38ae77d743 textual: make two messages somewhat easier to understand
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:38:39 +02:00
Benno Schulenberg 3755d48b17 agetty: use standard angular brackets in usage message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-04 11:54:49 +02:00
Yuri Chornoivan 0d0d12adf8 Fix various typos 2013-09-28 13:33:59 +03:00
Karel Zak b34f097e75 agetty: add \S to output /etc/os-release data
This patch allows to use a new \S or \S{VARNAME} sequence in the
/etc/issue file. The sequence prints data from /etc/os-release.  The
reason is to keep /etc/issue file distribution and release
independent.

The \S{ANSI_COLOR} is converted to the real terminal escape seq.

For example:

   \S
   Kernel \r on an \m (\l)

or more complex example:

   Welcome to \S{ANSI_COLOR}\S{NAME}0m \S{VERSION}
   Report bugs at \S{BUG_REPORT_URL}.

See http://www.freedesktop.org/software/systemd/man/os-release.html
fr more details about /etc/issue.

Based on patch from Bill Nottingham <notting@redhat.com>.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-12 12:44:09 +02:00
James Buren f28dde8ecf agetty: add baud rates available from glibc that are not already supported
This adds userspace support for baud rates reater than 230400, provided the tty
also supports it.
2013-09-12 11:03:59 +02:00
James Buren 09625c2ec7 agetty: only use EXTA/EXTB macros if B19200/B38400 macros are not present 2013-09-12 11:02:48 +02:00
Karel Zak 46568b002d agetty: cleanup debug ifdefs
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-09 09:15:40 +02:00
Sami Kerola cfa7fe890b last, utmpdump, agetty, wall, write: avoid compatibility hacks
In include/bits/utmp.h the ut_user and ut_time macros are marked with
comment they are backwards compatibility hacks.  It is probably best to
avoid use of these macros where ever possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:10 +01:00
Karel Zak 6f96420666 agetty: -L accepts optional argument
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-06 15:39:11 +02:00
Sami Kerola 3797cf255b agetty: fix memory leak [clang-analyzer]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-09 14:25:15 +02:00
kernc a056cfe290 Fixes "getty: unrecognized option '--loginpause'"
Usage incorrectly stated --loginpause is a valid option, where instead --login-pause is.

Also --no-hostname --> --nohostname.
2013-07-04 17:02:57 +02:00
Karel Zak 714cff30fd agetty: use O_NONBLOCK only for serial lines with CLOCAL
* regression introduced by ef264c830e

 * also increase sleep when O_NONBLOCK used (grr.. this is so stupid
   thing, do we really need O_NONBLOCK for the stupid serial lines?)

References: https://bugzilla.redhat.com/show_bug.cgi?id=972457
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-06-13 11:30:02 +02:00
Karel Zak 4cfda3dce0 agetty: update man page and usage()
- baud_rate is optional
 - agetty has been rewritten 2 years ago, so don't blame original
   authors in the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-06-03 10:04:43 +02:00
Karel Zak ef264c830e agetty: allow full control on CLOCAL flag
Now the -L option allows to explicitly enable CLOCAL flag.

Unfortunately sometimes it's necessary to clear the flag. This patch
add optional argument =<mode> to specify 'auto', 'always' and 'never'
to control CLOCAL flag.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=816342
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-23 09:47:58 +02:00
Sami Kerola 1aba8336c0 agetty: check writing to a file was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-26 13:26:06 +02:00
Sami Kerola 86ad1432e8 agetty: the command does not have -h and -V options
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-05 13:55:54 +02:00
Karel Zak 4b856ee4b9 agetty: add --chroot to usage() and man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-05 12:55:20 +02:00
Karel Zak 1505a0b266 agetty: add -E, --remote to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-05 12:47:42 +02:00
Karel Zak 8362545b4a lib/xalloc: fix mamory leak in xgethostname() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:08:47 +01:00